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]

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)]

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)
22 - 5 = -3
44 - 5 = -1
44 - 5 = -1
44 - 5 = -1
55 - 5 = 0
55 - 5 = 0
77 - 5 = 2
99 - 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?

SituationFormula
You have ALL data pointsPopulation (divide by N)
You have a sample from a larger groupSample (divide by n-1)
Measuring a specific group (class of students, employees)Usually sample
Measuring the entire target populationPopulation

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

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

  1. Calculate the mean
  2. Subtract the mean from each value
  3. Square each result
  4. Add all squared results
  5. Divide by N (population) or n-1 (sample)
  6. 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.