Two Buttons, Two Answers, One Dataset
Type the same numbers into a spreadsheet and two functions give two different standard deviations. A calculator offers σ and s. A programming library quietly picks one for you. Students ask which is “right”, and many guess. The wrong guess shifts a result by a predictable amount, and on small datasets that shift is large.
This guide explains the difference in plain terms, shows why dividing by n − 1 exists, and measures its effect with 500,000 simulated samples. It also lists what common software does by default, which is where many silent errors begin.
Population and Sample: The Two Definitions
Population. Every member of the group you want to describe, such as all 30 students in one class. A number that describes a population is called a parameter.
Sample. A subset used to learn about a larger population, such as 30 students drawn from a whole school. A number computed from a sample is called a statistic.
Population standard deviation. σ = √(Σ(x − μ)² ÷ N), where μ is the population mean and N the number of values.
Sample standard deviation. s = √(Σ(x − x̄)² ÷ (n − 1)), where x̄ is the sample mean and n the sample size. Dividing by n − 1 is called Bessel’s correction.
One Dataset, Both Ways
Take four values: 3, 5, 7 and 9. The mean is 6. The squared deviations are 9, 1, 1 and 9, which sum to 20.
Treated as a population (N = 4): variance 20 ÷ 4 = 5, so σ = 2.236.
Treated as a sample (n = 4): variance 20 ÷ 3 = 6.667, so s = 2.582.
Same data, same mean, but s is about 15.5% larger than σ. The standard deviation calculator shows both versions side by side, with the steps.
A Second Example: Eight Numbers, Step by Step
Use 2, 4, 4, 4, 5, 5, 7 and 9. The sum is 40, so the mean is 5. The deviations are −3, −1, −1, −1, 0, 0, 2 and 4, and their squares are 9, 1, 1, 1, 0, 0, 4 and 16, which add to 32.
As a population, the variance is 32 ÷ 8 = 4 and σ = 2 exactly. As a sample, the variance is 32 ÷ 7 = 4.571 and s = 2.138, about 6.9% higher. Writing the sum of squares once and dividing it two ways is the cleanest habit, because it shows that the only difference is the divisor.
Why n − 1? The Intuition
A sample’s own mean is, by construction, the point that sits closest to the sample’s values. The true population mean is almost never exactly there. Distances measured from x̄ are therefore slightly smaller than distances measured from μ, so the spread looks smaller than it really is. Dividing by n produces a variance that is too low on average, and dividing by n − 1 stretches it back to the correct size.
The slogan “we lose one degree of freedom” describes the same thing. Once the sample mean is fixed, only n − 1 of the deviations can vary freely, because they must add to zero. The degrees of freedom page gives the general idea.
Measuring the Bias: 500,000 Simulated Samples
Mathvelo drew 100,000 samples at each size from a normal population with standard deviation 10, so the true variance is 100. The table shows the average variance from each formula and the average standard deviation.
| Sample size n | Average variance, divide by n | Average variance, divide by n − 1 | Average s |
|---|---|---|---|
| 2 | 49.7 | 99.4 | 7.95 |
| 3 | 66.5 | 99.7 | 8.85 |
| 5 | 80.2 | 100.2 | 9.41 |
| 10 | 89.8 | 99.8 | 9.72 |
| 30 | 96.5 | 99.8 | 9.90 |
Dividing by n lands near (n − 1) ÷ n of the truth: about 50 for n = 2 and 80 for n = 5. Dividing by n − 1 lands on 100 every time, within simulation noise. That is exactly what “unbiased” means for a variance.
A Surprise: s Is Still a Little Low
The last column is the part most explanations skip. Although the variance is unbiased, the standard deviation is not, because a square root of an average is not the average of square roots. At n = 5, the average s is 9.41 against a true value of 10, about 6% low. At n = 2 it is 7.95, about 20% low. The shortfall fades with size, reaching 1% at n = 30. No simple correction is used in everyday work, so the practical advice is to keep samples reasonably large and to treat small-sample standard deviations as rough.
How Much Does the Choice Matter?
The sample figure is larger than the population figure by a factor of √(n ÷ (n − 1)). For n = 2 that is 1.414, a 41% gap. For n = 5 it is 1.118, about 12%. For n = 30 it is 1.017, under 2%. At n = 100 the gap is about 0.5%. The choice matters most for small datasets, which is exactly where textbook problems and lab experiments live. For a sample of one value, s is undefined, because n − 1 is zero.
Which One Should You Use?
Ask one question: is the dataset the whole group, or a window onto a bigger one? Grades for every student in one class, with no wish to generalise, are a population. Heights of 40 adults used to say something about adults in general are a sample. When unsure, a sample is the safer default, since most real analysis is trying to generalise.
Once s is known, a z-score for a single value uses it. The z-score calculator and the mean, median and mode calculator give the other numbers you will usually want. Reading the result correctly also needs care with percentages, covered in the guide on percentage change versus percentage points.
What Common Tools Do by Default
| Tool | Population (N) | Sample (n − 1) |
|---|---|---|
| Excel and Google Sheets | STDEV.P | STDEV.S |
| Python statistics module | pstdev | stdev |
| NumPy | std (default, ddof=0) | std(ddof=1) |
| pandas | std(ddof=0) | std (default, ddof=1) |
| Scientific calculators | σx or σn | sx or σn−1 |
The trap is that NumPy and pandas disagree about the default. A script that moves from one library to the other changes its answer silently. A spreadsheet explainer such as Statology’s comparison of STDEV.P and STDEV.S shows the same split in Excel, and key labels on calculators vary by brand, so check the manual.
Five Quick Cases
| Situation | Use | Reason |
|---|---|---|
| Test scores of every student in one class, no wider claim | Population | The data is the whole group |
| 50 items checked from a batch of 10,000 | Sample | The batch is the target |
| Salaries of all 12 staff in a small firm | Population | Everyone is included |
| A poll of 800 voters | Sample | Voters in general are the target |
| Three repeat lab measurements | Sample | They estimate the spread of the method |
Where s Goes Next: Standard Error
The sample standard deviation feeds the standard error of the mean, s ÷ √n. With s = 10 and n = 25, the standard error is 2. This is why an accurate s matters: it flows into confidence intervals and tests. A number that is slightly low at small n makes those intervals slightly too narrow, another reason to be cautious with very small samples and to report n alongside any result.
A Quick Mental Check on Any Result
A rough rule says the standard deviation of a moderate-sized, bell-shaped sample is about a quarter of its range. For the eight numbers above, the range is 9 − 2 = 7, so the rule predicts about 1.75, while the true sample value is 2.14. That is the right size, and an answer such as 21.4 or 0.2 would be rejected at once. The rule is rough and works less well for tiny or skewed datasets, but it catches slips such as a forgotten square root. The same estimate-first habit is explained in the guide on how to check a math answer.
Notation varies between books. Some write the sample standard deviation as s, others as σ̂ or σₙ₋₁, and some use SD for both. When the symbol is unclear, look for the divisor in the formula, since the divisor is the only thing that really distinguishes the two.
Common Mistakes
Using the population formula on a small sample understates spread, which makes results look more precise than they are. Using the sample formula on a full population overstates it slightly. Mixing the two inside one calculation, such as a sample variance with a population mean, gives numbers that do not match any textbook. A final slip is forgetting to take the square root, which reports the variance instead of the standard deviation.
What Is Overrated, Underrated and Often Wrong
Overrated: the one-line slogan “we lose a degree of freedom”. It is true but explains little on its own. Underrated: checking which function a tool is using, since it takes seconds and prevents silent differences between programs. Often wrong: the claim that n − 1 makes s unbiased. It makes the variance unbiased, and the simulation above shows s still sits below the truth at small n.
Quick Answers
When should I use n instead of n − 1?
When the data is the entire population you care about, with no intention to generalise.
Is it STDEV.S or STDEV.P for a sample in Excel?
STDEV.S. STDEV.P is for a full population.
Does the choice matter for large datasets?
Little. At n = 100 the two differ by about 0.5%, and the gap keeps shrinking.
Why is the sample standard deviation still biased?
The square root of an unbiased variance is not unbiased, so s tends to run slightly low, especially for small n.
What is the standard deviation of two numbers?
The sample version is |a − b| ÷ √2, and the population version is |a − b| ÷ 2. For 4 and 10, that is 4.24 and 3.
Related Mathvelo Tools
Further Reading and Sources
- Bessel’s correction — Why n − 1 corrects the variance
- Standard deviation — Definitions and the unbiased estimate
- Degrees of freedom (statistics) — The n − 1 intuition
- Statology: STDEV.P vs STDEV.S in Excel — Spreadsheet functions
A note on these guides. Simulation figures come from 100,000 random samples per size using a normal population with standard deviation 10 and a fixed seed. Library defaults were listed from their documented behaviour. Opinions are labelled as opinions. This page is educational and not professional advice.