Standard deviation formulas
| Sample | Population | |
|---|---|---|
| Standard deviation | s = √( Σ(x − x̄)² ÷ (n − 1) ) | σ = √( Σ(x − μ)² ÷ N ) |
| Variance | s² = Σ(x − x̄)² ÷ (n − 1) | σ² = Σ(x − μ)² ÷ N |
How to calculate standard deviation by hand
Example data: 2, 4, 4, 4, 5, 5, 7, 9.
- Find the mean: (2 + 4 + 4 + 4 + 5 + 5 + 7 + 9) ÷ 8 = 40 ÷ 8 = 5.
- Subtract the mean and square: 9, 1, 1, 1, 0, 0, 4, 16.
- Add them up: the sum of squares is 32.
- Divide: by n − 1 = 7 for a sample (variance 4.571) or by N = 8 for a population (variance 4).
- Square root: s = √4.571 ≈ 2.138; σ = √4 = 2.
What standard deviation tells you
The standard deviation measures how far values typically sit from the mean. A small standard deviation means the data is tightly clustered; a large one means it is spread out. For roughly bell-shaped data, the 68–95–99.7 rule applies: about 68% of values lie within 1 standard deviation of the mean, 95% within 2, and 99.7% within 3.
To see how far a single value is from the mean in standard deviations, use the z-score calculator. To see the spread, draw a histogram.
Standard deviation, in one picture
Standard deviation measures how spread out values are around their mean. These two data sets have exactly the same mean, but one is tightly packed and the other is spread out, and their standard deviations show it.
How to read your result
- It is in the same units as your data. A standard deviation of 4.2 cm means values typically sit about 4 cm from the mean.
- Use the 68–95–99.7 rule for bell-shaped data. If test scores have a mean of 70 and a standard deviation of 5, about 68% of students scored between 65 and 75, and about 95% between 60 and 80.
- Compare spreads with the coefficient of variation (SD ÷ mean) when the means are very different. A spread of 5 kg matters a lot for cats and very little for cars.
- It is never negative, and it is 0 only when every value is identical.
Sample or population? Quick examples
| Situation | Use |
|---|---|
| 30 students surveyed to learn about the whole school | Sample (s, n − 1) |
| Weights of 50 bags tested from a day’s production | Sample (s, n − 1) |
| Test scores of every student in your class, describing just your class | Population (σ, N) |
| Monthly sales for all 12 months of last year | Population (σ, N) |
If you’re unsure, use the sample formula. It’s the default in most courses, software and research.
Common mistakes to avoid
- Dividing by n for a sample. This underestimates the spread. Use n − 1 unless you truly have the whole population.
- Forgetting the square root. Σ(x − x̄)² ÷ (n − 1) is the variance. The standard deviation is its square root.
- Rounding the mean too early. Rounding x̄ before subtracting introduces errors that add up. Keep full precision until the end.
- Mixing up standard deviation and standard error. The SD describes the spread of the data; the standard error (s ÷ √n) describes how precisely the mean is estimated.
- Relying on SD for skewed data. A few extreme values inflate it. For skewed data, report the median and IQR as well.
Standard deviation in Excel, Google Sheets, TI-84 and Python
| Software | How |
|---|---|
| Excel | =STDEV.S(A2:A51) for a sample, =STDEV.P(A2:A51) for a population. Variance: VAR.S and VAR.P. |
| Google Sheets | =STDEV(A2:A51) for a sample, =STDEVP(A2:A51) for a population. |
| TI-84 | STAT › CALC › 1-Var Stats. Sx is the sample SD; σx is the population SD. |
| Python | statistics.stdev(data) (sample) or statistics.pstdev(data); NumPy: np.std(data, ddof=1) for a sample. |
Have grouped data instead of raw values? Use the grouped data calculator.
Related tools: Descriptive Statistics Calculator, Z-Score Calculator, Mean, Median & Mode Calculator, Histogram Maker and Five-Number Summary Calculator.