Sample variance: why n − 1?
About this app
Variance and standard deviation as a game: six people at a height chart say their height, every deviation arrow unfolds into a square, all squares go onto one pile, the pile is cut into n − 1 equal strips, one strip is s², its side is s. Then thousands of samples from 400 body heights: the mean of all s² lands on σ², with ÷ n it stays too low by σ²/n.
With explain mode: an AI tutor walks you through the app, points out what matters in the scene and answers your questions.
The idea
Variance measures how far values are from the mean on average, squared: the deviations alone always add up to zero, and large distances should count more. The standard deviation is its square root and has the unit of the data again. When you estimate the variance from a sample, you divide the sum of squares by n − 1. The reason: the sample mean x̄ always sits in the middle of its own data, and about the true μ the squares would be larger. On average exactly one σ² is missing, so E(Σ(xᵢ − x̄)²) = (n − 1)·σ². That makes s² unbiased.
What the app shows
In the height game six people stand at a height chart: 166, 183, 172, 189, 161 and 179 cm, mean 175. Each deviation arrow unfolds into a real square, the squares stack up area-true to 562 cm², and the column is cut into five strips. One strip is s² = 112.4 cm²; shaped as a square its side is s = 10.6 cm. Measured about μ = 172 it would be 616 cm². In the second scene thousands of samples are drawn from 400 body heights: the running mean of the estimates with n − 1 lands on σ² = 80.5, with n it stays at (n − 1)/n · σ².
What you can try
Step through the game with “Next” and drag a head: the person grows or shrinks, and squares and sum update. Switch between dividing by n − 1 and by n and show the true μ. In the second scene draw one sample and watch the points fly out of the crowd, then a hundred or a thousand at once. Set n to 2: dividing by n only hits half. At n = 30 the gap gets small but does not vanish.
Frequently asked questions
- Why do we divide by n − 1 in the sample variance?
- Because the deviations from the sample mean x̄ are smaller on average than those from the true mean μ. Σ(xᵢ − μ)² = Σ(xᵢ − x̄)² + n·(x̄ − μ)², and the last piece is exactly σ² on average. The sum of squares about x̄ therefore has expected value (n − 1)·σ², and only dividing by n − 1 hits σ² on average.
- What does unbiased mean?
- An estimator is unbiased if its expected value equals the quantity it estimates. If you repeat the sample very often, the average of all estimates lands on the true value. The sample variance with n − 1 is unbiased for σ²; with n it is too low by σ²/n on average.
- What is the difference between variance and standard deviation?
- The variance is the average of the squared deviations from the mean and has the squared unit, cm² for body heights. The standard deviation is its square root and has the unit of the data again, cm. For bell-shaped data about two thirds of the values lie within mean ± standard deviation.
- What can I change in the app?
- In the height game the steps from the mean to the square root, dividing by n − 1 or n, the comparison with the true μ, the number of people and every single height by dragging a head. In the samples scene the sample size n from 2 to 30, drawing one, a hundred or a thousand samples, and the cloud of single estimates.
Subject: Statistics
More from Statistics
- Anscombe's quartet
- Bias-variance / overfitting
- Box plot workshop
- Geometric mean
- Law of large numbers
- Histogram workshop
- Hypothesis test & p-value
- Confidence interval
A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps