# Uncertainties02B.wxmx

## Preface

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

Edwin L. (Ted) Woollett
https://home.csulb.edu/~woollett/
July 30, 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

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)) )$

## fracDataLessThan (data, maxval)

fracDataLessThan (myData,maxval) :=
block ([ ccnt : 0 ],
    for j thru length (myData) do
      if myData[j] <= maxval then ccnt : ccnt + 1,
    float (ccnt/ length (myData)) )$

## sigE (List)

sigE (data) returns the standard deviation of the mean (SDOM), σE of a data set.

sigE(data) := float ( std1 (data) / sqrt (length (data) ) )$

## 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,"  =  ", sconcat (ddx/ss," * σ" ) ),
    print ( " x1 = ", mm - ddx, ",  x2 = ", mm + ddx ),
    [mm - ddx, mm + ddx] )$

## The Standard Error of the Mean σE, SDOM

We repeat the definition of the standard error of the mean presented in the previous
worksheet, based on [HH] Sec. 2.7. The 'standard error of the mean' is also called
the 'statistical error on the mean'; see Lyons, Sec. 1.5. Fred Senese, Sec. 8.3.1, uses
the symbol sE for the standard errror of the mean. [HH] use the symbol δ (Greek delta).

"The width of the histogram of means is a measure of the precision of the mean. It is 
clearly evident from the above plots that the width of the histogram of the means 
decreases as the size of the sample used to calculate the mean increases—this is a 
consequence of averaging over statistical fluctuations." 

"The width of the histogram of means is the standard deviation of the mean, also known 
as the standard error, σE."

"When the number of measurements involved in calculating the mean increases, the 
means are better defined; consequently the histograms of the distributions of the means 
are narrower. Note that the precision with which the mean can be determined is related 
to the number of measurements used to calculate the mean."

"In practice one does not generate histograms of the means based on trials containing 
many measurements; rather one uses all N measurements x_i to calculate one value 
for the mean <x>. We expect the standard error (the standard deviation of the mean), 
σE, to decrease as the number of data points we collect, N, increases."

It can be shown "that the standard error is reduced by a factor of √N with respect to the
sample standard deviation:"

                σE = σ_sample / N^½

"A data set containing N multiple readings yields one value of the mean. Thus we should 
quote our findings as the mean ± the error on the mean, i.e."

              <x> +/- σE  ==  <x> +/-  σ_sample / N^½

"In other words, we are saying that there is a two-thirds chance that the measured 
parameter is within the range [ <x> - σE , <x> + σE ]."

"One can interpret the standard error as being a standard deviation, not of the 
measurements, but rather the mean: this is why the standard error σE  is also called the 
standard deviation of the mean (SDOM)."

## The Error in the Error

[HH] Sec. 2.7.1

"There exists a formula for the fractional error in the error (Squires 2001, Appendix B); 
it is defined as

  (fractional) error in the error =   1 / √ (2*N - 2),

and is a slowly decreasing function of N."

mypts : makelist ( [N, float (1 / sqrt (2*N - 2) ) ], N, [5, 50, 5000] );

With N = 5 points, the fractional error in the error estimate is 0.35, with N = 50 points
the fractional error in the error estimate is 0.1, with N = 5000 points, 0.01.

wxdraw2d ( xrange = [-500, 6000], logy = true,  color = black, 
    xlabel = "Number of Measurements N",
    ylabel = "Fractional Error in the Error",
    points (mypts), color = blue,  explicit (1/sqrt(2*N-2), N, 4, 6e3)  )$

"It should be noted that the error on the error is a slowly decreasing function with 
respect to N. For example, with only five measurements the error estimate is only 
good to about 1 part in 3 (35%). As the sample size N increases, the error in the error 
decreases, and we can be more confident in our results, allowing for more significant 
figures to be quoted. Note that the error in the error does not fall to a few percent 
(allowing two significant figures to be quoted meaningfully) until approximately 
10,000 data points have been collected (see Exercise 2.4)."

"Conversely, care should be taken when choosing the number of appropriate significant 
figures [of the error] if the first significant figure of the error is 1 — rounding an error 
of 1.4 to 1, or 1.51 to 2 causes a change in the error of approximately 25%. "

"The following rule is generally adopted:

        Quote the error to one significant figure.

 Corollary:
   (i) If you have collected approximately 10,000 data points, or more, consider quoting 
              the error to two significant figures;
   (ii) if the first significant figure of the error is 1, consider quoting the second significant
             figure."

"Worked example:

Analysis of repeated measurements of the acceleration due to gravity, g, yields 
   <g> =  9.812 3456 m s^(−2), with σE = 0.032 1987 m s^(−2).
** If this answer was based on 10 measurements, you would report
            g = (9.81 +/- 0.03) m s^(-2).
** If this answer was based on 7,500 measurements you would consider reporting
            g = ((9.812 +/- 0.032) m s^(-2).

If another measurement technique has results which are 
      <g> = 9.817 654 m s^(−2) with σE = 0.101 23 m s^(−2), then
** If this answer was based on 10 measurements, you would report
           g = (9.8 ± 0.1) m s^(−2);
** if this answer was based on 500 measurements, you would consider reporting 
          g = (9.82 ± 0.10) m s^(−2)."

"Note that it is extremely rare to quote errors to three significant figures or higher.  As 
we saw earlier, even the currently accepted values for the fundamental constants have 
their errors quoted only to two significant figures. Note also that there is no rule about 
how many significant figures are included in the mean—this is ascertained after the error 
(and its error) are evaluated. The value of the acceleration due to gravity deduced in the 
worked example after 7500 measurements has an error known to two significant figures, 
and a mean known to four significant figures, whereas Avogadro’s number has an error 
known to two significant figures, and a mean known to nine significant figures."

"From the preceding section, we can formulate the following procedures to be
considered when we quote our results:

(1) Analyze the experimental data and calculate the mean; keep all significant figures 
          at this stage.
(2) Calculate the standard error σE (the error in the mean); keep all significant
        figures at this stage.
(3) Think about how many significant figures should be retained for the error σE having 
           reflected on the number of data points collected.
(4) Round the mean to the appropriate decimal place."

### Ten Measurements of the Period of a Pendulum

[HH] Sec. 2.3.1: Measurement of the period of a pendulum expressed in seconds.
"Rough-and-ready approach to estimating the width"

Ten measurements of the period of a pendulum (in sec.) were made, with the raw
data being:

trial : cons ("Trial", makelist (j,j,1,10) );

data : [10.0, 9.4, 9.8, 9.6, 10.5, 9.8, 10.3, 10.2, 10.4, 9.3];

matrix (trial, cons ("Period", data) );

Lsum (data) / length (data);

"Rough-and-ready approach to estimating the width"

"All data points lie within the interval 9.3 ≤ T ≤ 10.5 s which covers a range of 1.2 s, 
or a spread around the mean (<T> = 9.9 s) of about ±0.6 s. Evaluating the maximum 
spread of the data is one rough-and-ready approach to estimating the precision of the 
measurement. It is somewhat pessimistic, because as we will see later, we generally 
take the precision in a measurement to be two-thirds of the maximum spread of values, 
and therefore the spread of the data is approximately ±0.4 s. The factor of two thirds 
is justified for a Gaussian distribution. Note that the spread of the measurements is 
significantly worse than the precision of the measuring instrument—this is why taking 
repeat measurements is important."
"We can therefore say that:
    * a typical measurement of the period is likely to be within 0.4 seconds of
           the mean value;
   * the precision of the measurements is 0.4 seconds."

With the Maxima tools we calculate the mean, sample standard deviation, and
the standard error of the mean σE.

m : mean (data);
σ_sample : std1 (data);

σE : σ_sample/ sqrt (length (data) ), numer;

sigE (data);

"As the analysis is based on so few data points only the first significant figure of the 
standard error of the mean is retained; the result is reported as T = (9.9 ± 0.1) s"

### HH Exer. 2.4

Recall the advice given above about choosing the number of significant figures of the
standard error σE to report.

"Conversely, care should be taken when choosing the number of appropriate significant 
figures [of the error] if the first significant figure of the error is 1 — rounding an error 
of 1.4 to 1, or 1.51 to 2 causes a change in the error of approximately 25%. "

"The following rule is generally adopted:

        Quote the error to one significant figure.

 Corollary:
   (i) If you have collected approximately 10,000 data points, or more, consider quoting 
              the error to two significant figures;
   (ii) if the first significant figure of the error is 1, consider quoting the second significant
             figure."

"Consider a set of measurements with the standard error calculated to be 
σE = 0.987 654 321. Here we address the question of how many significant figures 
should be quoted. Construct a spreadsheet with four columns. The first column should 
be N, the number of measurements on which σE is based. In the second column write 
σE to the nine significant figures quoted above. The third column should be
σE* ( 1 - 1/sqrt (2*N - 2) ), and the fourth column should be σE* ( 1 + 1/sqrt (2*N - 2) )."

"As we are interested in the variation over a large dynamic range, choose values for N 
such as 2, 3, 5, 10, 20, 30, etc. Verify the statement above that the number of data
points, N, needs to approach a few tens of thousands before the second significant 
figure in the error can be quoted, i.e. when the values in the three columns become
equal to the second significant figure. REPEAT the analysis for the case where 
σE = 0.123 456 789, i.e. the first significant digit of the error is 1. How many data points
must be collected before the third significant figure can be quoted?"

In the first case the first significant digit of the standard error is 9.

σE : 0.987654321$
f (N) := print (N, σE, σE* float ( (1 - 1/sqrt (2*N - 2)) ), 
                σE* float ((1 + 1/sqrt (2*N - 2)) ) )$

fpprintprec : 2$

for n in [10,20,100, 200,1000,5000,10000,20000,30000,50000,
  70000] do f(n)$

For N = 70,000 data points and when restricting the printed values to two significant
figures, we finally have the three columns having the same value, and we can report
the standard error of the mean as (after rounding) 0.99.

REPEAT the analysis for the case where σE = 0.123 456 789, i.e. the first significant 
digit of the error is 1. How many data points must be collected before the third significant 
figure can be quoted?"

σE : 0.123456789$

fpprintprec : 3$

for n in [10,20,100, 200,1000,5000,10000,20000] do f(n)$

We see that with 10,000 data points, the three columns agree and we can quote
σE = 0.123 to three significant figures.

## Rounding and Significant Figures

[HH] Sec. 2.8.1

"RULE OF THUMB: If an error is not quoted assume that the uncertainty is in the last
reported digit."

"The theme of this chapter has been that all measurements are subject to uncertainty. 
A working rule is that, in the absence of an error being quoted, we assume that a number 
has significance equal to a single unit in the last figure quoted."

"Thus if we were to say that the resistance of a resistor was 97 Ω, it is said to have 
an absolute uncertainty of 1Ω and is said to be known to two significant figures. A 
resistor with a value of 100.04 Ω indicates an absolute uncertainty of 0.01 Ω and is
said to be known to five significant figures. Confusion can occur in ascertaining how 
many significant figures a number has when zeroes are involved."

"Rules for identifying significant digits"

"    * All non-zero digits are significant:
                  2.998 × 10^8 m s−1 has four significant figures.
    * All zeroes between non-zero digits are significant:
                 6.022 141 79 × 10^23 mol−1 has nine significant figures.
     * Zeroes to the left of the first non-zero digits are not significant: 
                0.51 MeV has two significant figures.
      * Zeroes at the end of a number to the right of the decimal point are significant: 
               1.60 × 10−19 C has three significant figures.
      * If a number ends in zeroes without a decimal point, the zeroes might be significant: 
                 270  might have two or three significant figures."

RULE OF THUMB: To avoid confusion when numbers end in zeros, report your values 
using scientific notation.

"The ambiguity in the last rule to use if a number ends in zeroes can be resolved by 
the use of scientific notation. For example, depending on whether two or three 
significant figures is appropriate, we could write 270 Ω as 0.27 kΩ, or 2.7 × 10^2 Ω, 
both of which have two significant figures; or 0.270 kΩ  , or 2.70 × 10^2 Ω, both of 
which have three significant figures. Note that the entries 0.3 kΩ  and 300 Ω in a 
lab book carry very different significance."

"Significant figures must also be considered when carrying out calculations. It is 
important to carry all digits through to the final result before rounding to avoid rounding 
errors which compromise the accuracy of the final result. The principle is the following:
the precision of a calculated result is limited by the least precise measurement in the 
calculation."

### Rounding Rules

"Decide which is the last digit to keep, then:

** Leave the last digit unchanged if the next digit is 4 or lower: 6.62×10^4
        becomes 6.6×10^4 if only two significant figures are appropriate.
** Increase the last digit by 1 if the next digit is 6 or higher: 5.67×10^8
       becomes 5.7×10^8 if only two significant figures are appropriate.

If the digit after the last one to be retained is 5 the recommended procedure
    is to choose the even round value:
** Leave the last digit unchanged if it is even. For example: 3.45 becomes
            3.4 if only two significant figures are appropriate.
** Increase the last digit by 1 if it is odd. For example: 3.55 becomes 3.6 if
                only two significant figures are appropriate.

This 'round-to-even method' avoids bias in rounding, because half of the time we round
up, and half of the time we round down."

"In addition and subtraction, the result is rounded off to the same number of decimal 
places as the number with the least number of decimal places. For example, 
1.23 + 45.6 should be quoted as 46.8. This reflects the fact that we
do not know whether the 45.6 is 45.56 or 45.64 to the next decimal place."

"In multiplication and division, the answer should be given to the same number 
of significant figures as the component with the least number of significant figures. 
For example, 1.2 × 345.6 is evaluated as 414.72 but quoted as 4.1 × 10^2 on account 
of the least precise value having only two significant figures."

"It is important to carry all significant figures through long calculations to avoid 
unnecessary rounding errors. Rounding to the appropriate precision should only 
be done at the end of the calculation."

## Uncertainties as Probabilities

We follow [HH], Ch. 3.

[HH] Sec 3.2.2

"A box contains 100 Ω resistors which are said to have a standard deviation of 2 Ω. 
   1.) What is the probability of selecting a resistor with a value of 95 Ω  or less? 
   2.) What is the probability of finding a resistor in the range 99 to 101 Ω?"

We can assume the box contains resistors which are certified by the factory
to have <R> = 100 Ω and σE = 2 Ω = standard deviation of the mean. Since the
value of the resistance R can take on a continuum of values, the Gaussian (Normal)
distribution is the appropriate distribution for error analysis. Since there is no information
of the size of the sample used by the manufacturer to determine the SDOM σE, we cannot
tell what the sample standard deviation σ_sample = std1(sample) was.

As we know from Stat04-Normal.wxmx, we can use the Maxima function
pdf_normal (x, <x>, σ). The Maxima function pdf_normal (x, μ, σ) returns a symbolic 
value for the value of the Normal (μ, σ) probability distribution at position x. μ is the 
mean = <x> = E(x) = 100 Ω, σ is the standard deviation of the mean, which we take
here as σE = σ_sample/sqrt(N), in which σ_sample = sqrt ( (N - 1)^(-1)*Σ (x_i  - <x>)^2 ),
which is computed using the Maxima function std1 for a given data set. In particular,
here σE is given as 2 Ω.

As was discussed in Stat04-Normal.wxmx,

Roughly 68% of the area under the Normal (μ, σ) curve lies in the region [μ - σ, μ + σ],
 ie., μ - σ <= x <= μ + σ. 

Roughly 95% of the area under the Normal (μ, σ) curve lies in the region [μ - 2 σ, μ + 2 σ],
 ie., (μ - 2 σ) <= x <= (μ + 2 σ).

Roughly 99.7% of the area under the Normal (μ, σ) curve lies in the region [μ - 3 σ, μ + 3 σ],
 ie., (μ - 3 σ) <= x <= (μ + 3 σ).

The probability of selecting a resistor with a value of 95 Ω  or less is the integral of
pdf_normal (x, 100, 2) from x = - infinity to x = 95, for which we can use the 'cumulative
distribution function' cdf_normal (xfinal, <x>, σ).

cdf_normal (x1, μ, σ) gives the probability that the value of x measured lies in
the interval [- ∞, x1], given that the values measured are described by the normal 
distribution with mean μ and standard deviation σ.

cdf_normal (95, 100, 2), numer;

cdf_normal returns a probability which is always a real number greater than or equal
to zero and less than or equal to one. 0 <= p <= 1. Multiplying the probability by 100
gives the chance or liklihood of finding that a randomly chosen resistor will have a
resistance of less than or equal to 95 Ω. Here that chance is about 0.6%.

The longer path to this answer is to directly integrate pdf_normal:

integrate (pdf_normal (x, 100, 2), x, minf, 95);

float (%);

The probability of finding a randomly chosen resistor in the range 99 to 101 Ω can be 
found by summing (integrating) over the probabilities P(x) dx of finding x in [x, x+dx]
starting at x = 99, ending at x = 101, with x taking a continuum of floating point values.

float ( integrate (pdf_normal (x, 100, 2), x, 99, 101) );

or we could use cdf_normal (why does this work?):

cdf_normal (101, 100, 2) - cdf_normal (99, 100, 2), numer;

The chance of finding a randomly chosen resistor from the box to have a resistance
in the range [99 Ω, 101 Ω] is about 38%.

The area under the curve of Normal (100, 2) with x in the range [99, 101] gives the
probability 0.383. We can show this using wxdraw2d.

pdf_normal (100, 100, 2), numer;

wxdraw2d (xrange = [90, 108], yrange = [0, 0.21], 
    xlabel = "x", ylabel = "probability", grid = true,
    title = " μ = 100,  σ = 2,  pdf normal (x, 100, 2) - red  ", 
    color = red, line_width = 2,  explicit (pdf_normal (x, 100, 2), x, 90, 108), 
    filled_func = true, fill_color = dark_gray,  key = " 99 - 101 ",
    explicit ( pdf_normal (x, 100, 2), x, 99, 101),
    color = black, line_width = 1.5, key = "",
    parametric (99,yy,yy,0, pdf_normal(99, 100, 2) ),
     parametric (101,yy,yy,0, pdf_normal(101, 100, 2) ), line_width = 1,
    color = blue, parametric (100,yy,yy,0, pdf_normal(100, 100, 2) ) )$

3*σ = 3*2 = 6. Notice for x < 92 and x > 106 there is negligible area (probability)
under the curve.

## Confidence Intervals

The Maxima function confidence (q, m, s) is defined at the top of this worksheet.
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.

fpprintprec;

Approximately 68% confidence that x will be found in range 100 +/- 1*σ;
" we are confident, at the 68% level, that, were we to take another measurement, 
the value would lie within one standard deviation of the mean."

confidence (0.68, 100, 2)$

confidence (0.683, 100, 2)$

About 90% confidence that x will be found in range 100 +/- 1.65*σ

confidence (0.90, 100, 2)$

confidence (0.902, 100, 2)$

confidence (0.95, 100, 2)$

1.96 approx = 2.0, so approximately 95% confidence that x will be found in the range
100 +/- 2σ.

confidence (0.955, 100, 2)$

confidence (0.99, 100, 2)$

confidence (0.997, 100, 2)$

confidence (0.9973, 100, 2)$

Approximate Confidence Summary Table

matrix (
    ["Centered on mean", "+/- σ", "+/- 1.65 σ", "+/- 2σ","+/- 2.58 σ","+/- 3σ"],
    ["Measurements within range", "68%"," 90%", "95%","99%","99.7%"],
    ["Measurements outside range", "32%", "10%", "5%", "1.0%", "0.3%"],
    [" ", "1 in 3", "1 in 10", "1 in 20"," 1 in 100", "1 in 400"] ); 

"Recalling the interpretation of the standard error as a standard deviation of the mean 
we can also calculate other confidence intervals. Whereas often in the physical sciences 
the error bar is taken as one standard deviation of the mean (the standard error), other 
conventions exist; in other disciplines the 95% confidence limit is often used." 

We have shown above "that 95.0% of the measurements lie within the range ±1.96σ. 
Therefore if a data set of N measurements has a mean <x> and standard deviation 
σ_sample == σ_(N−1), we would report the result at the 95% confidence limit as"
        <x> +/- 1.96*σE == <x> +/- 1.96*σ_(N-1)/√N

"When σ_(N−1) is ascertained from experimental data, especially from a small number
of repeat measurements, greater care is needed with confidence limits." Later we will 
discuss the 'Student’s t distribution', which is more appropriate for confidence interval 
estimation from a small number of data points."

### random_normal (μ, σ),   random_normal (μ, σ, n)

The Maxima function random_normal (m, s) returns a Normal (m, s) random variate.
The parameter m is the requested average (mean) value of the distribution.
The parameter s is the requested standard deviation of the distribution.

The Maxima function random_normal (m, s, n) returns a list of n random Normal (m, s) 
variates, where m is the average ( mean) of the distribution and s is one standard 
deviation.

For example, here is a list of 10 normally distributed floating point (real) numbers
taken from a Gaussian distribution whose mean is 100 and standard deviation is 2.

fpprintprec : 3$
rsample : random_normal (100, 2, 10);

We simulate a sample consisting of 1,000 resistors randomly chosen. We avoid printing
out the entire list of 1,000 values by ending the command with the dollar sign ($).
We can then use our  homemade functions (defined at the top of the worksheet) fll,
head, and tail.

rsample : random_normal (100, 2, 1000)$
fll (rsample);
head (rsample);
tail (rsample);

Each time you run this command, you will (in general) get a different set of 1,000 resistor
values. For this particular run we calculate the data list values. Of course the number of
values will always be 1,000, but the mean and the value of one standard deviation will in
general be different.

num : length (rsample);
m : mean (rsample);
s : std1 (rsample);

Our Maxima function fracData (alist, a, b), defined at the top of this worksheet, 
calculates the fraction of the list numbers which lie in the interval [a, b].

For this sample to be faithful to a Gaussian (normal) distribution, about 68% of the 
data values should be in the range [<x> - σ, <x> + σ] = [98, 102].

The fraction of the sample within +/- σ of the mean (theor: 0.68):

fracData (rsample, 98, 102);

The sample fraction in range 99 ohms - 101 ohms (theory: 0.38).

fracData (rsample, 99, 101);

The sample fraction with R <= 95 ohms (theory: 0.006).

fracDataLessThan (rsample, 95);

The comparisons between the sample and theory would be closer if we used 
a simulation using 10,000 or 100,000 random_normal values.

As we did in Stat04-Normal.wxmx, we plot a histogram using rsample, choosing to throw 
the raw data into 20 bins. We show a plot of pdf_normal (x, 100, 2) in red also.

wxdraw2d( xrange = [94, 106], xlabel = "R",
    title = " random normal (100, 2, 1000), pdf normal (x, 100, 2) - red ",    
  histogram_description (rsample, nclasses = 20, frequency = density,
        fill_color = black, fill_density = 0.5), color = red,    
 explicit(pdf_normal (x, 100, 2), x, 94, 106)  )$

## Comparisons: Experiment vs. Accepted Value

Reference: [HH] 3.3.4

1.)  If your experimental result and the accepted value differ by up to one standard error,
             they are 'in excellent agreement.'

2.)  If your experimental result and the accepted value differ by between one and two 
         standard errors, they are 'in reasonable agreement.'

3.)  If your experimental result and the accepted value differ by more than three standard 
             errors, they are 'in disagreement.'