A student types five numbers into a spreadsheet and gets 2.74. A classmate enters the same five numbers into a short script and gets 2.45. Both check their typing twice. Nothing is wrong with either entry, and neither program has a bug.
The two results answer two different questions. One describes the spread of exactly those five values. The other estimates the spread of a larger group that those five values were drawn from. The arithmetic differs by a single step, and knowing which step is enough to settle most arguments about whose answer is right.
What Standard Deviation Measures
Standard deviation summarizes how far values tend to sit from their average. A small result means the numbers cluster tightly. A large one means they are scattered. It is reported in the same units as the data, so a set of commute times measured in minutes has a standard deviation in minutes.
The calculation starts with the mean. You subtract the mean from each value, square each of those gaps, and add the squares together. Squaring removes the negative signs, which would otherwise cancel the positive ones and leave zero every time. It also gives large gaps more weight than small ones.
You then divide that total by a count to get the variance, and take the square root to return to the original units. The whole disagreement lives in the choice of count.
One Data Set, Two Results
Take the values 12, 15, 11, 14 and 18. Suppose they are the minutes five recent bus trips took. The sum is 70 and the mean is 14.
The gaps from the mean are -2, 1, -3, 0 and 4. Their squares are 4, 1, 9, 0 and 16, which add to 30. Up to this point every method agrees.
The population version divides 30 by 5, giving a variance of 6 and a standard deviation of about 2.45. The sample version divides 30 by 4, giving a variance of 7.5 and a standard deviation of about 2.74. Same data, same squared gaps, different divisor.
| Version | Divisor | Variance | Standard deviation |
|---|---|---|---|
| Population | n = 5 | 6.0 | 2.45 |
| Sample | n - 1 = 4 | 7.5 | 2.74 |
The sample figure is always the larger of the two whenever the values are not all identical. You can use that as a quick way to identify which one you are looking at when you have both.
Population or Sample: the Question to Ask
The choice depends on what you want the number to describe. If your list contains every member of the group you care about, it is a population. If your list is a portion that stands in for something bigger, it is a sample.
A teacher who wants the spread of scores for the 28 students in one class, and has all 28 scores, is describing a population. A researcher who tests 28 students in order to say something about every student in a district is working with a sample.
The numbers on the page can be identical in both cases. The difference is in the claim you plan to make. That is why no program can pick the correct version for you. It sees the values, not your intentions.
The bus example is a sample. Five trips are not every trip that route will ever make. If you want to know how variable the route usually is, divide by 4.
Photo by Seyd Designer on Pexels
Why Dividing by n Runs Low
When you measure gaps from the sample mean, you are measuring from the point that sits closest to those particular values. The sample mean is the number that makes the sum of squared gaps as small as it can be. The true mean of the wider group is almost always somewhere else.
Measured from the true mean, the same values would show a total squared gap at least as large, and usually larger. So dividing the smaller total by n produces a variance that tends to fall short of the real one. The shortfall is not bad luck in one data set. It happens on average, across repeated sampling.
Dividing by n minus 1 instead of n inflates the result by exactly the amount needed to correct that average shortfall in the variance. The adjustment is known as Bessel's correction.
There is one fine point. The correction makes the variance estimate unbiased. Taking a square root afterward leaves the standard deviation slightly low on average. For most practical work that leftover is small and ignored, but it is real, especially with very few observations.
The One Value That Is Not Free
A second way to see the divisor involves counting how much independent information you have. The five gaps from the mean must add to zero. Once you know four of them, the fifth is fixed.
In the bus data, if the first four gaps are -2, 1, -3 and 0, they sum to -4. The last gap has no choice but to be 4. Only four of the five gaps can vary freely.
Statisticians call that count the degrees of freedom. Estimating the mean from the data used one of them up, leaving n minus 1 for estimating the spread. The same bookkeeping appears later in t-tests and regression, where each estimated quantity costs another degree of freedom.
How Much the Gap Matters at Different Sizes
The sample result equals the population result multiplied by the square root of n divided by n minus 1. That factor depends only on the number of values, not on what they are.
| Number of values | Sample result is larger by about |
|---|---|
| 2 | 41 percent |
| 5 | 12 percent |
| 10 | 5 percent |
| 30 | 1.7 percent |
| 100 | 0.5 percent |
| 1000 | 0.05 percent |
With thousands of rows, the two versions agree to the first few digits and the choice rarely changes a decision. With five or ten measurements, it can change a reported figure noticeably. Small studies, pilot tests and classroom labs sit right in the range where it matters.
A larger factor does not mean small samples become trustworthy once corrected. Five bus trips still tell you little. The correction removes a predictable tilt, while the random uncertainty from having only five observations stays.
What Your Software Does by Default
Defaults are where most of the confusion comes from, because popular tools do not agree. In spreadsheets, functions with an S suffix such as STDEV.S use the sample formula, and STDEV.P uses the population formula. The older STDEV name behaves like the sample version. Microsoft's Excel support pages document each one.
Python users meet both conventions. The built-in statistics module offers stdev for samples and pstdev for populations. NumPy's std function divides by n unless you pass ddof=1, while the pandas std method divides by n minus 1 unless you tell it otherwise. Two lines of code on the same column can disagree for that reason alone.
R's sd function uses n minus 1. Many handheld calculators show both, often labeled Sx for the sample value and a lowercase sigma for the population value. Reading the wrong line on that screen is an easy mistake during a timed test.
Photo by Tima Miroshnichenko on Pexels
A Two Number Check for Any Tool
When a program does not say which formula it uses, feed it the values 1 and 3. The mean is 2 and the squared gaps add to 2.
A result of 1 means the tool divided by 2, the population formula. A result of about 1.414 means it divided by 1, the sample formula. The test takes a few seconds and removes the guesswork.
It also helps to look for a tool that prints both. The statistics calculator on this site takes a pasted list and returns sample and population variance and standard deviation together, along with the mean, median and quartiles. Seeing the two side by side makes it obvious which one a textbook answer or a coworker's report was using.
Mistakes That Follow From Mixing Them
Comparing two groups with different formulas can create a difference that does not exist. If last month's figure came from a spreadsheet and this month's from a script with population defaults, the process may appear to have become more consistent when nothing changed.
Rounding too early causes a related problem. Keep several decimal places through the squared gaps and the division, and round only the final figure. Rounding the mean to a whole number first can shift the result in small data sets.
Another error is using the standard deviation where the standard error belongs. Standard deviation describes how spread out individual values are. Standard error describes how uncertain the mean is, and it is found by dividing the sample standard deviation by the square root of n. The second number shrinks as you collect more data. The first does not shrink systematically.
Writing the Number So Others Can Check It
State which version you used. A line such as "mean 14 minutes, sample standard deviation 2.7 minutes, n = 5" tells a reader everything needed to reproduce it. Leaving out the count hides how fragile the figure might be.
Consider whether standard deviation is the right summary at all. A single extreme value can enlarge it dramatically. For skewed data such as incomes, house prices or response times, report the median and the interquartile range alongside it, or in place of it. The NIST engineering statistics handbook covers these measures of spread and when each behaves well.
If you want to practice on other number problems, the full tools directory groups the math and science calculators together, and the EvvyTools blog has more explainers on why results that look like they should match sometimes do not. You can also browse the free calculators from EvvyTools when a hand calculation needs a second opinion.
A Short Way to Decide
Ask whether your list is the whole group or a piece of it. If it is the whole group and you will not generalize beyond it, divide by n. If it stands in for anything larger, divide by n minus 1.
When you are unsure, the sample version is the usual choice in research and quality work, because measured data seldom covers every case that matters. Whatever you pick, name it next to the number. The student and the classmate from the opening were both right, and one short label on each answer would have shown it.