How to calculate the standard deviation of a data set
The standard deviation measures how spread out numbers are around their mean. You calculate it in five steps: find the mean, subtract it from each value, square the differences, average them, and take the square root. For the data set 2, 4, 4, 4, 5, 5, 7, 9, the population standard deviation is 2 and the sample standard deviation is 2.14. Paste your own numbers into the standard deviation calculator.
The formulas
For a population (you have every value):
σ = √( Σ(x − μ)² ÷ N )
For a sample (a subset used to estimate a larger population):
s = √( Σ(x − x̄)² ÷ (n − 1) )
The only difference is the divisor: N or n − 1.
Worked example
Data: 2, 4, 4, 4, 5, 5, 7, 9 (n = 8).
Step 1: the mean. (2 + 4 + 4 + 4 + 5 + 5 + 7 + 9) ÷ 8 = 40 ÷ 8 = 5.
Steps 2 and 3: deviations and squares.
| 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 |
Step 4: sum of squares. 9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32.
Step 5: divide and take the square root.
- population: 32 ÷ 8 = 4 (the variance), √4 = 2
- sample: 32 ÷ 7 = 4.571 (the variance), √4.571 = 2.138
Why square the deviations?
The raw deviations always add up to zero, because values above and below the mean cancel out. Squaring makes every deviation positive and gives larger deviations more weight. Taking the square root at the end brings the result back to the original units: if your data is in centimetres, so is the standard deviation, while the variance is in square centimetres.
Sample or population?
Use the population formula when your data includes every member of the group you care about, such as the test scores of all 28 students in your class when you only want to describe that class. Use the sample formula when your data is a selection used to draw conclusions about a larger group, such as 200 surveyed customers representing all your customers. In research and most statistics courses, the sample version is what you need.
Dividing by n − 1 (Bessel's correction) compensates for the fact that a sample tends to underestimate the spread of the population. With large data sets the difference becomes negligible.
What does the number tell you?
For data that is roughly normally distributed:
- about 68% of values lie within 1 standard deviation of the mean;
- about 95% within 2 standard deviations;
- about 99.7% within 3 standard deviations.
Suppose test scores have a mean of 70 and a standard deviation of 8. Then about 95% of students scored between 54 and 86, and a score of 94 is three standard deviations above the mean, which is unusual.
In Excel and Google Sheets
| Function | Meaning |
|---|---|
STDEV.S | sample (n − 1) |
STDEV.P | population (N) |
VAR.S / VAR.P | the matching variances |
STDEV | older name for STDEV.S |
On a TI-84 calculator, 1-Var Stats shows both Sx (sample) and σx (population).
Frequently asked questions
What is the difference between variance and standard deviation?
The variance is the average squared deviation; the standard deviation is its square root. The standard deviation is in the same units as the data, which makes it easier to interpret.
Can the standard deviation be negative?
No. It is always zero or positive. Zero means all values are identical.
What is a high standard deviation?
It depends on the mean. The coefficient of variation (standard deviation ÷ mean) helps compare data sets; in the example it is 2 ÷ 5 = 40%.
How many values do I need?
At least two for a sample standard deviation. More values give a more reliable estimate.