---
tag: 0JN9P4A944
kind: definition
name: Sample variance
msc: [62F10]
defines: 0NHXGY2C5J
uses: [0QNRBHWV35, 007QED3E0Y, 036756NFD6, 01BD2TFFP4]
sources:
  - url: https://en.wikipedia.org/wiki/Bessel's_correction
    locator: Formulation
---

## Definition

Let $n \ge 2$ and let $X_1, \dots, X_n$ be real random variables with [[sample mean|0QNRBHWV35]] $\bar{X}_n$.
The sample variance is the [[statistic|036756NFD6]]
$$S_n^2 = \frac{1}{n - 1} \sum_{i=1}^{n} \left(X_i - \bar{X}_n\right)^2.$$
The sample standard deviation is $S_n = \sqrt{S_n^2}$.

## Remarks

If the $X_i$ are i.i.d. with [[variance|007QED3E0Y]] $\sigma^2 < \infty$, then $E[S_n^2] = \sigma^2$. So $S_n^2$ is an unbiased estimator of $\sigma^2$.
The divisor $n - 1$ instead of $n$ is Bessel's correction. The version with divisor $n$ has expectation $\frac{n-1}{n} \sigma^2$, so it has the [[bias|01BD2TFFP4]] $-\sigma^2/n$.
The reason is that $\sum_i (X_i - \bar{X}_n)^2 \le \sum_i (X_i - \mu)^2$: the deviations from $\bar{X}_n$ are on average smaller than those from the true mean $\mu$.
For i.i.d. $\mathcal{N}(\mu, \sigma^2)$ variables, $(n - 1) S_n^2 / \sigma^2$ has the chi-squared distribution with $n - 1$ degrees of freedom, and it is independent of $\bar{X}_n$.



## Explanations

### L1 human

The sample variance is the average squared distance of the data from their mean, but with the divisor $n - 1$.
For the data $4$, $7$, $10$, the mean is $7$, the squared deviations add up to $18$, and the sample variance is $18/2 = 9$.
