Sample Variance and Standard Deviation

Estimates the spread of a population from a sample. Dividing by count − 1 instead of the count gives the unbiased sample variance. At least two values are needed.

When your data is a sample drawn from a larger population, the unbiased sample variance is what estimates that population's spread.

s2=1n1i=1n(xixˉ)2s=s2s^2 = \dfrac{1}{n - 1}\sum_{i=1}^{n} (x_i - \bar{x})^2 \qquad s = \sqrt{s^2}

The key is dividing by n1n - 1 rather than nn. That quantity is called the number of degrees of freedom.

Why n − 1

The deviations are measured from the sample mean xˉ\bar{x}, and the sample mean sits as close to its own data as possible. The sum of squared deviations therefore comes out systematically too small compared with measuring from the true population mean.

Dividing by nn would understate the population variance. Dividing by the slightly smaller n1n - 1 cancels that bias exactly, so that on average the estimate is right. That is what "unbiased" means.

Example

For 10, 20, 30, 40, 50 the mean is 30 and the sum of squared deviations is 400+100+0+100+400=1000400 + 100 + 0 + 100 + 400 = 1000.

s2=100051=250s=250=15.8114s^2 = \dfrac{1000}{5 - 1} = 250 \qquad s = \sqrt{250} = 15.8114

Dividing by nn instead would have given a variance of 200 and a standard deviation of 14.1421. The unbiased estimate is a little larger.

Which one to use

When in doubt, use the sample variance. Nearly every statistics package defaults to n1n - 1.