Calculator of Alexandria

Mean, standard deviation and standard error calculator

Paste a list of numbers to get the mean, sample and population standard deviation, and the standard error of the mean.

Paste a column from a spreadsheet, or separate values with spaces or commas. Write thousands without commas.

Meanxˉ\bar{x}
Standard deviation (sample)ss
Standard error of the meanSE\text{SE}
Standard deviation (population)σ\sigma
Countnn

Formula

s=∑(xi−xˉ)2n−1s = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n - 1}}
How it's derived

The formulas

xˉ=1n∑i=1nxi\bar{x} = \frac{1}{n}\sum_{i=1}^{n} x_i s=∑(xi−xˉ)2n−1,SE=sns = \sqrt{\frac{\sum (x_i - \bar{x})^2}{n - 1}}, \qquad \text{SE} = \frac{s}{\sqrt{n}}

The mean xˉ\bar{x} is the centre of your data, the standard deviation ss is how spread out individual values are, and the standard error SE\text{SE} is how precisely the mean itself is known.

Where they come from

The mean is the value that balances the data: the deviations above it cancel the deviations below it, because ∑(xi−xˉ)=∑xi−nxˉ=0\sum (x_i - \bar{x}) = \sum x_i - n\bar{x} = 0.

Spread. Since signed deviations always sum to zero, we square them so they can’t cancel. Averaging the squared deviations gives the variance, and its square root brings us back to the original units. If your numbers are the entire population, that average uses nn:

σ=∑(xi−μ)2n\sigma = \sqrt{\frac{\sum (x_i - \mu)^2}{n}}

Why n−1n - 1 for a sample. Usually your numbers are a sample, and the true mean μ\mu is unknown, so you measure deviations from xˉ\bar{x} instead. But xˉ\bar{x} is calculated from the same data, which puts it closer to those points than μ\mu is. In fact xˉ\bar{x} is exactly the value that minimises ∑(xi−c)2\sum (x_i - c)^2, so deviations from it are systematically too small. On average the shortfall is exactly one value’s worth of variance:

E[∑(xi−xˉ)2]=(n−1) σ2\mathbb{E}\left[\sum (x_i - \bar{x})^2\right] = (n - 1)\,\sigma^2

Dividing by n−1n - 1 instead of nn (Bessel’s correction) cancels that bias. Another way to see it: once xˉ\bar{x} is fixed, only n−1n - 1 deviations are free to vary, because the last one must make them sum to zero.

Standard error. The mean of nn independent values has variance σ2/n\sigma^2/n, because variances of independent values add, and dividing a sum by nn divides its variance by n2n^2:

Var⁡(xˉ)=1n2∑Var⁡(xi)=nσ2n2=σ2n\operatorname{Var}(\bar{x}) = \frac{1}{n^2}\sum \operatorname{Var}(x_i) = \frac{n\sigma^2}{n^2} = \frac{\sigma^2}{n}

Taking the square root and estimating σ\sigma with ss gives SE=s/n\text{SE} = s/\sqrt{n}. That is why quadrupling your sample size only halves the standard error.

Worked example

For 2, 4, 4, 4, 5, 5, 7, 9: the mean is 40/8=540/8 = 5, the squared deviations sum to 32, so

s=32/7=2.138,σ=32/8=2,SE=2.138/8=0.756s = \sqrt{32/7} = 2.138, \qquad \sigma = \sqrt{32/8} = 2, \qquad \text{SE} = 2.138/\sqrt{8} = 0.756

Which one to report

  • Standard deviation describes your data: how much individual measurements vary.
  • Standard error describes your estimate of the mean. Use it, or better a confidence interval, when comparing means.
  • Error bars in figures should say which one they show; they differ by a factor of n\sqrt{n}.

Last checked