How to Calculate Standard Deviation- Step-by-Step
What Standard Deviation Actually Is
Standard deviation measures how spread out numbers are from their average. That's it. Nothing fancy.
If your data points cluster close to the mean, you get a small standard deviation. If they're all over the place, you get a large standard deviation. It tells you whether to expect tight results or wild swings.
Why You Need This Number
Standard deviation shows up everywhere: finance, science, quality control, sports stats. You need it when:
- You're checking if a measurement is unusually far from normal
- You want to compare how consistent two datasets are
- You're calculating confidence intervals
- You need variance for further analysis
Skip it and you're flying blind.
The Formula (Don't Panic)
For a population, the formula is:
σ = √[Σ(x - μ)² / N]
For a sample, you use n-1 instead of N (Bessel's correction):
s = √[Σ(x - x̄)² / (n-1)]
The difference matters. Use the wrong one and your results are wrong.
Step-by-Step Calculation
Example dataset: 2, 4, 4, 4, 5, 5, 7, 9
Step 1: Find the mean
Add everything up and divide by how many numbers you have.
2 + 4 + 4 + 4 + 5 + 5 + 7 + 9 = 40
40 ÷ 8 = 5
Step 2: Subtract the mean from each value
2 - 5 = -3
4 - 5 = -1
4 - 5 = -1
4 - 5 = -1
5 - 5 = 0
5 - 5 = 0
7 - 5 = 2
9 - 5 = 4
Step 3: Square each difference
(-3)² = 9
(-1)² = 1
(-1)² = 1
(-1)² = 1
0² = 0
0² = 0
2² = 4
4² = 16
Step 4: Add all squared differences
9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32
Step 5: Divide by N (or n-1 for a sample)
Population: 32 ÷ 8 = 4
Sample: 32 ÷ 7 = 4.57
Step 6: Take the square root
Population SD: √4 = 2
Sample SD: √4.57 = 2.14
Population vs. Sample: When to Use Which
| Situation | Use |
|---|---|
| You have every single data point | Population formula (divide by N) |
| You're working with a subset of data | Sample formula (divide by n-1) |
| Measuring everyone in a study | Population formula |
| Taking a survey, analyzing past records | Sample formula |
The n-1 in the sample formula corrects for bias. Small samples tend to underestimate variability. This fix makes your estimate more accurate.
Quick Comparison: Standard Deviation vs. Variance
| Measure | Formula | Unit of measurement | Use case |
|---|---|---|---|
| Variance | Average of squared differences | Squared original units | Theoretical work, advanced stats |
| Standard Deviation | Square root of variance | Same as original data | Reporting results, practical analysis |
Variance tells you the average squared deviation. Standard deviation puts it back in the original units so it's interpretable.
How to Calculate in Excel or Google Sheets
Skip the manual math for large datasets.
- Population SD: =STDEVP(range)
- Sample SD: =STDEV(range)
- Newer Excel versions: =STDEV.P(range) for population, =STDEV.S(range) for sample
Verify your formula matches your data type. Mixing these up is a common mistake.
How to Calculate in Python
import statistics
data = [2, 4, 4, 4, 5, 5, 7, 9]
# Sample standard deviation
sample_sd = statistics.stdev(data)
# Population standard deviation
population_sd = statistics.pstdev(data)
print(f"Sample SD: {sample_sd}")
print(f"Population SD: {population_sd}")
Output: Sample SD: 2.14, Population SD: 2.0
Interpreting Your Results
A standard deviation of 2 on our dataset (mean = 5) means most values fall between 3 and 7. About 68% of data falls within one standard deviation of the mean in a normal distribution.
Low SD = consistent results. High SD = unpredictable results. There's no "good" or "bad" value—it depends entirely on what you're measuring.
If you're measuring manufacturing defects and get an SD of 0.5, that's great. If you're measuring daily stock prices with the same SD, that's volatility you might want to avoid.
Common Mistakes That Ruin Your Calculation
- Using population formula when you have a sample
- Forgetting to square the differences (you'll get the wrong answer)
- Rounding too early in the process
- Not checking for data entry errors before starting
Double-check your mean. If that's wrong, everything downstream is wrong.
Getting Started Checklist
- □ Determine if you're working with a population or sample
- □ Calculate the mean first
- □ Subtract mean from each value
- □ Square each result
- □ Sum all squared values
- □ Divide by N (population) or n-1 (sample)
- □ Take the square root
- □ Interpret in context of your data
That's the whole process. Once you do it a few times, it becomes automatic.