Standard Deviation Formula- Step-by-Step Calculation
What Standard Deviation Actually Is
Standard deviation measures how spread out numbers are from their average (mean). That's it. Nothing fancy.
A low standard deviation means numbers cluster close to the mean. A high standard deviation means they're scattered far apart.
You use it when you want to know how variable your data is. That's the whole point.
The Two Formulas You Need to Know
There are two versions. Using the wrong one gives you wrong answers.
Population Standard Deviation
Use this when you have every single data point in your dataset.
σ = √[Σ(xi - μ)² / N]
- σ = population standard deviation
- xi = each value in your data
- μ = the population mean
- N = total number of values
Sample Standard Deviation
Use this when your data is just a sample of a larger population. This is what you use most often in real research.
s = √[Σ(xi - x̄)² / (n-1)]
- s = sample standard deviation
- xi = each value in your sample
- x̄ = the sample mean
- n = sample size
The difference: sample standard deviation divides by n-1 instead of n. This corrects for the fact that a sample usually underestimates the true spread. Statisticians call this Bessel's correction.
Step-by-Step Calculation (With Real Numbers)
Let's calculate the standard deviation for this dataset: 2, 4, 4, 4, 5, 5, 7, 9
Step 1: Find the Mean
Add all values and divide by how many there are.
(2 + 4 + 4 + 4 + 5 + 5 + 7 + 9) ÷ 8 = 40 ÷ 8 = 5
Step 2: Subtract the Mean from Each Value
This gives you the deviations. They can be negative—that's fine.
| Value (xi) | xi - Mean (5) |
|---|---|
| 2 | 2 - 5 = -3 |
| 4 | 4 - 5 = -1 |
| 4 | 4 - 5 = -1 |
| 4 | 4 - 5 = -1 |
| 5 | 5 - 5 = 0 |
| 5 | 5 - 5 = 0 |
| 7 | 7 - 5 = 2 |
| 9 | 9 - 5 = 4 |
Step 3: Square Each Deviation
Squaring removes negatives. You need this because a -3 and a +3 both matter equally.
-3² = 9, -1² = 1, -1² = 1, -1² = 1, 0² = 0, 0² = 0, 2² = 4, 4² = 16
Step 4: Add All Squared Deviations
9 + 1 + 1 + 1 + 0 + 0 + 4 + 16 = 32
Step 5: Divide by N (or n-1)
For population: 32 ÷ 8 = 4
For sample: 32 ÷ 7 = 4.57
Step 6: Take the Square Root
For population: √4 = 2
For sample: √4.57 = 2.14
That's your standard deviation. The data varies about 2 units from the mean on average.
Population vs Sample: Which Formula Do You Use?
| Situation | Formula |
|---|---|
| You have ALL data points | Population (divide by N) |
| You have a sample from a larger group | Sample (divide by n-1) |
| Measuring a specific group (class of students, employees) | Usually sample |
| Measuring the entire target population | Population |
Most of the time you're working with samples. Use the sample formula unless you're certain you have everyone.
How to Calculate Standard Deviation in Excel or Google Sheets
Forget doing this by hand. Let the software do it.
For a Sample:
Use =STDEV.S(range) or =STDEV()
For a Population:
Use =STDEV.P(range)
That's it. Select your data, pick the right function, done.
How to Calculate in Python
import statistics data = [2, 4, 4, 4, 5, 5, 7, 9] # Sample standard deviation print(statistics.stdev(data)) # Output: 2.14 # Population standard deviation print(statistics.pstdev(data)) # Output: 2.0
Common Mistakes That Give You Wrong Answers
- Using population formula when you should use sample formula. This underestimates variability and makes your data look tighter than it really is.
- Forgetting to square the deviations. The negatives cancel out and you get zero every time. That's not useful.
- Mixing up variance and standard deviation. Variance is the squared result before you take the square root. They're related but not the same.
- Using n instead of n-1 for samples. Your answer will be slightly wrong.
What the Number Actually Tells You
Standard deviation is measured in the same units as your original data.
If your data is test scores (0-100), your standard deviation is also in points. If your data is dollars, your standard deviation is in dollars.
About 68% of your data falls within one standard deviation of the mean. About 95% falls within two. This is the empirical rule—it works best for data that follows a normal distribution.
Quick Reference: The Process
- Calculate the mean
- Subtract the mean from each value
- Square each result
- Add all squared results
- Divide by N (population) or n-1 (sample)
- Take the square root
Standard deviation isn't complicated. It's just systematic. Follow the steps, use the right formula, and you'll get the right answer every time.