Why We Divide by n − 1
The Problem
Suppose we observe i.i.d. samples from a random variable with unknown mean and variance . We want to estimate
If we knew the true mean , the obvious estimator would be
It varies from one dataset to another, but it is correct on average:
The problem is that is unknown. The natural replacement is the sample mean
Plugging into the same formula gives the estimator we want to understand:
This looks like the known-mean estimator with one reasonable substitution. Yet it underestimates on average. The standard correction replaces in the denominator with .
Why does estimating the mean cost exactly one? We did not remove an observation. We used all of them. The missing piece is that was chosen from those same observations, and it was chosen to make their squared deviations as small as possible.
Variance as an Optimization Problem
To see that choice explicitly, let be any candidate center and define
Here is a free variable. For every value of , the function returns the average squared distance of the observations from that center. Evaluating it at the true mean gives the known-mean estimator, . Evaluating it at the sample mean gives the plug-in estimator introduced above:
The useful question is therefore not merely whether estimates well. It is: how was selected, and what does that selection do to ?
Indeed, is exactly the value of that minimizes . Differentiate with respect to :
Since is a quadratic with second derivative , this critical point is the unique minimum.
is not just an estimate of . It is the point that makes the squared deviations as small as possible on this dataset. Therefore
Try it yourself. Drag across the axis and watch change. Notice it always bottoms out at .
That is the sample-by-sample comparison we need. The true mean usually does not land exactly at the dataset’s minimizer , so replacing with can only move us downward on the curve.
Bias is still a statement about expectations, not about one dataset. Since for every dataset and is unbiased for , we have , with strict inequality whenever . The next section computes the exact gap.
Computing the Bias
So far we know the sign of the bias: the expectation of is too small.
Now we compute exactly how small. The trick is to compare and directly. Expand around , then average over . The cross-term vanishes because .
The important thing is not that this expansion is clever. The important thing is that it expands around the value chosen by the optimization problem. That is why one term disappears instead of becoming another nuisance term to carry around.
Two things stand out. First, the identity in line 1 is exact, not a Taylor approximation, so the gap in line 3 is precisely the squared error of as an estimator of . Second, the last step uses (the sample mean is unbiased): under that condition, is exactly the variance of the estimator .
All that’s left is to plug in a specific value for . Since is an average of independent draws each with variance , we get .
The in the denominator of comes from averaging independent samples. The more data we have, the less wobbles, and the less we underestimate.
The expectation of is too small by a factor of . Rescaling by the reciprocal cancels the inside and gives the familiar unbiased estimator .
See the bias in action. Draw repeated samples and watch the two estimators converge.
One Parameter, One Sample Lost
Notice something striking about the bias . Our estimator is an average of terms, each with expectation :
So itself has expectation , but falls short by . That gap is exactly one term’s worth of variance, averaged out.
Why exactly one, and not some data-dependent fraction? Our derivation gave the right number for this particular case (, the sample mean), but it leaned on a clean algebraic identity, , that doesn’t obviously extend to fitting more parameters. If we tried the same calculation for simple linear regression, the analogous identity wouldn’t be so clean: the Hessian of the regression loss has data-dependent entries.
So we don’t yet have a general reason for the "" to come out as an integer. The parameter-counting hint above (“the counts the parameter we fit”) is suggestive, but we have not justified it. In the next post we use the projection view of ordinary least squares (OLS), with the hat matrix making that projection explicit. For a correctly specified, full-rank linear least-squares model, the cost of fitting coefficients is the dimension of the subspace onto which OLS projects. That dimension is , and it explains the "" in as the intercept-only special case.
The Takeaway
To collect the whole post in two formulas: the naive estimator, evaluated at the fitted center , is biased low,
so one should instead use the rescaled, unbiased sample variance
This corrected estimator requires . With only one observation, the residual sum of squares is zero and there is no remaining information with which to estimate the population variance.
References
The result itself is fairly well known and appears, usually without attribution, in most statistics textbooks. Two good places to find it:
- Casella, G. & Berger, R. L. (2002). Statistical Inference (2nd ed.). Duxbury. The unbiasedness of is Theorem 5.2.6; unbiasedness as an evaluation criterion is developed in Chapter 7.
- Wasserman, L. (2004). All of Statistics. Springer. Point estimation is covered in Chapter 6.