📊 Standard Deviation Calculator
Calculate mean, variance, population standard deviation, and sample deviation from datasets.
Standard deviation: measuring spread, and choosing between population and sample
An average tells you where a data set sits. Standard deviation tells you how tightly it clusters there. Two groups can share a mean of 50 while one ranges from 48 to 52 and the other from 5 to 95, and without a measure of spread the two look identical.
The calculation, step by step
- Find the mean: add all values and divide by how many there are.
- Subtract the mean from each value to get the deviation.
- Square each deviation, which removes the signs and weights large departures more heavily.
- Average the squared deviations. This is the variance.
- Take the square root, which returns the answer to the original units.
population: σ = √[ Σ(x − μ)² / N ] sample: s = √[ Σ(x − x̄)² / (n − 1) ]
Why the sample formula divides by n − 1
A sample's own mean sits closer to its own data points than the true population mean does, so the squared deviations come out slightly too small and the variance is biased downward. Dividing by n − 1 instead of n corrects for it. This is Bessel's correction, and the n − 1 is the number of independent pieces of information left once the mean has been estimated from the data.
| Sample size | Population SD | Sample SD | Difference |
|---|---|---|---|
| 5 | 10.00 | 11.18 | +11.8% |
| 10 | 10.00 | 10.54 | +5.4% |
| 30 | 10.00 | 10.17 | +1.7% |
| 100 | 10.00 | 10.05 | +0.5% |
The correction matters for small data sets and becomes negligible for large ones. The rule for choosing: if your data is every member of the group you care about, use the population formula. If it is a subset you are using to estimate something larger, use the sample formula. In practice, most real data sets are samples.
The empirical rule
For data that is roughly normally distributed:
| Range | Approximate share |
|---|---|
| Within 1 standard deviation of the mean | 68% |
| Within 2 standard deviations | 95% |
| Within 3 standard deviations | 99.7% |
If test scores average 72 with a standard deviation of 8, roughly 68% of students scored between 64 and 80, and about 95% between 56 and 88. A score of 96 is three standard deviations out, which fewer than two students in a thousand would reach.
The empirical rule only applies to roughly symmetric, bell-shaped data. For skewed data such as household income, where a long upper tail pulls the mean away from the typical value, the percentages do not hold and the median with an interquartile range describes the distribution better.
Variance, standard deviation and coefficient of variation
Variance is the standard deviation squared. It is the more convenient quantity mathematically, because variances of independent variables add, but it is in squared units: the variance of a set of heights in centimetres is in square centimetres, which means nothing physically. Standard deviation returns to the original units, which is why it is what gets reported.
To compare spread between data sets with different scales, use the coefficient of variation, which is the standard deviation divided by the mean, expressed as a percentage. A standard deviation of 5 is large on a mean of 20 and trivial on a mean of 5,000.
A worked example
Five measurements: 12, 15, 18, 20, 25. The mean is 18. Deviations are −6, −3, 0, 2 and 7, which square to 36, 9, 0, 4 and 49, summing to 98. Population variance is 98/5 = 19.6, so σ = 4.43. Sample variance is 98/4 = 24.5, so s = 4.95. The coefficient of variation using the sample figure is 4.95 / 18 = 27.5%.
Frequently Asked Questions (FAQs)
Should I use population or sample standard deviation?
Use the sample formula, dividing by n − 1, unless your data covers every member of the group you want to describe. Measuring all 30 students in a class to describe that class is a population; measuring 30 students to say something about the school is a sample.
What does a standard deviation of zero mean?
Every value in the data set is identical. There is no spread at all, so every deviation from the mean is zero. It is a valid result and usually a sign that the measurement is not capturing variation that exists.
Is a high standard deviation bad?
Neither good nor bad on its own. In manufacturing, low spread means consistency and is desirable. In a portfolio, higher spread means higher volatility, which is the price of higher expected return. Judge it against what the data is for.
How is standard deviation different from standard error?
Standard deviation describes the spread of the data. Standard error describes the precision of the mean, and equals the standard deviation divided by the square root of the sample size. Larger samples do not reduce the standard deviation but they do reduce the standard error.
What is a z-score?
The number of standard deviations a value sits from the mean: z = (x − mean) / SD. It turns any value into a comparable scale, which is how scores from different tests with different means can be placed side by side.
Why square the deviations instead of taking absolute values?
Squaring keeps the mathematics tractable: squared deviations are differentiable, they decompose cleanly in statistical models, and variances of independent variables add. The mean absolute deviation is a valid measure of spread and is occasionally more robust, but it does not have those properties.
Does standard deviation work for skewed data?
It can be calculated, but it describes the distribution poorly and the empirical rule does not apply. For income, waiting times and similar right-skewed data, the median with the interquartile range gives a far more honest picture.