1 Random number distributions (PDFs)

In most experiments, it turns out that if one were to take thousands of measurements, and from all of these compute the probability dPdxξ(ξ) (called the PDF or probability distribution function of x) that any one measurement results in a value for x between ξ and ξ + , one would get a probability distribution like the following;

dP   (ξ)       1       (ξ- ˉx)2
---x---- =  √-------e ---2σ2-
   dξ         2 π σ
This is called a Normally distributed random variable, and the most probable outcome of a measurement is called xor ˉx. This is in fact the average measurement
     ∫    d℘x( ξ)
ˉx =     ξ --------dξ
            dξ
Since we have no idea how the actual physical data is distributed (we can’t know d℘x(ξ)
  dξ), we estimate the mean as
                                      ∑N
ˉx =  〈x 〉 =  x1-+--x2-+-⋅-⋅⋅ +-xN--=  --i=1-xi
                      N                  N
Example Suppose that 100,000 measurements of quantity x indicate that the measured value of x is Normally random with ˉx = 2.0cm and σ = 1.0cm. If you were to make a measurement of x, what is the probability that your resulting value would be between 1.9 and 1.91?
It would be
            1       - (2.0-1.9)2-
dP   ≈  √----------e   2(1.0)2  ⋅ (0.01) =  0.039
          2π  ⋅ 1.0

The actual distribution is the Bell-curve which looks like the following;

PIC

This type of random number is important for a second reason that is very deeply connected with lab measurements; averages of collections of random numbers are always themselves Normally distributed. This is called the Central Limit Theorem of statistics. It means that we do not need to know the probabilities of actually getting a particular measurement result, averages of many measurements will always be Normal random numbers, which is why any proper experiment will always involve many measurements from which averages are computed. Another corollary of the theorem is that averages come closer to the “true” value than single measurements in the absence of systematic errors. If quantity x is randomly distributed with standard deviation (precision) σx, then averages of sets of N measurements of x are normally distributed with standard deviation

       ---σx-----
σ ˉx =  √ N  -  1 < <  σx
The mean is more “tightly distributed”, and this translates into averages being a more precise measure of a quantity’s actual value.

1.1 Experimental error

The standard deviation σ is a measure of the precision (not accuracy) of the measurement set; the smaller σ, the “tighter” the distribution of outcomes. This means that your chances of making a measurement close to the true value (assumed to be the mean in the absence of systematic errors) is higher as σ gets smaller. The calculation of σ is simple, as it measures the average deviation of each measurement from the mean value; if we actually knew the PDF of x we would use

      ∫
σ2 =    (ξ -  ˉx)2 d℘x(-ξ)-d ξ
                    d ξ
but we in general do not, so we estimate the standard deviation as
                2             2                    2     ∑N            2
  2    (x1----ˉx)--+--(x2----ˉx)--+--⋅⋅⋅ +-(xN-----ˉx)--    --i=1(xi----xˉ)---
σ   =                     N  -  1                    =       N  -  1
This is the quantity that we will associate with the experimental error. We will accept σ as being a measure of experimental precision, which is what we actually mean when we refer to experimental error. If a given set of data has a standard deviation of sigma, then any randomly chosen result has a better than 89% chance of being between ˉx - σ and ˉx+ σ.

2 Error propagation

If you measure a quantity x in the lab, and get N values {x1,x2,⋅⋅⋅,xN} with mean ˉx = ξd℘xdξ(ξ)and standard deviation (squared) σx2 = (ξ -ˉx)2 d℘dxξ(ξ), and then use this data to compute some function of x, say g(x), how do you report your results?
This is the topic of error propagation, what are the means and standard deviations of functions of random numbers?
The answer comes from a major theorem in the mathematics of random numbers (statistics); the Law of the Unconscious Statistician;

-----            ∫
g(x)  =  g(ˉx)  =    g(ξ) d-℘x(-ξ) dξ
                            dξ
which is not difficult to prove.
Using this we can easily compute the standard deviation in g since it is just a mean (of (g(ξ) -ˉg )2 );
      ∫
  2                 2 d℘x(-ξ)-
σ g =   (g( ξ) - ˉg)     dξ    dξ
We use the Taylor theorem to expand g(ξ) about the mean value
                  dg
g( ξ) =  g(ˉx) +  (---)  (ξ - ˉx) +  ⋅⋅ ⋅
                  d ξ ˉx
and so we get
       ∫  dg              d℘  (ξ)         dg
σ2  =    (---)2 (ξ -  ˉx)2 ---x----d ξ =  (---)2σ2
  g       d ξ xˉ             dξ           dx  ˉx  x
and by taking roots
       dg
σg =  ∣---∣ σx
       dx  ˉx
A detailed analysis using basic statistics indicates that the standard deviation of a quantity that is a function of a set of random variables is of a form that suggests the interpretation that errors combine like perpendicular vectors. In other words errors in independent quantities cannot cancel, but simply combine in such a way as to result in a maximal error.
If
y =  f(x  ,x  ,⋅⋅⋅)
         1   2
then
  2     ∂f---2  2      ∂f---2  2            -∂f--  2  2
σ y =  (∂x  )  σx1 +  (∂x  )  σx2 +  ⋅⋅⋅ + (∂x    ) σ xN
           1              2                     N
in which each function ∂f _ ∂xi is computed using the averages ˉxi.

2.0.1 A summary for the impatient

If in the lab you measure several quantities a, b, and c each N times, obtaining the data sets

{a  ,a , ⋅⋅⋅,a   },   {b  ,b ,⋅⋅ ⋅,b  },   {c  ,c ,⋅ ⋅⋅,c  }
   1  2        N         1  2       N         1  2       N
and must compute some function f(a,b,c) as an experimental result, What must you do?

Step 1. Estimate the means and standard deviations (estimate since you do not know the true PDFs for a,b and c)

         N∑                   ∑N                  ∑N
ˉa =  -1-    a ,      ˉb =  1--   b ,      ˉc =  1--    c
     N  i=1  i            N  i=1  i           N  i=1  i
and
      ┌│ ----------------------            ┌│ ---------------------            ┌│ ---------------------
      ││    1    ∑N                        ││    1    ∑N                       ││     1    N∑
σa =  ∘ --------   (ai -  ˉa)2,      σb =  ∘ --------   (bi - ˉb)2,     σc  = ∘  --------   (ci - ˉc)2
        N   - 1 i=1                         N  -  1 i=1                         N  - 1 i=1

Step 2. Compute the derivatives

              ∂f  (a,b, c)                     ∂f (a, b,c)                     ∂f  (a,b, c)
fa(a, b,c) =  ------------,      fb(a, b,c) =  ------------,     fc(a, b,c) =  ------------
                   ∂a                              ∂b                               ∂c

Step 3. Compute the mean f;

ˉ         ˉ
f =  f (ˉa,b, ˉc)
and its standard deviation (squared)
σ2 =  (f  (ˉa,ˉb, ˉc)σ  )2 + (f  (ˉa,ˉb, ˉc)σ  )2 + (f ( ˉa,ˉb,cˉ) σ  )2
 f       a          a        b          b        c          c
and report as the results of your experiment
 ˉ
f  ± σf

2.0.2 Examples

Suppose that we measure the critical angle for a static equilibrium on an inclined plane, and discover that motion begins at angle θ = 0.120, 0.123, 0.119, 0.121, 0.120, 0.121 radians for six trials. The mean of these is estimated to be

ˉθ =  0.120--+--0.123-+--0.119--+--0.121-+--0.120--+-0.121--=  0.120667
                               6
and the standard deviation is estimated to be
  2    1-                      2                        2                         2
σ θ =  5((0.120  - 0.120667)    +  (0.123 -  0.120667)    + (0.119  - 0.120667)
                       2                      2                       2
+(0.121  - 0.120667)    +(0.120  - 0.120667)   +(0.121  -  0.120667)   ),     σ θ =  0.00137
The coefficient of friction computed from this is then
ˉμs =  tan  ˉθ =  tan 0.120667   =  0.12126
The error in its value is then, with
∂-tan--θ    ---1---
         =      2
   ∂θ       cos  θ
equal to
σ   =  ∣--σθ--∣ =  0.00137-- =  0.0014
 μs     cos2 ˉθ      0.9840
In our lab report we would write
μs ±  Δ μs  =  0.12126  ±  0.0014

Example The error in the area of a circle whose radius measurements have average ˉR and standard deviation σR; use

          2       ∂A--
A  =  π R  ,      ∂R  =  2 πR
so
σ   = ∣2π Rˉ∣σ
  a            R

Example An experiment measures three quantities a, b, and c repeatedly, getting averages ˉa, ˉb , and ˉc and standard deviations σa, σb, and σc for them. These data are used to obtain an experimental value for a quantity d supposedly given by the formula

d =  ax by cz
in which x, y, and z are constants. What is the experimental value of d and its standard deviation?
Constants are assumed to be known to at least one full digit or significant figure than data. We will need only the derivatives
∂d-       x- 1 y  z      d-      ∂d-       x  y- 1 z     d-
    =  x a    b  c  =  x  ,          =  y a  b    c  =  y
∂a                       a       ∂b                      b
and
∂d-        x y  z- 1     d-
    =  z a  b  c    =  z
 ∂c                      c
which we compute using the averages
{ˉa, ˉb, ˉc},      and       ˉd =  ˉax ˉby ˉcz
All of these factors go into the formula
 2       ˉd-2  2      dˉ 2  2      dˉ 2  2
σd =  (x ˉa)  σa +  (yˉb)  σb +  (zˉc ) σ c

Remember that you can use the binomial theorem

        n
(1 + δ)   ≈  1 + n δ +  ⋅⋅⋅
to compute the derivatives. In fact the binomial theorem itself can be used to quickly arrive at a formula very close to the correct error expression without the use of calculus in the following way.

Example Obtain an error formula for A = a2
b-
Partial derivatives of multi-variable functions are the same as ordinary derivatives

∂A           A(a  +  δa, b) - A(a,  b)          (a2 + 2a  δa +  (δa)2)b - 1 - a2b - 1
---- =  lim  --------------------------=   lim   -------------------------------------
 ∂a     δa→0            δa                δa→0                  δa
=  lim (2ab - 1 + δa b- 1) =  2ab - 1 = 2a-
   δa→0                                   b
and
                                                      2        2
∂A--=   lim   A(a,-b-+--δb)----A(a,-b)-=   lim   1-(---a--- -  a--)
∂b     δb→0             δb               δb→0  δb b +  δb     b
Use synthetic division or the binomial theorem
--1----    ----1------   1-   δb-
        =         δb  ≈    -   2 +  ⋅⋅⋅
b + δb     b(1 +  b )    b    b
to get
∂A           1      a2δb               a2
----=  lim  ---( -  --2--+  ⋅⋅⋅ ) = -  -2-
∂b     δb→0 δb       b                 b

3 Linear regression

Several of the experiments test a hypothesis that some quantity y is related to another quantity x according to a linear relation y = ax + b. The experiment is usually about testing the hypothesis by taking a set of data {(xi,yi)i = 1,2,⋅⋅⋅,N} and using the data to compute a the slope and b the intercept of the relation and comparing the results to the theoretical values. We perform such an analysis by computing a and b for the line that most closely conforms to the set of data taken in the lab, through the method of linear regression.

Consider the two collections of points {(xi,yi)i = 1,2,⋅⋅⋅,N}, which is your lab data, and {(xi,axi + b)i = 1,2,⋅⋅⋅,N} which is the “true” set of points gotten by using the actual theoretical relation between x and y, which is assumed to be the straight line y = ax + b. Consider then the sum of squares of the distances between corresponding points in the two sets;

  2   ---1---- N∑                    2
σ  =              (yi - (axi  + b))
      N   - 1  i=1
The line that best conforms to the set of data is the line for which this quantity is smallest, in other words the line from which the points deviate the least from vertically.

PIC

To find the slope a and b of the best fit line we simply minimize σ2 with respect to a and b; set the derivatives to zero

   2             ∑N
∂σ---=  0 =  - 2    x  (y  -  (ax  +  b))
 ∂a              i=1  i   i       i
∂σ2              N∑
-----=  0 =  - 2    (yi - (axi +  b))
∂b              i=1
which results in two equations in a and b
∑              ∑    2     ∑                ∑          ∑
   (xiyi) -  a    x i - b     xi =  0,         yi - a     xi - N  b =  0
 i              i          i                i          i
which we solve for the best fitting line parameters
         ∑            ∑     ∑                ∑    2 ∑       ∑      ∑
a  =  N----i(∑xiyi)----∑-i xi--i yi,     b =  --i x-i-∑i yi----i∑xi---i(xiyi)
         N    i x2i - ( i xi)2                    N    i x2i - ( i xi)2
and obtain standard deviations as well, by using the shorthand
S   = ∑   x  = ⃗x⋅⃗u,      S  2 = ∑  x2  =  ⃗x⋅⃗x,      N  =  ⃗u ⋅⃗u,      ⃗x  =  (x ,x  ,⋅⋅ ⋅,x  )
  x    i   i                x     i   i                                      1   2        N
and ⃗u = (1,1,⋅⋅⋅,1). The formulas for a and b define them to be linear functions of the random deviates ⃗y = (y1,y2,⋅⋅⋅,yN)
      N                                  N
     ∑    N-xi----Sxui--                ∑    Sx-xi----Sx2ui-                     2       2
a =      (     D       )yi,      b =  -     (      D        )yi,      D  =  N Sx  - (Sx)
     i=1                                i=1
To get the standard deviations we regard a and b as random deviates, and expand each around their means
--   N∑   N--xi----Sxui- ---      --     ∑N   Sx-xi----Sx2ui- ---
a =     (      D       )yi,      b = -     (       D        )yi
     i=1                                 i=1
This leads to
--------2-    N∑    N--xi---Sxui--  N-xj----Sxuj-- ---------------------
(a -  a)  =       (              )(              )(yi -  yi)(yj -  yj)
             i,j=1        D               D
We assume that each yi measurement is independent of yj⁄=i, so that all non-diagonal correlation coefficients vanish,
---------------------                         ---------2-    2
(yi -  yi)(yj -  yj) =  0,   if  i ⁄=  j,      (yi - yi)  =  σi
and so
 2    N∑   N  xi - Sxui   2  2
σa =     (--------------) σ i
       i        D
In practice we use the same σi2 for each yi;
 2     2       1    ∑N                   2
σi =  σ  =  --------   (yi -  (axi +  b)) ,      ∀i
            N  -  1 i=1
resulting in
          N 2⃗x ⋅ ⃗x -  2N Sx ⃗x ⋅ ⃗u +  S2⃗u ⋅ ⃗u     N
σ2a =  σ2( ----------------------------x------) =  --σ2
                          D2                      D
We can do the same for σb, starting with
        N∑   Sxxi  -  Sx2ui
b =  -     (---------------)yi
       i=1        D
---------     N
      --2    ∑     Sxxi----Sx2ui--  Sxxj----Sx2uj-- ---------------------   Sx2-  2
(b -  b)  =      (       D       )(       D        )(yi -  yi)(yj -  yj) =   D  σ
            i,j=1
The two standard deviations are therefore
               ∑
 2    ------σ2---i-x2i------        2    --------σ2N----------
σb =     ∑    2    ∑      2,      σa =     ∑    2    ∑      2
      N    i x i - ( i xi)              N    i x i - ( i xi)
In this formula σ is the standard deviation of the yi measurements, all assumed to be the same for each i. This can be estimated, or you could measure yi several times for each i, and compute it more rigorously.

3.0.3 A summary for the impatient

If you have a collection of data points

{(x1, y1), (x2, y2),⋅ ⋅⋅,(xN  ,yN )}
that presumably fall on a straight line y = ax + b, the slope a and intercept b of the line that best fits this data are gotten as follows;

Step 1. Compute

      ∑N               ∑N               N∑                N∑
Sx =      xi,   Sx2 =      x2,   Sy  =     yi,   Sxy  =     xi yi
      i=1              i=1  i           i=1               i=1

Step 2. The best fit slope and intercept are

     N--Sxy----SxSy--           Sx2Sy-----SxSxy--
a =  N S  2 - (S  )2 ,     b =   N S  2 - (S  )2
         x       x                   x       x
respectively. To get estimates of the error in a and b take another step;

Step 3. Compute

               N
σ2 =  ---1----∑   (y  - (ax   + b))2
      N   - 1       i       i
              i=1
Then
                2                            2
 2    -----N--σ-------        2    -----Sx2σ-------
σa =  N  S  2 - (S  )2,      σb =  N  S 2 -  (S )2
          x        x                   x       x

3.1 Programs

Curses-based coinsole programs. Requires PD-curses and perhaps GMP.

Simple command-line linear fit (regression).