Week 04 · Bias, variance, and mean squared error

Choose a variance estimator according to the error you care about.

Watch on YouTube

← Week 3 · Subject contents · Week 5 →

Choose a variance estimator according to the error you care about.

Work through the problem

For independent draws from a population of variance σ², the expected sum of squared deviations from the sample mean is (n−1)σ². To see where the missing degree of freedom goes, expand Σ(Xᵢ−X̄)² = Σ(Xᵢ−μ)² − n(X̄−μ)² and take expectations. Dividing by n−1 is unbiased. Dividing by n produces bias −σ²/n.

Mean squared error is Var(T) + Bias(T)². For normal samples at n = 5 and σ² = 1, the unbiased estimator has variance 2/4 = 0.50. Scaling it by 4/5 gives variance 0.32 and squared bias 0.04, for MSE 0.36. The smaller-MSE choice here relies on the stated distribution and loss.

Run the Python lab

import numpy as np
x = np.random.default_rng(33).normal(size=(30000, 5))
for ddof in [0, 1]:
    estimates = x.var(axis=1, ddof=ddof)
    mse = np.mean((estimates - 1)**2)
    print(ddof, round(estimates.mean() - 1, 3), round(mse, 3))
    assert abs(mse - {0: .36, 1: .50}[ddof]) < .035

Output from the lab

0 -0.204 0.359
1 -0.005 0.496

Practice

  1. Which estimator has lower MSE for this normal experiment?

Check your reasoning

  1. The n divisor. Its smaller variance outweighs its squared bias.

← Week 3 · Subject contents · Week 5 →

Further reading · MIT 18.650 · Statistics for Applications