How to calculate standard deviation, step by step
The standard deviation formula, five steps to calculate it by hand, worked examples for a list and a frequency table, and population σ versus sample s.
Standard deviation measures how far data spread from the mean. The standard deviation formula for a population is σ = √(Σ(x − x̄)² / n): subtract the mean from each value, square, average the squares, then take the square root. The average of the squares is the variance.
Key points
- Variance is the mean of the squared deviations; standard deviation is its square root.
- DSE Compulsory Part uses σ, which divides by n.
- The sample standard deviation s divides by n − 1 and belongs to M1.
- Adding a constant to every value does not change σ; multiplying every value by k multiplies σ by |k|.
The standard deviation formula
For n values x₁, x₂, …, xₙ with mean x̄, the population standard deviation is σ = √(Σ(x − x̄)² / n). The variance is σ², the same expression without the square root.
The symbol σ is the Greek letter sigma. Standard deviation is in the same units as the data, which is why it is easier to interpret than the variance.
Read next: Standard deviation calculator
How to find standard deviation in five steps
Follow these steps for any list of numbers.
- Find the mean x̄: add the values and divide by n.
- Subtract the mean from each value to get the deviations x − x̄.
- Square each deviation.
- Add the squares and divide by n. This is the variance.
- Take the square root. This is the standard deviation σ.
Worked example: a list of numbers
Find the standard deviation of 4, 7, 8, 9 and 12. The mean is 40 ÷ 5 = 8.
The squares add up to 34, so the variance is 34 ÷ 5 = 6.8 and σ = √6.8 ≈ 2.61.
You can check with the shortcut σ² = Σx²/n − x̄². Here Σx² = 354, so σ² = 70.8 − 64 = 6.8, the same answer.
Deviations and squares
| x | x − x̄ | (x − x̄)² |
|---|---|---|
| 4 | −4 | 16 |
| 7 | −1 | 1 |
| 8 | 0 | 0 |
| 9 | 1 | 1 |
| 12 | 4 | 16 |
| Total | 0 | 34 |
Worked example: a frequency table
When values repeat, multiply each squared deviation by its frequency f: σ = √(Σf(x − x̄)² / Σf).
A class records the number of books each student read: 1 book (2 students), 2 books (5 students) and 3 books (3 students). Then Σf = 10 and the mean is 21 ÷ 10 = 2.1.
The weighted squares add up to 4.9, so the variance is 4.9 ÷ 10 = 0.49 and σ = 0.7.
Frequency table
| x | f | x − x̄ | f(x − x̄)² |
|---|---|---|---|
| 1 | 2 | −1.1 | 2.42 |
| 2 | 5 | −0.1 | 0.05 |
| 3 | 3 | 0.9 | 2.43 |
| Total | 10 | 4.9 |
Read next: Measures of dispersion: methods and examples
Population σ or sample s?
The sample standard deviation s divides by n − 1 instead of n. HKEAA's notation table uses the population variance σ² in the Compulsory Part and keeps the sample variance s² for M1, so for DSE Compulsory Part questions divide by n.
For the list above, s = √(34 ÷ 4) = √8.5 ≈ 2.92, larger than σ. Scientific calculators usually show both: σx (or σn) divides by n, and sx (or σn−1) divides by n − 1.
What happens when the data change
Adding the same number to every value moves the mean but leaves the spread, and so σ, unchanged. Multiplying every value by k multiplies σ by |k| and the variance by k².
So if every mark in a test is raised by 5, σ stays the same; if every mark is doubled, σ doubles.
Read next: All the DSE Maths formulas by topic
Try one
Find the standard deviation of 2, 4, 4, 5 and 10.
Hint: The mean is 5.
Answer: Deviations: −3, −1, −1, 0, 5. Squares: 9, 1, 1, 0, 25, total 36. Variance = 36 ÷ 5 = 7.2, so σ = √7.2 ≈ 2.68.
Check your answer with the standard deviation calculator
Frequently asked questions
Can standard deviation be negative?
No. It is a square root, so it is zero or positive. It is zero only when every value is the same.
What is the difference between variance and standard deviation?
Variance is the mean of the squared deviations; standard deviation is its square root, so it has the same units as the data.
Why square the deviations?
The deviations always add up to zero, because values above and below the mean cancel. Squaring makes every deviation positive.
Which calculator key should I use in DSE Maths?
For the Compulsory Part, the key that divides by n, usually labelled σx. The key that divides by n − 1 is for sample questions in M1.