Why We Divide by n-1 in Sample Variance
You have i.i.d. samples $X_1, \ldots, X_n$ from a distribution with mean $\mu$ and variance $\sigma^2$. The sample variance is defined as
$$S^2 = \frac{1}{n-1}\sum_{i=1}^{n}(X_i - \bar{X})^2$$
Prove that $E[S^2] = \sigma^2$ -- that is, dividing by $n-1$ instead of $n$ makes $S^2$ an unbiased estimator of the population variance.
As part of your proof, give a clear explanation of why the factor is $n-1$ and not $n$ in terms of degrees of freedom.
Hints
- Try writing $X_i - \bar{X}$ as $(X_i - \mu) - (\bar{X} - \mu)$ and expanding the square. What happens to the cross term?
- You will need $\text{Var}(\bar{X}) = \sigma^2/n$. This is the key fact that produces the correction factor.
- After expanding, the sum telescopes to $\sum(X_i - \mu)^2 - n(\bar{X} - \mu)^2$. Take expectations of each piece separately.
Worked Solution
How to Think About It: This is one of the most common interview questions in statistics, and it separates people who memorize from people who understand. The key tension is simple: we want to estimate $\sigma^2 = E[(X - \mu)^2]$, but we do not know $\mu$, so we substitute $\bar{X}$. The problem is that $\bar{X}$ is closer to the data than $\mu$ is -- it was literally chosen to minimize $\sum (X_i - \bar{X})^2$. So measuring deviations from $\bar{X}$ systematically underestimates the true spread. Dividing by $n-1$ instead of $n$ corrects for exactly that bias.
Quick Estimate: Take $n = 2$ to see the effect starkly. Two draws $X_1, X_2$ with $\bar{X} = (X_1 + X_2)/2$. Then $\sum(X_i - \bar{X})^2 = 2 \cdot ((X_1 - X_2)/2)^2 = (X_1 - X_2)^2 / 2$. Now $E[(X_1 - X_2)^2] = 2\sigma^2$, so $E[\sum(X_i - \bar{X})^2] = \sigma^2 = (2-1)\sigma^2$. If you divided by $n = 2$, you would get $\sigma^2/2$ -- biased by a factor of 2. Dividing by $n-1 = 1$ gives $\sigma^2$. The bias is worst for small $n$ and vanishes as $n \to \infty$.
Approach: The standard proof adds and subtracts $\mu$ inside the squared term, then uses linearity of expectation and the known variance of the sample mean.
Formal Solution:
Start by decomposing each deviation from $\bar{X}$ into a deviation from $\mu$:
$$X_i - \bar{X} = (X_i - \mu) - (\bar{X} - \mu)$$
Square and sum over $i$:
$$\sum_{i=1}^{n}(X_i - \bar{X})^2 = \sum_{i=1}^{n}\left[(X_i - \mu) - (\bar{X} - \mu)\right]^2$$
Expand the square:
$$= \sum_{i=1}^{n}(X_i - \mu)^2 - 2(\bar{X} - \mu)\sum_{i=1}^{n}(X_i - \mu) + n(\bar{X} - \mu)^2$$
Notice that $\sum_{i=1}^{n}(X_i - \mu) = n(\bar{X} - \mu)$, so the cross term equals $-2n(\bar{X} - \mu)^2$. This gives:
$$\sum_{i=1}^{n}(X_i - \bar{X})^2 = \sum_{i=1}^{n}(X_i - \mu)^2 - n(\bar{X} - \mu)^2$$
Now take expectations of both sides. Since $E[(X_i - \mu)^2] = \sigma^2$ for each $i$:
$$E\left[\sum_{i=1}^{n}(X_i - \mu)^2\right] = n\sigma^2$$
And since $\text{Var}(\bar{X}) = \sigma^2/n$:
$$E\left[n(\bar{X} - \mu)^2\right] = n \cdot \frac{\sigma^2}{n} = \sigma^2$$
Putting it together:
$$E\left[\sum_{i=1}^{n}(X_i - \bar{X})^2\right] = n\sigma^2 - \sigma^2 = (n-1)\sigma^2$$
Therefore:
$$E[S^2] = E\left[\frac{1}{n-1}\sum_{i=1}^{n}(X_i - \bar{X})^2\right] = \frac{(n-1)\sigma^2}{n-1} = \sigma^2$$
Degrees of Freedom Interpretation: The $n$ deviations $X_i - \bar{X}$ are not independent -- they satisfy the constraint $\sum_{i=1}^{n}(X_i - \bar{X}) = 0$. So there are only $n-1$ free pieces of information about spread. Equivalently, estimating $\mu$ by $\bar{X}$ "uses up" one degree of freedom. The factor $n-1$ in the denominator accounts for this lost degree of freedom.
Answer: By expanding $\sum(X_i - \bar{X})^2 = \sum(X_i - \mu)^2 - n(\bar{X} - \mu)^2$ and taking expectations, the sum of squared deviations from the sample mean has expectation $(n-1)\sigma^2$, not $n\sigma^2$. The "missing" $\sigma^2$ comes from $E[n(\bar{X} - \mu)^2] = \sigma^2$ -- the cost of estimating the mean from the same data. Dividing by $n-1$ corrects for this, yielding $E[S^2] = \sigma^2$.
Intuition
The deeper lesson here is about the cost of estimation. Whenever you estimate a parameter from data and then use that same estimate to compute residuals, the residuals are systematically too small. The sample mean $\bar{X}$ is literally the point that minimizes $\sum(X_i - c)^2$ over all $c$, so deviations from $\bar{X}$ are guaranteed to be smaller than deviations from the true $\mu$. Bessel's correction ($n-1$ instead of $n$) is the simplest instance of a general principle: you lose one degree of freedom for every parameter you estimate from the data before computing residuals.
This principle shows up constantly in practice. In linear regression with $p$ predictors, the unbiased variance estimate divides by $n - p - 1$, not $n$. In time series, fitting an AR(p) model costs $p$ degrees of freedom. The common interview mistake is to just say "degrees of freedom" without explaining why -- the proof above shows exactly where the $n-1$ comes from: the subtracted term $n(\bar{X} - \mu)^2$ has expectation $\sigma^2$, which is the precise cost of not knowing $\mu$.