hubble’s law and model fitting

18
Hubble’s Law and Model Fitting Computational Physics Physics is a natural science which attempts to describe the Universe in terms of a few basic concepts such as time, space, mass, and electric charge. These quantities can be assigned numerical values that every physicist can agree upon. Nature is complex, so physicists choose to study natural phenomena that appear to be as simple as possible and can be reproduced reliably by other physicists. Most physicists specialize in one of three types of activity. Experimental physicists observe these phenomena, measure their properties using instruments, and attempt to discover simple laws describe these observations: experimental physics is based on technology. Theoretical physicists invent mathematical models that relate measured properties and construct theories which organize and unify these models: theoretical physics is based on mathematics. Computational physicists use digital computers to analyze experimental data and explore the properties of models and theories: computational physics is based on computer science an numerical analysis. Experimentalists spend most of their time designing and building instruments, and in collecting and analyzing experimental data. Theorists work primarily with mathematical theories and equations, and make predictions that can be verified or falsified by experiment. Computationalists design algorithms to solve equations or analyze data, write and debug computer programs that implement algorithms, and run simulations to explore theories and compare with experimental data. The Expanding Universe A galaxy is a collection of several billion stars. Galaxies have characteristic shapes and are separted from one another by empty space. More than 10,000 galaxies have been identified and cataloged, and Earth receives light from more than a hundred billion galaxies. The location and speed of a galaxy are examples of natural phenomena that astronomers have attempted to measure. Fig. 1 shows a typical galaxy studied by Edwin Hubble[1] and his collaborator Milton Humason. Cepheid Variables as Standard Candles A Cepheid variable is a type of star whose luminosity varies with a period of a few days. Its absolute luminosity can be predicted from its period. Its apparent luminosity observed on Earth can therefore be used to infer its distance. The speed of a galaxy can be inferred from the shift in wavelength of spectral lines in the light it emits. Lines from distant galaxies are generally redshifted, which indicates that they are receding from us. Hubble analyzed the data in Fig. 2 using the relation rK + X cos α cos δ + Y sin α cos δ + Z sin δ = v, (1) where r, v are the measured distance and speed of the galaxy located at galactic longitude α and latitude δ, and K,X,Y,Z are constants. Fig. 3 shows the results of his analysis. He concluded that K 500 km/s/Mpc, which is considerably larger that the current best value of Hubble’s constant H(t 0 ) 72 km/s/Mpc. 1

Upload: dimitrideliyianni

Post on 11-Sep-2015

23 views

Category:

Documents


7 download

DESCRIPTION

Hubble’s Law and Model Fitting

TRANSCRIPT

  • Hubbles Law and Model Fitting

    Computational Physics

    Physics is a natural science which attempts to describe the Universe in terms of a few basic concepts suchas time, space, mass, and electric charge. These quantities can be assigned numerical values that everyphysicist can agree upon. Nature is complex, so physicists choose to study natural phenomena that appearto be as simple as possible and can be reproduced reliably by other physicists.

    Most physicists specialize in one of three types of activity. Experimental physicists observe thesephenomena, measure their properties using instruments, and attempt to discover simple laws describe theseobservations: experimental physics is based on technology. Theoretical physicists invent mathematicalmodels that relate measured properties and construct theories which organize and unify these models:theoretical physics is based on mathematics. Computational physicists use digital computers to analyzeexperimental data and explore the properties of models and theories: computational physics is based oncomputer science an numerical analysis.

    Experimentalists spend most of their time designing and building instruments, and in collecting andanalyzing experimental data. Theorists work primarily with mathematical theories and equations, andmake predictions that can be verified or falsified by experiment. Computationalists design algorithms tosolve equations or analyze data, write and debug computer programs that implement algorithms, and runsimulations to explore theories and compare with experimental data.

    The Expanding Universe

    A galaxy is a collection of several billion stars. Galaxies have characteristic shapes and are separted fromone another by empty space. More than 10,000 galaxies have been identified and cataloged, and Earthreceives light from more than a hundred billion galaxies. The location and speed of a galaxy are examplesof natural phenomena that astronomers have attempted to measure. Fig. 1 shows a typical galaxy studiedby Edwin Hubble[1] and his collaborator Milton Humason.

    Cepheid Variables as Standard Candles

    A Cepheid variable is a type of star whose luminosity varies with a period of a few days. Its absoluteluminosity can be predicted from its period. Its apparent luminosity observed on Earth can therefore beused to infer its distance.

    The speed of a galaxy can be inferred from the shift in wavelength of spectral lines in the light it emits.Lines from distant galaxies are generally redshifted, which indicates that they are receding from us.

    Hubble analyzed the data in Fig. 2 using the relation

    rK +X cos cos + Y sin cos + Z sin = v , (1)

    where r, v are the measured distance and speed of the galaxy located at galactic longitude and latitude ,and K,X, Y, Z are constants. Fig. 3 shows the results of his analysis. He concluded thatK 500 km/s/Mpc, which is considerably larger that the current best value of Hubbles constantH(t0) 72 km/s/Mpc.

    1

  • Figure 1: Hubble lists Barnards Galaxy NGC 6822, see http://antwrp.gsfc.nasa.gov/apod/ap020123.html, at a distance r = 0.214 Mpc (1 Mega-parsec = 3.0861019 km) moving towards us with speed v = 130km/s.

    General-Relativistic Theory of Cosmology

    General Relativity is a mathematical theory that relates the properties of time and space to the energydensity measured at each point in space and instant of time. The mathematical equations of GeneralRelativity can be written

    R 12gR = 8GN

    c4T g (2)

    where GN is Newtons gravitational constant, c is the speed of light, and is the cosmological constant.The other quantities in the equation are functions of the time-space 4-vector x = {ct,~r}. The metrictensor g(x) describes the geometry of spacetime, the Ricci tensor R and curvature scalar R arefunctions of the metric tensor and its spacetime derivatives, and the stress-energy tensor T, representsthe energy and momentum density of matter and radiation.

    This complex set of nonlinear partial differential equations is extremely challenging to solve. Analyticsolutions exist only for very simple distributions of matter and radiation. The simplest cosmological modelassumes that spacetime is homogeneous and isotropic and described by the Robertson-Walker metric

    ds2 3

    =0

    3=0

    gdxdx = c2dt2 R2(t)

    [dr2

    1 kr2 + r2(d2 + sin2 d2)

    ], (3)

    where R is the cosmological scale factor, r, , are spherical-polar coordinates, and the curvature constantk = 0,1 signifies a flat, open, or closed universe.The simplest assumption about matter and radiation is that it behaves like uniform perfect fluid withdensity and pressure p. This leads to the Friedmann-Lamatre equations

    H2 (R

    R

    )2=

    8GN

    3 kc

    2

    R2+

    c2

    3,

    R

    R= 4GN

    3(+ 3p) +

    c2

    3. (4)

    H(t) is the Hubble parameter and its value at the present time t0 is Hubbles constantH(t0) = 72 km/s/Mpc.

    2

  • Figure 2: Table 1 from Hubbles paper [1].

    3

  • Figure 3: A Figure from Hubbles paper [1].

    4

  • We will study these differential equations later in the course. For this lecture all we need to know is how torelate them galaxy redshifts in an expanding universe. Suppose R1 is the scale factor when light offrequency 1 was emitted from a distant galaxy, and R2 is the scale factor when this light is observed onEarth with frequency 2, then the redshift z is given by

    z + 1 =12

    =R2R1

    1 + v12c

    , (5)

    where v12 is the speed of the distant galaxy relative to the observer.

    Algorithm for fitting data to a straight line

    Consider a data set with n data points labeled by an index i = 0, 1, . . . , n1. Each point consists of tworeal numbers xi, yi. For example, n is the number of observed galaxies, and xi and yi are their radialdistances and velocities.

    We would like to summarize this data set using a model equation that relates the two real variables x, y,for example a linear model

    y(x) = a+ bx , (6)

    with intercept a and slope b.

    Least-squares algorithm

    The least-squares algorithm determines the model parameters a, b by minimizing the function

    f(a, b) n1i=0

    (yi a bxi)2 . (7)

    This procedure tends to make the deviation of yi from the point y(xi) = a+ bxi on the straight line assmall as possible. The derivatives of f vanish at its minimum

    f

    a= 2

    n1i=0

    (yi a bxi) = 0 , and fb

    = 2n1i=0

    xi(yi a bxi) = 0 . (8)

    These two equations can be solved simultaneously for the two unknowns a, b. Define the following sums:

    sx n1i=0

    xi , sy n1i=0

    yi , sxx n1i=0

    x2i , sxy n1i=0

    xiyi . (9)

    Then the least-squares values of the parameters are given by

    a =sxxsy sxsxynsxx s2x

    , b =nsxy sxsynsxx s2x

    . (10)

    Uncertainty estimates

    The number of degrees of freedom of the fit is the number of data points minus the number of parameters: = n 2. An estimate of the variance of the data set from the model prediction is

    2 f(a, b)

    =1

    n 2n1i=0

    (yi y(xi))2 . (11)

    5

  • The standard deviation is an estimate of the error bar in each yi. These error estimates can bepropagated to the parameters a, b considered as functions of yi:

    2a =

    n1i=0

    (a

    yi

    )2=

    2sxxnsxx s2x

    , 2b =

    n1i=0

    (b

    yi

    )2=

    2n

    nsxx s2x. (12)

    Programming in C++

    The simplest C++ program consists of 12 characters:

    int main(){}

    Every C++ program must define a unique main function, which can have either no arguments as definedhere by empty parentheses (), or two arguments usually written (int argc, char *argc[]). The returnvalue of the function is of type int, which usually represents a 32-bit integer in the range [231..2311].Note the required space between int and main. The body of the function in braces {} is empty: thefunction does nothing except to return the integer 0 (zero) by default.

    The following program prints a message on the display.

    #include /* standard C++ input output stream header */

    int main() // main function returns 0 on successful completion

    {

    std::cout

  • started by the two characters /* and ended by the two characters */ and can extend over more thanone line. C++-style comments are started by the two characters // and extend to the end of the line.

    Computing with integers and real numbers

    Physical quantities are represented real numbers, which include integers, rational fractions, and realnumbers like

    2 and that require an infinite number of decimal digits to express exactly. Integers that

    are not too large in magnitude can be represented in C++ by quantities of type int and rationalfractions and real numbers that are not too large or too small can represented by quantities of typedouble with approximately 15 decimal digits of precision.

    #include /* defines arc-tangent function atan */

    #include /* defines cout, cin and endl */

    #include /* defines numeric_limits */

    using namespace std; // import included std objects into global namespace

    const double pi = 4 * atan(1.0); // pi in radians from arc-tangent function

    int main () {

    cout

  • types like int or double as parameters. The type has static member functions, such as min andmax, which return limiting values.

    The program uses the do { } while (condition); control structure: the block of statements in braces{ } is executed repeatedly while the logical expression condition evaluates to true.

    Computing the Hubble Constant

    Hubble used Eq. 1 with 4 parameters to model his data. We will use a simpler linear equation with twoparameters

    v(r) = a+ br , (13)

    to determine Hubbles constant as the slope b using the linear least-squares algorithm.

    #include

    #include

    using namespace std;

    const int n = 24; // number of galaxies in Table 1

    double r[n] = { // distances in Mpc

    0.032, 0.034, 0.214, 0.263, 0.275, 0.275, 0.45, 0.5, 0.5, 0.63, 0.8, 0.9,

    0.9, 0.9, 0.9, 1.0, 1.1, 1.1, 1.4, 1.7, 2.0, 2.0, 2.0, 2.0

    };

    double v[n] = { // velocities in km/s

    +170, +290, -130, -70, -185, -220, +200, +290, +270, +200, +300, -30,

    +650, +150, +500, +920, +450, +500, +500, +960, +500, +850, +800, +1090

    };

    int main() {

    // declare and initialize various sums to be computed

    double s_x = 0, s_y = 0, s_xx = 0, s_xy = 0;

    // compute the sums

    for (int i = 0; i < n; i++) {

    s_x += r[i];

    s_y += v[i];

    s_xx += r[i] * r[i];

    s_xy += r[i] * v[i];

    }

    // evaluate least-squares fit forumlas

    double denom = n * s_xx - s_x * s_x;

    double a = (s_xx * s_y - s_x * s_xy) / denom;

    double b = (n * s_xy - s_x * s_y) / denom;

    8

  • // estimate the variance in the data set

    double sum = 0;

    for (int i = 0; i < n; i++) {

    double v_of_r_i = a + b * r[i];

    double error = v[i] - v_of_r_i;

    sum += error * error;

    }

    double sigma = sqrt(sum / (n - 2)); // estimate of error bar in v

    // estimate errors in a and b

    double sigma_a = sqrt(sigma * sigma * s_xx / denom);

    double sigma_b = sqrt(sigma * sigma * n / denom);

    // print results

    cout.precision(4);

    cout

  • Figure 4: Remnant of the Type Ia supernova SN 1604 http://en.wikipedia.org/wiki/SN_1604 observedby Johannes Kepler.

    Supernovae and Hubbles constant

    A plot of light intensity emitted as a function of time is called the light curve of the supernova explosion.Type Ia supernovae have characteristic light curves from which the their absolute luminosities can beinferred. Their distances from Earth can then be calculated from the observed apparent luminosities.

    Thus Type Ia supernovae can be used as standard candles, just like Cepheid variable stars. Becausesupernova explosions are billions of times brighter than typical stars they can be observed at much greaterdistances from Earth. Their distances and redshifts can be used to measure the Hubble parameter, seeFig. 5.

    Astronomers measure the brightness of an object in the sky using a unit called the magnitude. Theabsolute magnitude of the object is denoted by M and the apparent magnitude by m. The absolutemagnitude is defined to be the apparent magnitude observed at a distance of 10 parsecs from the object.The distance modulus is defined as the difference between the apparent and absolute magnitudes

    mM = 5 log10 r 5 , (14)

    where r is the distance in parsecs of the object from Earth.

    Davis et al.[4] study redshift and distance modulus data using a set of 192 Type Ia supernovae with largeredshifts. This data set is available as a file giving redshift z, distance modulus and the error in foreach object, as shown by the following snippet:

    ; Columns

    ; SN= supernova identifier

    ; z = redshift

    ; mu= distance modulus

    ; mu_err = error in distance modulus

    ;

    ; SN z mu mu_err

    b013 0.4260 41.98 0.23

    d033 0.5310 42.96 0.17

    10

  • Figure 5: From reference [2].

    11

  • d083 0.3330 40.71 0.14

    d084 0.5190 42.95 0.29

    We will write a program to fit this data to a straight line and estimate Hubbles constant. According toEq. 14, Supernova b013 is 248.9 Mpc from Earth, and the relativistic Doppler formula

    1 + z =1 + v

    c1 v2

    c2

    (15)

    gives its speed to be v = 0.341 c. At these cosmological distances and relativistic velocities the equations ofgeneral relativity must be used to relate the general relativistic redshift

    z =R(t0)

    R(t) 1 , (16)

    to the distance modulus. For distant supernovae the relation can be approximated as follows:

    = 25 + 5 log10

    (cz

    H0

    )+ 1.086(1 q0)z + . . . (17)

    where c is measured in km/s and H0 in km/s/Mpc. This equation follows from a Taylor expansion of thecosmic scale factor

    R(t) = R(t0)

    [1 + (t t0)H0 1

    2(t t0)2q0H20 + . . .

    ], (18)

    where t is the time of emission of light from the supernova and

    H0 R(t0)R(t0)

    , and q0 R(t0)R(t0)R2(t0)

    , (19)

    are Hubbles constant and the deceleration parameter at the present cosmological time t0. See Chapter 146 of Weinberg[3] for a detailed derivation of these formulas.

    Chi-square Fitting to a Straight Line

    Hubbles 1929 paper did not quote error bars on the data values, although we can fairly safely assume thathe quoted values with an appropriate number of significant digits. To fit Hubbles data we used a simpleleast-squares fit and estimated the error bar in the data set from the deviations of the data points from thefitted straight line. It is not possible to estimate the reliability of the least-squares fit in the absence oferror bars on the data.

    If the error bars i are available on the y values of the set, then it is possible to take them into account byminimizing the chi-square sum, which is defined as

    2(a, b) n1i=0

    (yi a bxi

    i

    )2. (20)

    In this expression, data values with small error bars are given more weight than data points with largeerror bars.

    The parameters a, b are determined by minimizing this function. The following formulas are discussed indetail in Numerical Recipes[5]:

    b =1

    Stt

    n1i=0

    tiyii

    , a =Sy Sxb

    S, 2a =

    1

    S

    (1 +

    S2xSStt

    ), 2b =

    1

    Stt. (21)

    12

  • Here

    ti =1

    i

    (xi Sx

    S

    ), Stt =

    n1i=0

    t2i , (22)

    and

    S =n1i=0

    1

    2i, Sx =

    n1i=0

    xi2i

    , Sy =n1i=0

    yi2i

    . (23)

    The goodness of fit can be computed as the probability Q that the value of 2 should be greater than orequal to its computed value. Because this involves computing an incomplete Gamma function, we will usethe simpler criterion that the 2 per degree of freedom is close to unity:

    2/d.o.f 1n 2

    n1i=0

    (yi a bxi

    i

    )2 1 . (24)

    Because the fit has two parameters a, b, the number of degrees of freedom is = n 2. Two data pointscan be fit exactly with two parameters. If 2 n 2, then the terms in the sum have average magnitudeclose to one. This implies that the deviations from the straight line are consistent with the error bars. If2/d.o.f 1 the fit is too good to be true; and if it is much larger than unity, data cannot beapproximated by a straight line.

    C++ strings, files and Gnuplot

    A good way of visualizing a data set is to plot it. If you do not have a better plotting program availableyou should download and install Gnuplot from http://gnuplot.info/ and learn how to use it.

    The following simple program shows how to simulate some data points with error bars and plot them usingGnuplot from a C++ program.

    #include /* defines abs() */

    #include /* defines rand() and system() */

    #include /* defines ofstream object for writing to a file */

    #include

    #include /* defines string objects */

    using namespace std;

    // path to gnuplot executable - change if located somewhere else

    #ifdef _MSC_VER /* this variable is defined by Visual C++ */

    string gnuplot("C:\\gnuplot\\bin\\wgnuplot.exe");

    #else /* Linux or Macintosh */

    string gnuplot("/usr/bin/gnuplot");

    #endif

    int main() {

    string plot_file_name("plot.data");

    13

  • ofstream plot_file(plot_file_name.c_str());

    for (int i = 0; i < 50; i++) {

    double x = 0.2 * i;

    double random_error = 0.2 * (-1 + 2.0 * rand() / (RAND_MAX + 1.0));

    double y = sin(x) + random_error;

    double error_bar = abs(random_error);

    plot_file

  • #include

    #include

    #include

    #include

    #include

    #include

    using namespace std;

    // ---------------- declare global variables ----------------

    string url("http://dark.dark-cosmology.dk/~tamarad/SN/");

    string data_file_name("Davis07_R07_WV07.dat");

    vector // C++ std template vector type

    z_data, // redshift - column 2 in data file

    mu_data, // distance modulus - column 3

    mu_err_data; // error in distance modulus - column 4

    // ---------------- function declarations ----------------

    void read_data(); // opens and reads the data file

    void chi_square_fit( // makes a linear chi-square fit

    const vector& x, // vector of x values - input

    const vector& y, // vector of y values - input

    const vector& err, // vector of y error values - input

    double& a, // fitted intercept - output

    double& b, // fitted slope - output

    double& sigma_a, // estimated error in intercept - output

    double& sigma_b, // estimated error in slope - output

    double& chi_square // minimized value of chi-square sum - output

    );

    // ---------------- function definitions ----------------

    int main() {

    cout

  • intercept, slope, intercept_err, slope_err, chisqr);

    cout.precision(4);

    cout

  • double& sigma_b, // estimated error in slope - output

    double& chi_square) // minimized value of chi-square sum - output

    {

    int n = x.size();

    double S = 0, S_x = 0, S_y = 0;

    for (int i = 0; i < n; i++) {

    S += 1 / err[i] / err[i];

    S_x += x[i] / err[i] / err[i];

    S_y += y[i] / err[i] / err[i];

    }

    vector t(n);

    for (int i = 0; i < n; i++)

    t[i] = (x[i] - S_x/S) / err[i];

    double S_tt = 0;

    for (int i = 0; i < n; i++)

    S_tt += t[i] * t[i];

    b = 0;

    for (int i = 0; i < n; i++)

    b += t[i] * y[i] / err[i];

    b /= S_tt;

    a = (S_y - S_x * b) / S;

    sigma_a = sqrt((1 + S_x * S_x / S / S_tt) / S);

    sigma_b = sqrt(1 / S_tt);

    chi_square = 0;

    for (int i = 0; i < n; i++) {

    double diff = (y[i] - a - b * x[i]) / err[i];

    chi_square += diff * diff;

    }

    }

    The chi_square_fit function uses reference objects and variables for its arguments. A reference variableis declared by appending an ampersand & to its type. The function works on the original object orvariable, so any changes it makes persist after it returns. If instead ordinary variables are used, then thefunction makes a copy. For a const input variable copying can waste time and memory, especially theobject is very large. If the function modifies a non-const variable, the changes are made to the copy andare lost when the function returns.

    References

    [1] Edwin Hubble, A relation between distance and radial velocity among extra-galactic nebulae, Proc.Natl. Acad. Sci. USA 15, 168 (1929), http://www.pnas.org/content/15/3/168.full.pdf.

    17

  • [2] K.A. Olive and J.A. Peacock, Big-bang cosmology, in C. Amsler et al., Phys. Lett. B667, 1 (2008),http://pdg.lbl.gov/2009/reviews/rpp2009-rev-bbang-cosmology.pdf.

    [3] S. Weinberg, Gravitation and Cosmology (Wiley, 1972).

    [4] T.M. Davis et al., Scrutinizing Exotic Cosmological Models Using ESSENCE Supernova DataCombined with Other Cosmological Probes, Ap. J. 666 716 (2007),http://arxiv.org/abs/astro-ph/0701510. Data can be downloaded fromhttp://dark.dark-cosmology.dk/~tamarad/SN/.

    [5] W.H. Press, S.A. Teukolsky, W.T. Vetterling and B.P. Flannery, Numerical Recipes in C (CambridgeUniversity Press 1992), 15.2 Fitting Data to a Straight Line,http://www.nrbook.com/a/bookcpdf/c15-2.pdf.

    [6] Herbert Schildt, C++ Beginners Guide,http://msdn.microsoft.com/en-us/beginner/cc305129.aspx, Chapter 1: C++ Fundamentals,http://go.microsoft.com/?linkid=8310946.

    18