The mean tells you where the data is centered. It says nothing about how spread out the data is. Two classes can both average 80 and still be very different: in one, everyone scored between 70 and 90, and in the other the scores run from 60 to 100. The variance and the standard deviation measure that spread with one number.
This page shows how to compute both step by step, why the distances are squared, what the $latex n-1$ does in the sample version, and how to read the result. The interactive figure draws the squares behind the formula, so you can see what is being averaged.
Why the mean is not enough
Class A scored 70, 75, 80, 85, 90. Class B scored 60, 70, 80, 90, 100. Both means are 80, but B is clearly more spread out. The standard deviations say so with numbers: 7.07 for A and 14.14 for B.
Deviations, variance and standard deviation
The deviation of a value is its distance from the mean, $latex x-\bar{x}$. You cannot average the deviations directly, because they always add up to 0: the positive ones cancel the negative ones. Squaring each deviation fixes the signs and gives extra weight to values far from the mean.
- The variance is the average of the squared deviations.
- The standard deviation is the square root of the variance. It comes back to the units of the data (points, centimeters, dollars), while the variance is in squared units.
For a population (every value in the group), with mean $latex \mu$ and $latex N$ values:
$latex \sigma^2=\frac{\sum (x-\mu)^2}{N} \qquad \sigma=\sqrt{\sigma^2}$
For a sample (some values taken from a larger group), with mean $latex \bar{x}$ and $latex n$ values:
$latex s^2=\frac{\sum (x-\bar{x})^2}{n-1} \qquad s=\sqrt{s^2}$
See the squares
Each blue square has a side equal to one value's distance from the mean, so its area is that deviation squared. The dashed orange square is the "average square": its area equals the variance, so its side is the standard deviation. Drag a point away from the others and watch the orange square grow. Switch to $latex n-1$ to see the sample version.
See the squares behind the standard deviation
Drag a point or type your own numbers. Each blue square has a side equal to one distance from the mean, so its area is that distance squared.
Step by step
- Find the mean: add the values and divide by how many there are.
- Subtract the mean from each value to get the deviations.
- Square each deviation.
- Add the squares. This is the sum of squares.
- Divide by $latex N$ (population) or $latex n-1$ (sample). That is the variance.
- Take the square root. That is the standard deviation.
Here is the whole process for the population 2, 4, 4, 4, 5, 5, 7, 9. The mean is $latex \mu=\frac{40}{8}=5$.
| x | x − 5 | (x − 5)² |
|---|---|---|
| 2 | -3 | 9 |
| 4 | -1 | 1 |
| 4 | -1 | 1 |
| 4 | -1 | 1 |
| 5 | 0 | 0 |
| 5 | 0 | 0 |
| 7 | 2 | 4 |
| 9 | 4 | 16 |
| Total | 0 | 32 |
The sum of squares is $latex 32$. Divide by $latex N=8$: $latex \sigma^2=\frac{32}{8}=4$. Then $latex \sigma=\sqrt{4}=2$.
Population or sample: N or n − 1?
Use $latex N$ when your data is everyone you care about, such as all 30 students in a class. Use $latex n-1$ when the data is a sample used to estimate a larger group, such as 30 voters chosen from a whole city.
The reason for $latex n-1$ is that the sample mean is calculated from the same data, so it sits closer to those values than the true mean would. Deviations measured from $latex \bar{x}$ come out a little too small on average, and dividing by a slightly smaller number corrects that. Another way to see it: once the mean is fixed, only $latex n-1$ of the deviations are free to vary, because the last one must make them add up to 0.
With large samples the difference fades. For $latex n=100$ the two standard deviations differ by about 0.5%. Calculators usually show both, labeled σ and s. The Standard deviation calculator reports both, and the Mean, median and mode calculator gives the mean and the range.
A shortcut formula
Expanding the square gives a version that skips the deviations:
$latex \sigma^2=\frac{\sum x^2}{N}-\mu^2$
For 2, 4, 4, 4, 5, 5, 7, 9: $latex \sum x^2=232$, so $latex \sigma^2=\frac{232}{8}-5^2=29-25=4$. Same answer. It is handy for exams, but it subtracts two big similar numbers, so keep every digit to avoid rounding errors.
How to read a standard deviation
- It uses the same units as the data. A standard deviation of 10 points means a typical score is about 10 points from the mean.
- A bigger value means more spread. It is 0 only when every value is equal, and it can never be negative.
- Adding the same number to every value does not change it. Multiplying every value by $latex k$ multiplies it by $latex |k|$.
- Outliers weigh a lot, because their distance is squared. For bell-shaped data, about 68% of the values fall within one standard deviation of the mean and about 95% within two.
Worked examples
EXAMPLE 1
The data 2, 4, 4, 4, 5, 5, 7, 9 is a sample. Find the sample variance and standard deviation.
The mean is 5 and the sum of squares is 32 (see the table above). With $latex n=8$: $latex s^2=\frac{32}{7}=4.571$.
$latex s=\sqrt{4.571}=2.138$. The sample standard deviation is 2.138, a bit larger than the population value 2.
EXAMPLE 2
Find the population standard deviation of 6, 8, 10, 12, 14.
Mean: $latex \frac{50}{5}=10$. Deviations: $latex -4,-2,0,2,4$. Squares: $latex 16,4,0,4,16$, which add up to 40.
$latex \sigma^2=\frac{40}{5}=8$ and $latex \sigma=\sqrt{8}=2.828$. If it were a sample, $latex s^2=\frac{40}{4}=10$ and $latex s=3.162$.
EXAMPLE 3
Compare class A (70, 75, 80, 85, 90) with class B (60, 70, 80, 90, 100). Both means are 80.
Class A: squared deviations $latex 100,25,0,25,100$ add up to 250, so $latex \sigma^2=50$ and $latex \sigma=7.07$.
Class B: squared deviations $latex 400,100,0,100,400$ add up to 1000, so $latex \sigma^2=200$ and $latex \sigma=14.14$.
Class B has exactly twice the standard deviation: its scores are twice as spread out.
EXAMPLE 4
How much does one outlier change the result? Compare 10, 12, 11, 13, 12 with 10, 12, 11, 13, 40.
The first set has mean 11.6 and $latex \sigma=1.02$.
Changing one value to 40 moves the mean to 17.2 and the standard deviation to $latex \sigma=11.44$, about 11 times larger. One extreme value dominates the sum of squares.
Common mistakes
- Dividing by the wrong number. Population: $latex N$. Sample: $latex n-1$. Check which one your problem needs.
- Adding the deviations without squaring. They always sum to 0.
- Forgetting the square root. The variance is in squared units. The standard deviation is the root.
- Rounding the mean too early. Use the exact mean when subtracting.
- Squaring the sum instead of summing the squares. $latex (\sum x)^2$ is not $latex \sum x^2$.
- Expecting a negative result. A negative variance or standard deviation means a mistake.
Solved exercises
EXERCISE 1
Find the population variance and standard deviation of 12, 15, 18, 21, 24.
Solution
The mean is 18. Deviations: $latex -6,-3,0,3,6$. Squares: $latex 36,9,0,9,36$, sum 90.
$latex \sigma^2=\frac{90}{5}=18$ and $latex \sigma=\sqrt{18}\approx 4.243$.
EXERCISE 2
Find the sample standard deviation of 4, 8, 6, 5, 3, 4.
Solution
The mean is 5. Deviations: $latex -1,3,1,0,-2,-1$. Squares: $latex 1,9,1,0,4,1$, sum 16.
$latex s^2=\frac{16}{5}=3.2$ and $latex s=\sqrt{3.2}\approx 1.789$.
EXERCISE 3
A sum of squared deviations is 108 for 10 values. Find the variance if the data is (a) a population, (b) a sample.
Solution
(a) $latex 108/10=10.8$. (b) $latex 108/9=12$.
EXERCISE 4
Without calculating, which has the larger standard deviation: 20, 22, 24, 26, 28 or 20, 21, 22, 23, 24? Then check.
Solution
The first set is twice as spread out (steps of 2 instead of 1). Check: $latex \sigma=2.83$ against $latex \sigma=1.41$.
EXERCISE 5
Use the shortcut formula for 1, 2, 3, 4, 5 (population).
Solution
$latex \sum x^2=55$, $latex \mu=3$. $latex \sigma^2=\frac{55}{5}-3^2=11-9=2$, so $latex \sigma=\sqrt{2}\approx 1.414$.
EXERCISE 6
The data 2, 4, 4, 4, 5, 5, 7, 9 has standard deviation 2. What happens to it if you (a) add 10 to every value, (b) multiply every value by 3?
Solution
(a) Nothing: it stays 2, since all distances to the mean are unchanged. (b) It triples to 6, and the variance becomes 36.
Frequently asked questions
Why square the deviations and not use absolute values?
Absolute values give a valid measure too (the mean absolute deviation). Squares are used because they behave well in algebra and calculus, and they underlie many other formulas in statistics.
Can the standard deviation be 0?
Yes, when all the values are equal. Then there is no spread at all.
Is a large standard deviation bad?
It depends on the context. It only says the data is spread out. A standard deviation of 15 minutes is large for a train schedule and tiny for a marathon.
Which one should I use on a test: N or n − 1?
Read the wording. If the data is the whole group, divide by N. If it is a sample meant to estimate a larger group, divide by n − 1. When a problem does not say, textbooks usually treat a list of data as a sample.
Related calculators
- Standard deviation calculator
- Mean, median and mode calculator
- Weighted average calculator
- Percentage calculator
More tools are in the calculators hub.