Standard Deviation Calculator

Take 2, 4, 4, 4, 5, 5, 7, 9. The mean is 5, the squared deviations add to 32, and from there the answer forks: divide by 8 and the standard deviation is exactly 2, divide by 7 and it is 2.138. Both are correct; they answer different questions. Most calculators pick one silently and never tell you which.

Separate with commas, spaces or line breaks
Standard Deviation Calculator — Sample and Population, Variance, Z-Scores and Coefficient of VariationBuildFigure

The one thing people get wrong

There are two standard deviations, they are different numbers, and which one is right depends entirely on what your list of numbers is.

  • Population, written sigma: your list is the whole group you care about. Every student in the class, every part in the batch, all twelve months of last year. Divide the sum of squared deviations by n.
  • Sample, written s: your list is a subset, drawn from a larger group, and you want to estimate the spread of that larger group. Thirty students out of a district, twenty parts pulled off the line, a survey. Divide by n minus 1.

The correction exists because you had to use the sample's own mean to compute the deviations. The sample mean sits, by construction, in the middle of your particular sample, which makes the deviations from it slightly smaller than the deviations from the true population mean would have been. Dividing by n minus 1 instead of n inflates the result by exactly enough to remove that bias from the variance. This is Bessel's correction, and one degree of freedom is the price of having estimated the mean from the same data.

The worked example, both ways

Take 2, 4, 4, 4, 5, 5, 7, 9. There are eight values and they sum to 40, so the mean is 5. The deviations are -3, -1, -1, -1, 0, 0, +2, +4. Squared they are 9, 1, 1, 1, 0, 0, 4, 16, which add to 32.

PopulationSample
Divisorn = 8n - 1 = 7
Variance32 / 8 = 432 / 7 = 4.571429
Standard deviation2 exactly2.138090
Spreadsheet functionSTDEV.P, STDEVPSTDEV.S, STDEV, STDEVA

The sample figure is about 7 percent larger here. With eight values the gap is visible; with a thousand it is a rounding error; with three or four it is large enough that quoting the wrong one is a real mistake. Since the two answers diverge most exactly when your data is smallest, this page always shows both and makes you say which one is the headline.

What your software silently assumes

Excel and Google Sheets split them: STDEV.S is the sample, STDEV.P is the population, and the bare legacy STDEV is the sample. NumPy goes the other way — numpy.std defaults to the population, and you get the sample by passing ddof=1. R's sd() is the sample with no option to change it. Most pocket calculators offer both under labels like sigma-n and sigma-n-1, which nobody reads. If two tools give you different answers on the same data, this is almost always the reason, and the ratio between them will be the square root of n over n minus 1.

Reading the number once you have it

The standard deviation carries the same units as your data, which is the whole reason for taking the square root of the variance at the end. "Mean 80 points, standard deviation 5 points" is directly readable; "variance 25 points squared" is not. The coefficient of variation, the standard deviation over the mean, strips the units off so you can compare the spread of two things measured differently — heights in centimetres against weights in kilograms. The standard error, s over the square root of n, is a different quantity again: it describes how much the mean would wobble if you drew another sample of the same size, and it shrinks as n grows, while the standard deviation does not.

A z-score says how many standard deviations a value sits from the mean. If the data is roughly bell-shaped, about 68 percent of values fall within one standard deviation of the mean and about 95 percent within two. That rule is a property of the normal distribution, not of standard deviations in general, and it fails badly on skewed or bimodal data. To turn a z-score into a rank, use the percentile calculator, which has a normal-distribution mode for exactly that.

Where this stops being enough

The standard deviation is a single number summarising a whole shape, and single numbers lose things. Two datasets can share a mean and a standard deviation while looking nothing alike — one flat, one with two peaks, one symmetric, one with a single outlier doing all the work. The value-by-value table above exists so you can see whether one row is producing most of the sum of squared deviations. If it is, decide deliberately whether that point belongs in the data, rather than letting it set the spread by default.

Questions people ask

My homework does not say sample or population. Which one?

Look for the word "sample", "survey", "drawn from", "randomly selected", or any request to estimate or infer something about a larger group; all of those mean n minus 1. If the problem hands you a complete set and asks about the spread of that set — the heights of all seven people in this list, the marks of everyone in this class — it is a population and you divide by n. Introductory statistics courses lean heavily on the sample formula because inference is the point of the course, while many secondary-school syllabuses define variance with n only. When you genuinely cannot tell, state your assumption next to the answer; that is what a marker wants to see anyway.

Why square the deviations instead of just taking absolute values?

Squaring is not the only option, and the absolute alternative is a real statistic, the mean absolute deviation. Squaring wins on two grounds. It is differentiable everywhere, so the algebra of least squares, regression and analysis of variance all follows from it, whereas the absolute value has a corner at zero that breaks the calculus. And variances of independent quantities add, which absolute deviations do not, so the whole apparatus of combining uncertainties depends on the squared version. The cost is that squaring gives extra weight to distant points, which is why a single outlier can move the standard deviation more than it moves anything else on the page.

What does a standard deviation of zero mean?

Every value in the list is identical. The mean equals every value, all the deviations are zero, and the sum of squared deviations is zero, so both variances and both standard deviations are zero. Z-scores are then undefined rather than zero, because computing one requires dividing by the standard deviation, and this page leaves that column blank instead of printing a misleading 0. In practice a standard deviation of zero on measured data usually means the measuring instrument has less resolution than the variation you are trying to detect.

Can the standard deviation be larger than the mean?

Yes, and it is common. Any data that is bounded below by zero and has a long right tail — waiting times, incomes, file sizes, defect counts — routinely has a standard deviation exceeding its mean, which shows up as a coefficient of variation above 100 percent. It is not an error. What it does tell you is that "mean plus or minus one standard deviation" runs below zero and therefore describes nothing real, which is a reliable sign that the data is not bell-shaped and that percentiles will describe it better than a mean and a spread.

Related