Basic Statistics Concepts
for Empirical Science Workshop

January 29 2006
Jim Mahoney

Some notes on basic ideas in statistics, particularly random errors and how results are reported in scientific journals.

the Mean

First, just to have some numbers to work with, suppose we pick a number at random from 0 to 100, assuming each has the same probability.  Doing this N=20 times might give the following numbers and histogram.

minNumber  =  0;
maxNumber  =  100;
howMany  =  20;
x  =  
      Table[Random[
          Integer, {minNumber, 
            maxNumber}], {howMany}]
<< Graphics`Graphics`;
Histogram[x];

The graph shows how many times we got a number in a certain range.

I'll call the individual numbers (Subscript[x, i]).  In other words, (Subscript[x, 1]) = 97, (Subscript[x, 2]) = 75, and so on.

The mean, or arithmetic average, of these number is their sum divided by how many you have.  Intuitively the mean describes the center of the numbers.  (However, be aware that there are other measures of the center, especially the "median".)

Using the "Σ" symbol to mean "sum", or "add 'em all up", and "N" for "howMany", the formula for the mean is

mean(x) = m = <x> =  \(x\&_\)  = ((Σ (Subscript[x, i]))/N)

In this case,

N[Mean[x]]

You can do this calculation with any tool you like: a handheld calculator, an online data analysis tool, Excel, Mathematica, or whatever.

the Standard Deviation

The standard deviation, usually indicated by the symbol σ (sigma) or just the letter "s", describes how far the numbers are from the mean.

Without going into the reasons why here, the formulas look like this :

\(TraditionalForm\`standard_deviation \((x)\)\  = \(σ\  = \ \(\@\(mean(\ \((x\_i - m)\)\^2)\)\  = \@\(mean(x\_i\^2)\  - \ m\^2\)\)\)\)
\(TraditionalForm\`			\ \ \(\(=\)\(\ \)\(\@\(\(Σ\ \((x\_\(\(i\)\(\ \)\) - m)\)\^2\)\/N\)\  = \ \@\(\(Σ\ \((x\_i)\)\^2\)\/N - \((\(Σ\ x\_i\)\/N)\)\^2\)\)\)\)

For the numbers up above,

<< 
        Statistics`DescriptiveStatistics`;

    N[StandardDeviationMLE[x]]

One particularly confusing thing about the formula for standard deviation is that there are actually two versions, one with an N in the denominator, and one with N - 1.  Most of the time (that is, as long as N isn't too small) the difference won't matter.  Different calculators use different conventions as to which of these they compute, so you'll need to read the documentation closely or do some tests to see which one your particular program is giving you.

\(TraditionalForm\`standard_deviation  _best  _guess  _of  _parent  _population \((x)\)\  = \(s\  = \ σ \@\( N\/\(N - 1\)\)\)\)

The difference is this : σ is the true standard deviation of those particular numbers, while s is the best estimate of the standard deviation of the larger population that those numbers came from.

the Normal Distribution

The real power of the standard deviation is in talking about numbers that follow a Normal Distribution, also called a Bell Curve.

In that case, about 2/3's of all the numbers are within 1 σ of the mean, while about 95% of all the numbers are within 2 σ.  This is important enough to have a formula line.

m  ±  
        1 σ    contains 68  % of normally distributed data
\(m\  ± \ 
          2\ σ\ \ \ \ contains\ 95.5  %\ of\ normally\ distributed\ data\)

Here's another histogram.  Even though it doesn't have red bars, the ideas is still the same :  the x axis shows a data value, while the y axis represents how many of the data points have that value, just like the plot at the top of this page.

<<Statistics`ContinuousDistributions`;
ndist = 
        NormalDistribution[0, 1];
normPDF  =  
        PDF[ndist, 
          xx];
\(DisplayTogether[
Plot[
          normPDF, {xx, \(-3\), 3}, {Ticks -> None, 
            AxesStyle -> {RGBColor[ .6,  .6,  .6]}}], \ 
        Graphics[{\ RGBColor[0, 0,  .5], 
            Text["±2σ", {2.5,  .1}], 
            Line[{{\(-2\),  .1}, {\(+2\),  .1}}]}], 
Graphics[{\ RGBColor[0,  .5, 0], 
            Text["±1σ", {2.5,  .2}], 
            Line[{{\(-1\),  .2}, {\(+1\),  .2}}]}]
];\)
Null

the Standard Deviation of the Mean

This is all very nice, I hear you saying - but what if my data don't follow a Normal Distribution?  After all, the numbers that we started with (0 to 100 with equal probability) aren't normal.

Well, no, they're not.  BUT what if that "experirment" (picking 20 numbers and taking the mean) is done over and over again? What does the distribution of the means look like?  

You might guess that the mean would be near 50 each time, half way between 0 and 100.  And you'd be right. OK, how near? And what is the shape of the distribution?

Here are the numbers you might get if you did this "experiment" 120 time, along with the corresponding histogram.

nTrials  =  120;
experiment  :=  
        Mean[Table[
            Random[Integer, {minNumber, 
                maxNumber}], {howMany}]];
data  =  N[Table[experiment, {nTrials}]]
Histogram[data, HistogramRange -> {30, 70}];

For the mean and standard deviation of these "experiments" we get

Mean[data]

StandardDeviationMLE[data]

These "experiments" give data which is starting to look like a Normal Distribution.  This is in fact a general rule : the distribution of the mean of almost anything is normally distributed if you do it enough times.

This data has has a mean near 50 and a standard deviation a lot smaller than the one from the original random numbers. How much smaller?

Well, there's a formula for that which works out like this :

\(TraditionalForm\`σ\_\(mean\ of\ n_trials\)\ \  ≃ \ \ σ\_once\/\@n_trials\)

For the experiment just performed, (Subscript[σ, once]) = 25 or so (see the top of this page), and n_trials = 120, 
so  \(TraditionalForm\`σ\_once/\(\(\)\(\@n_trials\)\)\)= 25/(Sqrt[120])= 2.8 which is in the same ballpark as 6.5 - even if they aren't quite the same.

Anytime you're doing an experiment over and over to beat down the random errors and get better accuracy,
this is what you're up against:  to get 10 times better accuracy, you need to do it 100 times more often.  (Gulp.)

Experimental Measurements

Now for the punch line : how would you report the results of an experiment like this in a scientific journal?  The language would look something like this.

	In an experiment to measure the mean of 20 random numbers from 0 to 100,
	we find that the result is 49.97  ±  13.2 at the  2σ (p < 0.05) confidence level.

Saying "2σ" is the same as saying"p < 0.05"; in both cases, you're claiming that if someone else chooses 20 random numbers from 0 to 100 and takes their mean, then 95% of the time they'll get the same result you did, 
namely a number within 13.2 of 49.97.  The scientific literature uses these sorts of phrases interchangeably.


So ... are we having fun yet?