How to Calculate Standard Deviation (Step by Step)
Standard deviation measures how spread out a set of numbers is. Find the mean, work out how far each value sits from that mean, square those distances, average them, then take the square root of the result. There are two versions of this formula: a sample version that divides by n-1, and a population version that divides by n. Which one applies depends on whether your data is the whole group you care about or just a slice of it.
Why it matters
The mean tells you where a dataset is centered. It says nothing about how consistent the values are. Two classes can score the same average on a test and still describe completely different situations for a teacher.
Take two groups of five test scores, both averaging exactly 70:
| Scores | Mean | Population SD | Sample SD | |
|---|---|---|---|---|
| Class A | 68, 70, 72, 70, 70 | 70 | 1.26 | 1.41 |
| Class B | 50, 90, 60, 80, 70 | 70 | 14.14 | 15.81 |
Class A’s scores cluster tightly around 70. Every student landed within two points of the average, so the standard deviation is small. Class B has the same mean, but the individual scores range from 50 to 90. Some students clearly struggled, others aced it, and the average of 70 hides that gap entirely. A teacher looking only at the mean would think the two classes performed identically. The standard deviation shows they didn’t.
Population vs. sample: which formula to use
Both formulas start the same way: subtract the mean from each value, square the result, and add up the squares. They differ only in what you divide by.
Population standard deviation divides the sum of squared deviations by n, the total count of values. Use this when your dataset already includes everyone or everything you’re studying, such as the test scores of every student in one specific class, or the weight of every box a machine produced in a single shift.
Sample standard deviation divides by n-1 instead of n. Use this when your data is a subset drawn from a larger population and you’re trying to estimate that population’s spread from a smaller batch, like polling 200 voters to estimate an entire electorate, or measuring 10 boxes out of a day’s production run of 50,000. Dividing by a smaller number (n-1) inflates the result slightly, which corrects for the fact that a sample tends to underestimate the true variability of the group it came from. Statisticians call this Bessel’s correction.
If you’re unsure which applies, ask whether more data of the same kind exists beyond what you’re holding. If yes, you’re almost certainly working with a sample.
Worked example: checking cereal box weights
A factory targets 500 grams per cereal box. Quality control pulls ten boxes off the line and weighs each one, in grams:
498, 502, 501, 497, 503, 500, 499, 502, 496, 501
Step 1: Find the mean. Add the ten weights: 498 + 502 + 501 + 497 + 503 + 500 + 499 + 502 + 496 + 501 = 4999. Divide by 10: mean = 499.9 grams. The heaviest box is 503g and the lightest is 496g, a range of 7 grams.
Step 2: Find each deviation and square it.
| Box | Weight (g) | Deviation from mean | Squared deviation |
|---|---|---|---|
| 1 | 498 | -1.9 | 3.61 |
| 2 | 502 | 2.1 | 4.41 |
| 3 | 501 | 1.1 | 1.21 |
| 4 | 497 | -2.9 | 8.41 |
| 5 | 503 | 3.1 | 9.61 |
| 6 | 500 | 0.1 | 0.01 |
| 7 | 499 | -0.9 | 0.81 |
| 8 | 502 | 2.1 | 4.41 |
| 9 | 496 | -3.9 | 15.21 |
| 10 | 501 | 1.1 | 1.21 |
Step 3: Sum the squared deviations. Adding the last column: 3.61 + 4.41 + 1.21 + 8.41 + 9.61 + 0.01 + 0.81 + 4.41 + 15.21 + 1.21 = 48.9.
Step 4: Divide and take the square root. These ten boxes are a sample pulled from a much larger production run, so both readings are worth knowing. If you treated the ten boxes as the entire population, you’d divide by 10: variance = 48.9 / 10 = 4.89, and standard deviation = √4.89 ≈ 2.21 grams. Treating them as a sample of a larger run, you divide by n-1 = 9: variance ≈ 48.9 / 9 = 5.43, and standard deviation = √5.43 ≈ 2.33 grams.
Either way, the result tells the quality team something the mean alone can’t: most boxes fall within about 2 to 2.3 grams of 499.9g, so the process is running tight and close to target, without a single outlier skewing the picture.
Calculate with your own numbers
Paste your own list of values below and get the mean, both standard deviations, and variance instantly.
Separate values with commas, spaces or new lines.
Enter at least one number to see the results.
- Count (n)
- —
- Sum
- —
- Mean (average)
- —
- Minimum
- —
- Maximum
- —
- Range
- —
Common mistakes
Averaging the raw deviations instead of squaring them first. If you subtract the mean from each value and average those differences directly, you’ll always get zero, because the negative and positive deviations cancel out by definition. Squaring first is what makes the spread show up as a positive number.
Reporting variance as if it were the standard deviation. Variance is the average of the squared deviations; standard deviation is its square root. They’re in different units too. If you’re measuring grams, variance comes out in grams squared, which is meaningless on its own. Forgetting the final square-root step is one of the most common errors in a hand calculation.
Dividing by n when the data is a sample. Using n instead of n-1 for a sample understates how spread out the true population likely is, especially with small datasets. The difference between dividing by 9 and dividing by 10 might look tiny for ten boxes, but it grows more noticeable the smaller your sample gets.
Mixing up which formula a tool or textbook is using. Some calculators default to population SD, others to sample SD, and a mismatch can make two “correct” answers look like one of them is wrong. Always check which divisor is being applied before comparing results across sources.
Frequently asked questions
What’s the actual difference between sample and population standard deviation? Population standard deviation divides the sum of squared deviations by n (the full count). Sample standard deviation divides by n-1. The sample version is always slightly larger for the same data, because dividing by a smaller number produces a bigger result. Use population SD only when your dataset is the complete group you’re studying; use sample SD whenever it’s a subset meant to estimate something larger.
What counts as a “low” or “high” standard deviation? It depends entirely on the scale and context of what you’re measuring. A standard deviation of 2 grams is tight for cereal box weights but would be enormous for measuring the weight of a single grain of rice. A useful way to judge it is relative to the mean: a standard deviation that’s a small fraction of the mean suggests tightly clustered data, while one that’s a large fraction suggests wide variability. There’s no universal cutoff that applies to every dataset.
Can standard deviation be negative? No. Because every deviation gets squared before being averaged, the result inside the square root can never be negative, and a square root itself is defined as non-negative. The smallest possible standard deviation is zero, which happens only when every value in the dataset is identical.
How does standard deviation relate to variance? Variance is the average of the squared deviations from the mean. Standard deviation is simply the square root of variance. They measure the same underlying spread, but standard deviation is usually more useful for everyday interpretation because it’s expressed in the same units as the original data (grams, dollars, points), while variance is expressed in squared units that don’t map cleanly back to anything physical.