How to Calculate Standard Deviation: Steps, Formula, and n − 1

💡 150–300K searches/mo⏱️ 7 min read

Standard deviation is the "typical distance from average" number. It's five steps, four of them arithmetic a middle schooler can do, and the whole thing takes about two minutes by hand once. The confusion is never the arithmetic — it's the n versus n − 1 question, and what the final number actually tells you. Both, solved below.

Advertisement

What does standard deviation measure?

Two data sets can share a mean and behave completely differently: {0, 0, 10, 10} and {4, 5, 5, 6} both average 5, but the first is wild and the second is tame. The mean can't see that difference. Standard deviation can.

The idea: measure how far each value sits from the mean, then combine those distances into one number. The combining is the clever part. Raw deviations always sum to zero (that's what makes the mean the mean), so we square them first — which also makes big outliers count extra — average the squares, and take the square root at the end to get back to the original units. Square root of the average squared distance: "standard deviation."

The five steps, with a real data set

Let's use 4, 8, 15, 16, 23, 42.

Step 1 — mean. Sum is 108, n is 6, so x̄ = 18.

Step 2 — deviations. Subtract the mean from each value: −14, −10, −3, −2, 5, 24.

Step 3 — square them. 196, 100, 9, 4, 25, 576.

Step 4 — average the squares. Their sum is 910.

xx − x̄(x − x̄)²
4−14196
8−10100
15−39
16−24
23525
4224576
x̄ = 18Σ = 910

Step 5 — square root. Here the n versus n − 1 fork appears:

The standard deviation calculator runs these exact steps on any data set and shows both answers with the deviations table, so you can check each line of by-hand work.

Check your homework line by line

Paste any data set. Get sample and population SD, variance, mean, median, and mode — with the deviations laid out.

Standard Deviation Calculator →

Sample or population: which divisor?

The rule is about where the data came from, not how many values you have.

Use n (population) when the data set is the entire group you're describing. All 23 students in a class, every unit a machine produced this shift, the complete list of your trades this year. You're describing those exact numbers, so you average the squared deviations the plain way.

Use n − 1 (sample) when the data is a sample standing in for a bigger population — a poll of 800 voters, a clinical trial's 40 patients, this month's 30 customer calls. You're not describing the sample; you're estimating the population behind it, and the plain average would systematically underestimate the spread.

Why n − 1 fixes the bias

Bessel's correction, in plain terms: the deviations in a sample are measured from the sample's own mean, and that mean is — by definition — the single closest point to those exact values. The true population mean sits further away on average, so real deviations run bigger than the ones you measured. Every sample, then, produces a slightly too-small spread estimate.

Dividing by n − 1 instead of n scales it back up, and it's not a hack: it's the exact correction for this bias, provable with a page of algebra. The correction shrinks as n grows — with 200 values the difference between n and n − 1 is under 1% — which is why it matters most in small-sample work, labs, and A/B tests with a few hundred users.

Reading the number: the 68-95-99.7 rule

For roughly bell-shaped data, the SD slices the distribution into predictable bands: about 68% of values fall within one SD of the mean, 95% within two, 99.7% within three. Mean 70, SD 5 on an exam, and roughly 95% of scores landed between 60 and 80.

The rule also flags outliers: a value 3+ SDs out is either a genuinely rare event or a data error, and either way it deserves a look. That's the practical use — SD turns "this number looks weird" into "this number is 4.2 SDs from the mean, probability well under 1 in 10,000 if the data is normal."

One caution: the rule assumes symmetry. Income, house prices, and website traffic are skewed right, so the mean gets dragged toward the tail and the bands sit lopsided. For skewed data, report the median and quartiles alongside — or instead.

Common mistakes, ranked by how often they cost points

Related reading: the average calculator handles the mean step (plus weighted averages), and the percentage change calculator covers the other spread-flavored question people bring to data — how much something moved between two points.

Advertisement

Frequently Asked Questions

What are the steps to calculate standard deviation?

1) Find the mean. 2) Subtract the mean from each value (deviations). 3) Square each deviation. 4) Average the squares — dividing by n for a population or n − 1 for a sample. That's the variance. 5) Take the square root. For 4, 8, 15, 16, 23, 42 the mean is 18, squared deviations total 910, population variance is 151.67, and SD is 12.32.

Why divide by n − 1 for a sample?

Bessel's correction. Deviations measured from the sample's own mean are systematically too small — the sample mean is, by construction, the single number closest to those exact points — so dividing by n would understate the population's spread. Dividing by n − 1 removes the bias. With tiny samples the correction is large: at n = 3 it inflates the variance by 50%.

Is standard deviation the same as variance?

Variance is the average squared deviation; SD is its square root, taken to return to the original units. If test scores have a variance of 225 points², the SD is 15 points. Report SD when humans will read the number; variance shows up inside most further statistics (standard error, t-tests, ANOVA).

What does a standard deviation of 0 mean?

Every value in the data set is identical. There is no spread at all, every deviation from the mean is zero, and both the population and sample SD formulas return 0. It cannot be negative — squared deviations can't sum below zero.

Related Tools