How to calculate standard deviation
Standard deviation measures how spread out numbers are around their mean. This guide walks through the calculation step by step with a worked example, and explains when to divide by n and when by n − 1.
The short version
- Find the mean. Add the values and divide by how many there are.
- Find each value's deviation. Subtract the mean from every value.
- Square the deviations and add them. Squaring stops negatives cancelling positives.
- Divide. By n for a whole population, or by n − 1 for a sample.
- Take the square root. That gives the standard deviation, in the same units as your data.
Skip the arithmetic. The free Standard Deviation Calculator does this for you, shows the formula and the working with your own numbers, and runs in your browser - nothing you type is uploaded. Also useful: Mean, Median & Mode Calculator, Z-Score Calculator.
A worked example
Data: 2, 4, 4, 4, 5, 5, 7, 9 (eight values).
Sample or population?
Use the population formula (divide by n) when your numbers are every member of the group you care about, such as all the students in one class. Use the sample formula (divide by n − 1) when your numbers are a sample meant to describe a bigger group. A sample's values sit slightly closer to their own mean than to the true mean, so dividing by n − 1 corrects the tendency to underestimate the spread. Most statistics courses default to the sample version unless told otherwise.
Variance and what the result means
Variance is the standard deviation squared: the average squared deviation before the square root. Standard deviation is easier to interpret because it is in the same units as the data. If test scores are roughly bell-shaped with mean 70 and standard deviation 10, about two-thirds of scores fall between 60 and 80, and about 95% between 50 and 90.
Mean, median and mode alongside it
Standard deviation describes spread; mean, median and mode describe the centre. Report them together. When a few extreme values pull the mean away from the median, the data is skewed and standard deviation will be large.
Common mistakes
- Dividing by n when you should divide by n − 1 (or the reverse).
- Forgetting the final square root and reporting the variance.
- Squaring the sum of deviations instead of summing the squares. The deviations always add to 0.
- Using the formula on a single value: a sample standard deviation needs at least two numbers.