How to Calculate Standard Deviation Step by Step (With Real Examples)
Standard deviation is one of those statistics that sounds intimidating but is actually quite mechanical once you see the steps laid out clearly. This guide walks through the calculation from scratch with real numbers so you can follow along and check your own work.
What Standard Deviation Actually Measures
Before jumping into the formula, it helps to understand what you are actually calculating. Standard deviation tells you how spread out your data is around the average. A small standard deviation means most values cluster close to the mean. A large one means the values are spread out across a wider range.
Think of two classrooms. Both have an average test score of 75. In classroom A, every student scored between 72 and 78. In classroom B, scores ranged from 40 to 98. Same average, completely different picture. Standard deviation captures that difference.
Sample vs Population First
Before calculating, you need to decide which version of the formula to use. Population standard deviation is for when your dataset contains every member of the group you are studying. Sample standard deviation is for when your data is a subset drawn from a larger group.
In most school assignments and most research, you are working with samples. The difference between the two comes down to one number in the denominator, which we will cover in the formula section.
The Step by Step Calculation
Let's use this dataset: 4, 7, 13, 2, 1. We are treating this as a sample.
Step 1: Find the mean. Add all values together. 4 + 7 + 13 + 2 + 1 = 27. Divide by the count. 27 / 5 = 5.4. The mean is 5.4.
Step 2: Subtract the mean from each value and square the result.
- 4 - 5.4 = -1.4, squared = 1.96
- 7 - 5.4 = 1.6, squared = 2.56
- 13 - 5.4 = 7.6, squared = 57.76
- 2 - 5.4 = -3.4, squared = 11.56
- 1 - 5.4 = -4.4, squared = 19.36
Step 3: Add the squared differences. 1.96 + 2.56 + 57.76 + 11.56 + 19.36 = 93.2
Step 4: Divide by n - 1 (for sample) or n (for population). Since this is a sample, divide by 5 - 1 = 4. That gives 93.2 / 4 = 23.3. This is the variance.
Step 5: Take the square root. Square root of 23.3 = approximately 4.83. That is the sample standard deviation.
Open Standard Deviation Calculator
Why We Square the Differences
You might wonder why we square the deviations instead of just taking the absolute value. Two reasons. First, squaring makes all deviations positive, so they do not cancel out when you add them. Second, squaring gives more weight to values that are far from the mean. A value that is 10 units away contributes 100 to the sum, while one that is 1 unit away contributes only 1. This makes standard deviation more sensitive to outliers, which is often the behaviour we want.
A Quicker Example with Whole Number Output
Dataset: 2, 4, 4, 4, 5, 5, 7, 9. Mean = 40 / 8 = 5. Squared deviations: 9, 1, 1, 1, 0, 0, 4, 16. Sum = 32. Population variance = 32 / 8 = 4. Population standard deviation = square root of 4 = 2. This is the textbook example precisely because the answer is a clean whole number.
Common Mistakes
The most frequent error is forgetting to square root at the end, which gives you variance instead of standard deviation. The second most common mistake is using n instead of n-1 when working with a sample. Both mistakes produce wrong answers that look plausible, which makes them easy to miss.
Frequently Asked Questions
What is the difference between standard deviation and variance?
Standard deviation is the square root of variance. Variance is the average of the squared differences from the mean. Standard deviation is easier to interpret because it is in the same units as your original data. If your data is in centimetres, your standard deviation is also in centimetres, but variance would be in centimetres squared.
When do I divide by n versus n-1?
Divide by n when you have the entire population. Divide by n-1 when you have a sample. Using n-1 for a sample is called Bessel's correction and prevents you from underestimating the true population variability. Most statistics courses default to n-1 unless explicitly told otherwise.
Can standard deviation be negative?
No. Because you square the deviations before averaging them, the result before the square root is always zero or positive. Zero only happens when all values in the dataset are identical. The square root of zero or a positive number is always zero or positive, so standard deviation is always zero or greater.
How do I interpret a standard deviation of 0?
A standard deviation of zero means every value in the dataset is exactly the same as the mean. There is no spread at all. This is rare in real data but can happen in manufactured examples or in very controlled measurements.