Population and Sample Standard Deviation Use Different Divisors

Three small stacks of wooden counters on a mathematics desk.
Conceptual illustration created with AI; not a research result or laboratory photograph.

Two programs can report different standard deviations for the same three values without either performing the arithmetic incorrectly. Their defaults may answer different statistical questions.

Work through 2, 4 and 6

The mean is 4. Deviations from it are −2, 0 and 2; their squares total 8. Treating these three observations as the complete population gives a variance of 8/3 and a standard deviation of about 1.633.

With the usual sample-variance correction, divide by 3 − 1 instead. The variance becomes 4 and its square root is 2. The observations did not change; the divisor did.

import numpy as np
x = [2, 4, 6]
np.std(x, ddof=0)  # approximately 1.633
np.std(x, ddof=1)  # 2.0

The NumPy documentation defines the divisor as N minus ddof. It also explains an important limit: the correction makes the variance estimator unbiased under the relevant sampling assumptions, but taking its square root does not make standard deviation itself an unbiased estimator.

Put the choice in the method note

Record whether you are describing the complete set of interest or using a sample to estimate a wider population’s variability. Include the function, settings and missing-value treatment. If one observation is all you have, the N − 1 calculation has a zero divisor; a software warning is not a mysterious property of that observation. Resolve the method before rounding the output for a chart.

AI-generated editorial illustration; not a documentary photograph.