Toolstia / Guides

How to calculate standard deviation, step by step

7 min read

The average tells you where the middle of your data is. The standard deviation tells you how spread out the data is around that middle. It is one of the most useful numbers in statistics, and the calculation is easier than the name suggests.

What standard deviation tells you

Two classes can both average 70 on a test. In one, everyone scored between 65 and 75. In the other, scores ranged from 30 to 100. The averages match, but the data is very different. The standard deviation captures that difference: it is small for the first class and large for the second.

The steps

Take the numbers 2, 4, 4, 4, 5, 5, 7, 9.

  1. Find the mean: add them up (40) and divide by how many there are (8). The mean is 5.
  2. Subtract the mean from each value: −3, −1, −1, −1, 0, 0, 2, 4.
  3. Square each result: 9, 1, 1, 1, 0, 0, 4, 16.
  4. Add the squares: 9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32.
  5. Divide by the number of values (8) to get the variance: 32 ÷ 8 = 4.
  6. Take the square root of the variance: √4 = 2. The standard deviation is 2.

Sample or population

The calculation above divides by n, which is correct when your numbers are the entire group you care about. This is the population standard deviation, written σ.

If your numbers are only a sample from a larger group, divide by n − 1 instead. This is the sample standard deviation, written s. For the same data, 32 ÷ 7 = 4.571 and the square root is about 2.138.

Dividing by n − 1 corrects for the fact that a sample tends to underestimate the true spread. When in doubt, and when your data is a sample, use the sample version.

Why we square the differences

If you simply added the differences from the mean, the positives and negatives would cancel to zero. Squaring makes every difference positive and gives extra weight to values far from the mean. Taking the square root at the end brings the answer back to the original units, such as points or centimetres.

The 68-95-99.7 rule

For data shaped like a bell curve, about 68% of values lie within one standard deviation of the mean, about 95% within two and about 99.7% within three. With a mean of 100 and a standard deviation of 15, about 95% of values fall between 70 and 130.

This only holds for roughly normal data. Skewed data does not follow the rule.

Z-scores

A z-score tells you how many standard deviations a value is from the mean: z = (value − mean) ÷ standard deviation. A z-score of 2 means the value is two standard deviations above average, which is unusually high.

Z-scores let you compare values from different sets, such as a test score in two subjects with different averages and spreads.

Common mistakes

  • Using the population formula for a sample, which makes the spread look smaller than it is.
  • Forgetting to take the square root and reporting the variance instead.
  • Treating an outlier as an error without checking. One extreme value can change the standard deviation a lot.
  • Comparing standard deviations of data with different units or very different means. In that case, use the coefficient of variation, which is the standard deviation divided by the mean.

Let the calculator do the work

The standard deviation calculator on Toolstia takes your list of numbers and shows both the sample and population results, the mean, the variance and the standard error. For short lists it also shows the working step by step, so you can follow along.

To go further, the z-score calculator turns a value into a percentile, and the confidence interval calculator estimates a range for the true mean from your sample.