How to Calculate Standard Deviation: 5 Steps with a Worked Example
Standard deviation tells you how far the values in a set typically sit from their mean. A small standard deviation means the values bunch together; a large one means they are spread out.
The short version
- Find the mean.
- Subtract the mean from each value.
- Square each of those differences and add them up.
- Divide by for a sample, or by if you have the whole population. This is the variance.
- Take the square root. That is the standard deviation.
The calculator above is loaded with the example worked through below. Replace the numbers with your own, or switch between sample and population.
Worked example: eight days of temperatures
Suppose you recorded the midday temperature, in °C, on 8 days:
Step 1: Find the mean
Add the values and divide by how many there are:
Step 2: Subtract the mean from each value
Values below the mean give a negative difference, values above it a positive one. The differences always add up to zero, which is why the next step squares them.
Step 3: Square the differences and add them
| 23 | -1.5 | 2.25 |
| 25 | 0.5 | 0.25 |
| 28 | 3.5 | 12.25 |
| 22 | -2.5 | 6.25 |
| 26 | 1.5 | 2.25 |
| 24 | -0.5 | 0.25 |
| 27 | 2.5 | 6.25 |
| 21 | -3.5 | 12.25 |
| Sum | 42 | |
Step 4: Divide by n − 1 to get the variance
These 8 days are a sample of the weather, not every day there will ever be, so divide by :
Step 5: Take the square root
The sample standard deviation is about 2.45 °C.
What the answer means
A standard deviation of 2.45 °C says a typical day was a couple of degrees away from the mean of 24.5 °C. It is not exactly the average distance from the mean (that would be the mean absolute deviation), because squaring gives the far-out days more weight.
For data that roughly follows a bell curve, about 68% of values fall within one standard deviation of the mean and about 95% within two. In this small set, 4 of the 8 days fall between 22.05 and 26.95 °C; a handful of values rarely matches the rule closely. To see where one value sits, turn it into a z-score: how many standard deviations it is from the mean.
Sample or population: which formula?
Both formulas follow the same five steps. The only difference is what you divide by in step 4.
- Sample (), divide by : your data is part of a bigger group, such as 100 customers out of 10,000, or a week of readings. This is the usual case in coursework and research.
- Population (), divide by : your data is the entire group you care about, such as the marks of every student in one class.
Dividing by (Bessel's correction) makes up for the fact that a sample's values sit closer to their own mean than to the true population mean. If the eight temperatures above were the whole population:
For the same numbers the population figure (2.29) is always a little smaller than the sample figure (2.45), unless every value is identical and both are zero. The gap shrinks as the data set grows.
On a calculator or in a spreadsheet
- Excel and Google Sheets:
=STDEV.S(A1:A8)for a sample,=STDEV.P(A1:A8)for a population. The olderSTDEVis the sample version. - Scientific and graphing calculators: in statistics mode, (shown as Sx on some models) is the sample standard deviation and is the population one.
Common mistakes
- Dividing by the wrong number. Use for a sample and for a whole population.
- Stopping at the variance. The variance (6 here) is in squared units, °C². Take the square root to get back to °C.
- Rounding the mean too early. Keep full precision until the last step; a rounded mean throws every difference off.
- Mixing it up with the standard error. The standard error, , measures how precisely you know the mean, not how spread out the data is.
Related calculators and guides
- Standard deviation calculator: sample, population, grouped data and two-set comparison, with every step.
- Variance calculator and mean, median and mode calculator.
- Coefficient of variation calculator: compare spread between sets with different means (guide).
- Z-scores and the normal distribution and how to find outliers.
Related Articles
Coefficient of Variation: Formula, Steps and Worked Examples
Work out the coefficient of variation from the mean and standard deviation, with a calculator loaded with the first example, sample against population, and when to use it instead of standard deviation.
Understanding Z-Scores and Normal Distribution
Learn what z-scores mean, how the bell curve works, and how to use z-score tables. Includes worked examples and links to our standard deviation calculator.
How to Find Outliers Using IQR and Z-Score Methods
Learn three methods for detecting outliers: the IQR method, Z-score method, and Modified Z-score. Includes worked examples and guidance on when to remove outliers.