# Uncertainties01.wxmx

## Preface

In Uncertainties01.wxmx  we introduce basic concepts in error analysis, with an 
emphasis on the physical sciences. 

Edwin L. (Ted) Woollett
https://home.csulb.edu/~woollett/
June 3, 2024

## References

[HH]  Ifan Hughes, Thomas Hase, Uncertainties: A Practical guide to Modern Error 
Analysis, 2010, Oxford Univ Press.

R. J. Barlow,  Statistics: A Guide to the Use of Statistical Methods in the Physical 
 Sciences  (Manchester Physics Series), 1993, Wiley

Gerhard Bohm, Günter Zech,
Introduction to Statistics and Data Analysis for Physicists, 3rd revised edition, 2017,
       available from CERN webpage:
       https://s3.cern.ch/inspire-prod-files-d/da9d786a06bf64d703e5c6665929ca01

Frederick James, 'Statistical Methods in Experimental Physics', 2nd ed., 
                            2006, World Scientific.

Louis Lyons, Statistics for Nuclear and Particle Physics, 1986, Cambridge Univ. Press,

Luca Lista,  'Statistical Methods for Data Analysis in Particle Physics', 
                          Lecture Notes in Physics 909, 2016,  Springer-Verlag,

Glen Cowan , Statistical Data Analysis, Clarendon Press,  Oxford, 1998

M.I.T. Course: Fundamentals of Statistics, (formerly 'Statistics for Applications'),
                   Philippe Rigollet lectures on YouTube
1.   https://www.youtube.com/watch?v=VPZD_aij8H0
2.    https://www.youtube.com/watch?v=C_W1adH-NVE
List of YouTube videos:
    https://www.youtube.com/playlist?list=PLUl4u3cNGP60uVBMaoNERc6knT_MgPKS0

https://ocw.mit.edu/courses/18-650-statistics-for-applications-fall-2016/
lecture slides: 
      https://ocw.mit.edu/courses/18-650-statistics-for-applications-fall-2016/
                 pages/lecture-slides/
lecture videos: 
       https://ocw.mit.edu/courses/18-650-statistics-for-applications-fall-2016/
                   video_galleries/lecture-videos/
lecture assignments (pdf's): 
     https://ocw.mit.edu/courses/18-650-statistics-for-applications-fall-2016/
                   pages/assignments/

load(draw)$ 
set_draw_defaults(line_width=2, grid = [2,2], point_type = filled_circle,
          head_type = 'nofilled, head_angle = 20, head_length = 0.5,
          background_color = light_gray, draw_realpart=false)$ 
load (descriptive)$  load (distrib)$
 fpprintprec : 5$ ratprint : false$ 

Homemade functions fll, head, tail, Lsum are useful for looking at long lists.

fll ( aL) := [ first (aL), last (aL), length (aL) ]$
head(L) := if listp (L) then rest (L, - (length (L) - 3) ) else 
      error("Input to 'head' must be a list of expressions ")$
tail (L) := if listp (L) then rest (L, length (L) - 3 )  else 
       error("Input to 'tail' must be a list of expressions ")$
Lsum (aList) := apply ("+", aList)$

## fracData (List, a, b)

fracData (alist, a, b) calculates the fraction of the list numbers which lie in the 
     interval [a, b].

fracData (myData, xx1, xx2) := 
block ([ ccnt : 0 ],
    for j thru length (myData) do
      if myData[j] >= xx1 and myData[j] <= xx2 then ccnt : ccnt + 1,
    float (ccnt/ length (myData)) )$

## confidence (q, m, s)

With q a number in the interval 0 < q < 1, and with m the mean and s the standard 
deviation of a Normal distribution, confidence (q, m, s)  prints out the values dx, m - dx, 
  m + dx, and outputs a list [m - dx, m  + dx] which allows one to have 100*q % 
  confidence a random value of x will lie within that interval, ie., within m +/- dx.

confidence (qq, mm, ss) := 
block ([ddx],
    ddx : 
       float ( (quantile_normal (qq + (1 - qq)/2, mm, ss) - 
                      quantile_normal ( (1 - qq)/2  , mm, ss))/2 ),
    print ( "delx = ", ddx ),
    print ( " x1 = ", mm - ddx, ",  x2 = ", mm + ddx ),
    [mm - ddx, mm + ddx])$

## Basic Concepts in Error Analysis

[HH] Sec. 1.1

"The aim of error analysis is to quantify and record the errors associated with the 
inevitable spread in a set of measurements, and to identify how we may improve the 
experiment. In the physical sciences experiments are often performed in order to 
determine the value of a quantity. However, there will always be an error associated 
with that value due to experimental uncertainties."

"The sources of these uncertainties are discussed later in this chapter. We can never 
be certain what the exact value is, but the errors give us a characteristic range in which 
we believe the correct value lies with a specified likelihood."

[HH] Sec. 1.2.1:

"A precise measurement is one in which the spread σ of the results is 'small', either in 
absolute magnitude or relative to the accepted value."

"An accurate measurement is one in which the results of the experiment agree with 
the accepted value."

"Types of errors:
  1.)   random errors—these influence precision;
  2.)   systematic errors—these influence the accuracy of a result;
  3.)   mistakes—bad data points."

"The signature of random errors in an experiment is that repeated measurements 
are scattered over a range. The smaller the random uncertainty, the smaller the scattered 
range of the data. ...the spread of the data is defined by the standard deviation σ."

"There are two categories of scatter in experiments: (1) technical, and (2) fundamental 
noise."

### Spring-loaded  Projectile Launcher Experiment

We will illustrate the results of an experiment measuring the range of a ball-bearing 
launched from a spring-loaded projectile launcher. Successive  measurements were 
taken of the distance the ball-bearing projectile landed with respect to the launching 
cannon. We show a histogram of the projectile radial range, r =  sqrt (x^2 + y^2),  below. 
The crucial point to note is this: although nominally these repeated measurements are 
performed under exactly the same conditions, and Newton’s laws of motion, which 
govern the trajectory, are time independent, successive repetitions of the experiment 
gave different values for the radial range of the ball-bearing projectile.

The histogram shown  below contains the information about the range of the projectile, 
and the uncertainty in this range.

The Maxima function random_normal (m,s) returns a random variate, with s > 0. m is 
the mean and s the standard deviation. Calling random_normal with a third argument n, 
random_normal (m,s,n), a random sample of size n will be simulated.    

for j thru 5 do print ( [random_normal (15,2), random_normal (7.5, 1.5) ] )$

nsample : 50$

xvals : random_normal (15, 5, nsample)$
fll (xvals);
head (xvals);
tail (xvals);

yvals : random_normal (7.5, 3, nsample)$
fll (yvals);
head (yvals);
tail (yvals);

xyhits : makelist ([ xvals [j], yvals [j] ], j, 1, nsample)$
fll (xyhits);
head (xyhits);
tail (xyhits);

wxdraw2d ( xrange = [-5,30], yrange = [0, 15], color = black,
      title = "ball bearing projectile hits on carbon paper",
       xlabel = " cm downrange from launcher",
       ylabel = "orthogonal to downrange",
        points (xyhits), color = red, key = "launcher",
        point_size = 2,  points ( [ [0, 7.5] ] ), color = blue, key = "",
        line_width = 4,  explicit (7.5, x, -1, 0) )$

radialRange : makelist ( sqrt ( xvals[j]^2 + yvals[j]^2 ), j, 1, nsample)$
fll (radialRange);
head (radialRange);
tail (radialRange);

wxhistogram (radialRange, xlabel = "radial range", ylabel = "ocurrance",
 title = " Radial Range Histogram ", fill_color = black,
 fill_density = 0.5  /* , frequency = density */ , nclasses = 15   )$

If we had included the option frequency = density, we would get automatic normalization 
so the area under the bars would equal unity and the y axis would extend from 0 to 1, 
and we would label the y axis 'probability'. The default number of bins is 10. Using the 
option nclasses = 15, as we did above, throws the data into 15 bins.

wxhistogram (radialRange, xlabel = "radial range", ylabel = "probability",
 title = " Radial Range Histogram ", fill_color = black,
 fill_density = 0.5, frequency = density, nclasses = 15   )$

mm : mean (radialRange);
ss : std (radialRange);

The mean (average) value of the radialRange values is mm  cm and one standard 
deviation is ss  cm. We have used the Maxima functions mean (data) and std (data). 
We have previously used both of these functions in Stat04-Normal.wxmx, in the section
 'Random Sample Size n = 100 Simulations'. The best estimate of the measured quantity
is the mean <x> of the distributed data.

fracData (radialRange, mm - ss, mm  + ss);

The value returned by fracData above is the fraction of the radialRange values which lie 
in the range [mean - std,  mean + std], ie., within one standard deviation of the mean 
value.

## Precision and Accuracy Defined

We either summarize or quote material in [HH], Sec. 1.2.

There is a great difference between saying "this is an accurate measurement of x" or 
saying "this is a precise measurement of x".

A 'precise measurement' means the spread of the experimental values is 'small', either 
small in absolute value or the ratio: σ/<x> is small. The spread of the data is defined by 
the standard deviation σ.

An 'accurate measurement' means that the mean value <x> is in 'agreement' with the 
current accepted value. Obviously, we could not use the word 'accurate' to describe the 
measurement of some quantity whose value is unknown so far, either experimentally 
or theoretically.

1.) An experiment which is both precise and accurate means the spread of the 
measurements is small and the mean of the measurements agrees with the accepted 
value. This is the 'gold standard'.

2.) An experiment which is accurate but not precise means that the mean of the 
measurements agrees with the accepted value, but the spread of the measured values 
is large.

3.) An experiment which is precise but not accurate has a small spread of measurements 
(small random errors) and has some systematic error which causes the mean of the 
measurements to be 'far' from the accepted value.

4.) An experiment which in neither precise nor accurate characterizes a set of 
measurements which have both a large systematic error or errors and well as large 
random errors: the spread of measured values is large and the mean is 'far' from the 
accepted value.

### Systematic Errors

Quoting [HH] in Sec. 1.2.3:

"Systematic errors cause the measured quantity to be shifted away from the accepted, 
or predicted, value. Measurements where this shift is small (relative to the error) are 
described as accurate. For example, for the data from the projectile launcher shown" 
above, " the total range needs to be measured from the initial position of the ball-bearing 
within the launcher. Measuring from the end of the cannon produces a systematic error. 
Systematic errors are reduced by estimating their possible size by considering the 
apparatus being used and observational procedures."

### Mistakes

"Another class of error which defies mathematical analysis is a mistake. These are 
similar in nature to systematic errors, and can be difficult to detect. Writing 2.34 instead 
of 2.43 in a lab book is a mistake, and if not immediately corrected is very difficult to 
compensate for later."

### 20% of measurements incorrectly logged  example

"A histogram of events is shown below, where the automated data-collecting software 
misfired on 20% of the events. Malfunction of the apparatus can be difficult to spot; 
the presence of erroneous points can become apparent when the data are displayed 
graphically."

n1 : 800$
n2 : 200$
nn : n1 + n2$

n1 events are correctly logged.

xv1 : random_normal (15, 2, n1)$
yv1 : random_normal (7.5, 1, n1)$
xy1 : makelist ([ xv1 [j], yv1 [j] ], j, 1, n1)$
fll (xy1);

n2 events are not correctly logged.

xv2 : random_normal (8, 2, n2)$
yv2 : random_normal (7.5, 1, n2)$
xy2 : makelist ([ xv2 [j], yv2 [j] ], j, 1, n2)$
fll (xy2);

We can use the Maxima function join ( list1, list2 ) to 'merge' two lists of the same length.
We can use the Maxima function append (list1, list2) to 'merge' two lists of any length.

L1 : [a, b, c];
L2 : [z, y, x, w, v];
LLjoin : join ( L1, L2 );
LLappend : append ( L1, L2 );

xytotal : append (xy1, xy2)$
fll (xytotal);
head (xytotal);
tail (xytotal);

wxdraw2d ( xrange = [0,30], yrange = [0, 15], color = black,
      title = "20% mistakes",
      xlabel = " x", ylabel = "y",  points (xytotal)  )$

To construct a histogram, we need to create a list from the raw data which is a simple 
list of scalars.This could have the form:  
    rxy : makelist ( sqrt ( xvtot[j]^2 + yvtot[j]^2 ), j, 1, nsample)$

xvtot : append (xv1, xv2)$
fll (xvtot);
yvtot : append (yv1, yv2)$
fll (yvtot);

rxy : makelist ( sqrt ( xvtot[j]^2 + yvtot[j]^2 ), j, 1, nn)$
fll (rxy);

wxhistogram (rxy, xlabel = "rxy", ylabel = "ocurrance",
 title = " 20% mistakes ", fill_color = black,
 fill_density = 0.5  /* , frequency = density */  , nclasses = 30   )$

The bump down near rxy = 11 indicates the possibility of incorrect logging of raw data 
by automatic data logging equipment.

### Other Examples of Mistakes

"There are other well-known types of mistakes which can influence the precision and 
accuracy of experimental results with potentially disastrous consequences. Misreading 
scales occurs often with an analog device which has a 0–10 scale above the gradations, 
and a 0–3 scale underneath. Care has to be taken when using a signal generator where 
an analog dial from 1 to 10 is used in conjunction with multiplier knobs such as 1–10 kHz. 
With an instrument such as an oscilloscope one has to be careful to check whether a 
multiplier such as ×10 has been engaged."

"There are many examples where confusion over units has had disastrous consequences.
In 1999 the failure of the NASA Mars Climate Orbiter was attributed to confusion about 
the value of forces: some computer codes used SI units, whereas others used imperial."

"A Boeing 767 aircraft ran out of fuel mid-flight in 1983; a subsequent investigation 
indicated a misunderstanding between metric and imperial units of volume."

### Rules of Thumb for Precision

We either summarize or quote [HH], Sec. 1.3.

"1.) The precision of a measurement only equals the precision of the measuring device 
               when all repeated measurements are identical.

2.) The highest precision achievable with an analog device such as a ruler is 
         half a division.

3.) The precision of a digital meter is limited to the last decimal point; i.e. one in the 
         last digit."

### Achieving Accurate Measurements

We either summarize or quote [HH], Sec. 1.4.

"The accuracy of an experiment is determined by systematic errors. For the example of 
the projectile launcher, the range is a function of both the launch angle and muzzle speed.
Experimental factors which could affect the accuracy include the setting of the launch 
angle or the reliance on the manufacturer’s specification of the muzzle speed. The 
theoretical prediction, for this example, is based on a calculation which ignores air 
resistance—the validity of this assumption could be questioned."

"Three of the more common sources of systematic error are zero, calibration, and 
     insertion errors. 

1.) An example of a zero error is using a ruler to measure length if the end of the ruler 
              has been worn away. 

2.) An example of a calibration error is using a metal ruler calibrated at 20 deg C for a 
           measurement when the temperature is 10 deg C, ignoring the thermal contraction.

3.)  Examples of insertion errors include: 

    a.) placing a room-temperature thermometer in a hot fluid, which will change the 
             temperature of the hot fluid,
     b.)  the current in an electrical circuit being changed by placing a meter across a 
             component of the circuit."

"In general one should ensure the apparatus used is properly calibrated and zeroed."

## Measurement Errors and the Central Limit Theorem

Quoting from R. J. Barlow, Sec. 4.1 

"When values are quoted with an error, this error is a Gaussian standard deviation σ. 
If you say the length of a piece of string is 12.3 ± 0.1 cm, you mean that you have 
measured it with a ruler (or equivalent device) which gives answers that differ from the 
true value by within 0.1 cm 68% of the time, 0.2 cm 95% of the time, and 0.3 cm 99.7% 
of the time..." 

"This is not just an arbitrary choice. Errors on measurements and results are generally 
well described by the Gaussian [Normal] distribution, which is of course why it is also 
known as the normal distribution."

### Why Errors are Gaussian 

Quoting Bohm, Sec. 4.1

"When we talk about measurement errors, we do not mean mistakes caused by the 
experimenter, but the unavoidable random dispersion of measurements. Therefore, a 
better name would be measurement uncertainties. We will use the terms uncertainty 
and error synonymously."

"The natural sciences owe their success to the possibility to compare quantitative 
hypotheses to experimental facts. However, we are able to check theoretical predictions 
only if we have an idea about the accuracy of the measurements. If this is not the case, 
our measurements are completely useless."

"Of course, we also want to compare the results of different experiments to each other 
and to combine them. Measurement errors must be defined in such a way that this is 
possible without knowing details of the measurement procedure. Only then, important 
parameters, like constants of nature, can be determined more and more accurately and 
possible variations with time, like it was hypothesized for the gravitational constant, can 
be tested."

"Finally, it is indispensable for the utilization of measured data in other scientific or 
engineering applications to know their accuracy and reliability. An overestimated error 
can lead to a waste of resources and, even worse, an underestimated error may lead 
to wrong conclusions."

### Expectation E(F) and Variance V(F) Defined

### E (F)

The expectation E (F),  or < F >, of a function F (x1, x2, ...., xN) is an N dimensional 
integral
      ∫ ∫ ... ∫ F (x1, x2, ...,xN) * P( x1, x2, ..., xN) dx1 dx2 ... dxN
with integration over the whole domain of the variables x1, x2, ..., xN, usually
minus infinity (minf) to positive infinity (inf).
P( x1, x2, ..., xN) dx1 dx2 ... dxN is the joint probability that x1 will be found in the 
interval  [x1, x1 + dx1], x2 will be found in the interval  [x2, x2 + dx2], ..., 
xN will be found in the interval  [xN, xN + dxN]. The joint probability P has the
normalization
    ∫ ∫ ... ∫  P( x1, x2, ..., xN) dx1 dx2 ... dxN  =  1.

The random variables x1, x2, ...,xN are independent if and only if P factors:
   P( x1, x2, ..., xN) = P1 (x1)*P2 (x2) * ..... * PN (xN).
Then we require the normalization conditions:
    ∫ P1 (x1) dx1 =  ∫ P2 (x2) dx2 = ... =  ∫ PN (xN) dxN =  1.

### V (F)

The variance of some function F (x1, x2, ..., xN) is denoted V (F) and defined by
          V (F)  =  E (  [ F  -  E (F) ]^2  )
which, in words, is the expectation of the square of the difference between
F and the expectation of F.

### σ (F)

The standard deviation σ is the square root of the variance.

### E(a1 x1 + a2 x2) = a1 E (x1) + a2 E (x2)

Let's show that  any linear combination of the x_i, such as

               X =  ∑ a_i  x_i,  with  i in [1, N],  satisfies:

              E(X) = <X> = mean of X = ∑ a_i   E (x_i ), 

that is, the mean of X is the same linear combination of the means of the x_i.

Working through the case N = 2 will make clear the generality of the result, which doesn't
depend on the factorization of P (x1, x2) (ie., doesn't depend on x1 and x2 being 
independent  random variables).

The mean of a general function of x1 and x2, F(x1, x2) is defined as (if x1 and x2 are 
real variables; we will assume they can take values between minus infinity ("minf") and
positive infinity ("inf"). 

   E( F (x1, x2) ) =  ∫  ∫  F (x1, x2)  P (x1, x2)  dx1 dx2,

where P (x1, x2) is the joint probability that x1 and x2 have particular values, with the
normalization requirement:
               ∫  ∫ P (x1, x2)  dx1 dx2  =  1. 

The expectation values for x1 and x2 are (in general):
               E (x1)  =  ∫  ∫ x1 P (x1, x2)  dx1 dx2,

               E (x2)  =  ∫  ∫ x2 P (x1, x2)  dx1 dx2.

Now assume F (x1, x2) is a linear function of independent variables x1 and x2:
      F (x1, x2) = a1 x1 + a2 x2, with a1 and a2  independent of x1 and x2. Then:

E (a1 x1 + a2 x2) = ∫  ∫  (a1 x1 + a2 x2)  P (x1, x2)  dx1 dx2,
                            = a1  ∫  ∫  x1 P (x1, x2)  dx1 dx2 +  a2  ∫  ∫  x2 P (x1, x2) dx1 dx2
                            =   =  a1*E(x1) + a2*E(x2).  QED.             
In the general case, 
                   E(  ∑ a_i  x_i   ) = ∑ a_i   E( x_i ). 

### V (a1 x1 + a2 x2) = (a1)² V (x1) + (a2)² V (x2)

In a similar manner one can prove (James, p. 28, Eq. (2.32) ) the relation between the 
variances is (with x1 and x2 independent variables, a1 and a2 constants):

  V (a1 x1 + a2 x2) = (a1)² V (x1) + (a2)² V (x2), and generalizing to arbitrary N,
                 V ( ∑ a_i   x_i  ) = ∑ (a_i)²  V (x_i) .

The above relations hold even if the independent variables x_i are each described by 
completely different probability distributions P_i (x_i).

We prove this for the case N = 2.

With F = a1 x1 + a2 x2,   V(F) = E ( [F - E(F) ]^2 ) by definition.

    E (F) = a1 E(x1) + a2 E(x2) = a1 μ1 + a2 μ2.

        F - E(F) = a1 (x1 - μ1) + a2 (x2 - μ2).

      [F -  E (F)]² = (a1)²  (x1 - μ1)² +  (a2)²  (x2 - μ2)² + 2 a1 a2 (x1 - μ1) (x2 - μ2).

E ( [F -  E (F)]² ) = (a1)²  E ( (x1 - μ1)² ) + (a2)²  E ( (x2 - μ2)² )   
                                       +  2 a1 a2  E ( (x1 - μ1)*(x2 - μ2) ).

The first two terms on the rhs are:
        (a1)²  V (x1) + (a2)²  V (x2).

In the third term, because x1 and x2 are independent random variables, 
    P(x1,x2) = P1(x1) P2(x2), and the third term is proportional to:

E [ (x1 - μ1)  (x2 - μ2) ] =  ∫  ∫  (x1-μ1) (x2-μ2)  P (x1, x2)  dx1 dx2,
                                     =  ∫  ∫  (x1-μ1) (x2-μ2)  P1(x1) P2(x2)  dx1 dx2
                                     =  ∫ (x1 - μ1) P1(x1) dx1   ∫  (x2 - μ2) P2(x2) dx2
                                     = [ ∫ x1 P1(x1) dx1  - μ1 ]  [ ∫ x2 P2(x2) dx2   - μ2 ]
                                     =  (μ1 - μ1)  (μ2 - μ2) = 0.
       
Thus V (a1 x1 + a2 x2) = (a1)² * V(x1) + (a2)²  V(x2), which can be generalized to 
arbitrary values of N.

### Central Limit Theorem (CLT)

Quoting from R. J. Barlow, Sec. 4.1 

"Measurements acquire errors from many different sources. If you measure the length 
of a rod using a ruler, all sorts of inexactitudes creep in: optical parallax, the ruler’s 
calibration, rounding errors, your hand shaking, and so on. Reading a meter with a 
moving pointer has similar problems. Digital meters and electronic readout avoid the 
effects of shaky hands and bleary eyes, but at the expense of others, hidden in the 
depths of the electronics. The imperfections in the measurements we make are not due 
to one cause, but to many."

"Now, there is a powerful and surprising result about the behaviour of a variable which 
is the sum of several others. It is called the central limit theorem or CLT for short."

"The central limit theorem:

If you take X = ∑ x_i, where i = 1,2,3,…,N,  with each x_i a measurement of some 
property x taken from a distribution of mean μ_i and variance V_i = (σ_i)^2,  then the 
distribution for X:

    (a) has an expectation value
                E(X) =  <X> =  ∑ μ_i / N                                             (4.1)

    (b)  has a variance
               V(X) = ∑ V_i  / N  ==  ∑ (σ_i)^2 / N                            (4.2)

     (c)  becomes Gaussian as N approaches infinity.                 (4.3)  "

"This is why the Gaussian is so important. A quantity produced by the cumulative effect 
of many independent variables will be, at least approximately, Gaussian, no matter what 
the distributions of the original variables may have been. Measurement errors behave 
accordingly, as do many other observed quantities. For example, human heights are well 
described by a Gaussian distribution, as are the lengths of the arm, forefinger, and other 
anatomical measurements, as these are due to the combined effects of many genetic 
and environmental factors."

### Justification of the Central Limit Theorem

Suppose you take N measurements, each done under the same conditions, and conclude
your "best" value is the arithmetic average of the N values, call it x_av. (In texts this 
usually is denoted by x with an overline, or "x-bar"). If you then repeat the whole process 
with another N measurements, you will, in general, get a somewhat different value for 
x_av, so x_av itself will have some distribution of values, with a mean <x_av> and its 
own variance V (x_av) == (s_av)^2.

Now with x_i standing for the i'th measurement of property x, out of a total of N 
measurements in a given experiment, let:

   x_av = ∑ x_i / N = average of N measurements.

If the same experiment, with N measurements of property x carried out with the same 
experimental conditions, the value of x_av will, in general, be slightly different. What can 
we say about the average of the set of x_av's?  Let <x_av> designate the average 
of the set of x_av's.

Using our relations for a linear combination of random variables x_i,

  <x_av> =  E( x_av ) = ∑  E (x_i) / N

If we assume  that E (x_i) ~ μ for all i, we get
         <x_av> =  E (x_av)  ~ ∑ μ / N =  (N μ) / N = μ.

"x_av is subject to random statistical fluctations, but on average its value is μ. The 
difference between your actual measured x_av's and the 'true' value μ is described by 
some distribution which has variance V(x_av)  = (s²  / N ) [in which s is approximately 
one standard deviation (the uncertainty) of each measurement], as we show below."

Next consider the variance of x_av and use our relation for the variance of a linear 
combination of variables and also our assumption that each of the N measurements of x 
in each experiment are independent (the result of one careful measurement has no 
influence on a second careful measurement).

V (x_av) = V ( ∑ x_i / N ) = V ( ∑ ( x_i  / N )  ) =  ( ∑  V (x_i) )  / N², in which we have 
used the  variance of a linear combination of random variables relation proved above, 
namely that  V ( a1*x1 + a2*x2 + ... + an*xn) = a1^2*V(x1) + a2^2*V(x2) + ... + an^2*V(xn),
in a situation in which a1 = (1/N), a2 = (1/N), etc., so every term here has a (1/N)^2 
coefficient which can be factored out of the sum.

If we assume that the V (x_i) all have the same value s^2 [since each measurement has 
the same uncertainty and hence the same s, we get

V (x_av) =  ( ∑ s^2 ) / N² = (N*s²) / N²  = s² / N  == s_av² , as asserted above.

Taking the square root:
      s_av = s / √ N  = s / N^(1/2).

The spread of the distribution of values of the x_av's will be smaller than s, depending on 
the size of N. (Averaging is good for you. More measurements are better than fewer.)

"It is also an example of the law of diminishing returns: to get twice as good a resolution 
you need four times as many measurements."

  Now s_av_4N = s/sqrt (4*N) =   [s/sqrt (N)] / 2 =  s_av_N / 2.

  Thus  'twice as good a resolution'  means getting an  s_av value one half the size 
   and this requires four times as many measurements.

"s_av/sqrt (N) is called the 'standard error of the mean', as it describes how well 
you know the mean of a distribution, which is often a very important quantity."

Common symbols are: SE, SEM, σM, σE. a statistic that indicates how much the 
average value (mean) for a particular sample is likely to differ from the average value 
for the larger population from which it is drawn. 

### Photon Decays

Continuing with Barlow's examples:

"Example: Photon energy measurements The energy resolution of a γ-ray detector used 
to investigate a decaying nuclear isotope is 50 keV. If only one such decay is observed, 
its energy is known to 50 keV. If 100 are collected, this improves to 5 keV. To reach 
1 keV you would need to observe 2500 decays."

In this example, the uncertainty of an individual measurement is s = 50 keV (50 kiloVolts).
If this measurement produces a value E = ( 300 +/- 50 ) keV based on one decay, we 
expect that averaging 100 measurements (with the identical equipment and setup) will 
produce an answer with an uncertainty of about 50/10 = 5 keV. Averaging 2500 
measurements will produce an answer with an uncertainty of about 50 / 50 = 1 keV.

### Weights of Eggs

"Example Weights of eggs The weights of eggs produced by a farmer’s hens have a 
standard deviation of 10 g. He feeds a group of hens an expensive vitamin supplement, 
which will pay back its costs if it increases the weight of the eggs by 2 g. He measures 
25 eggs from vitamin-fed hens and their average has increased by 3 g. 
Does this prove anything useful?"

"No. The standard error on the mean is s/√N = 10/√25 = 2 g, so the increase [in weight] 
is  only 1.5 s_av and is not really significant."

"Notice the subtle difference in this example, in that the variation in the egg weights 
comes from the spread in the objects themselves, not from the measurement 
process; it is assumed that the eggs can be weighed with complete accuracy, or 
at any rate an accuracy much better than 10 g, which is probably true."

Chicken eggs vary in weight from about 60 g to 70 g, depending on the age of the
chicken.