SStatistics, Built

Stage I · Bachelor's: Foundations

Part 8 of 65

From Sample to Population

Bachelor'sstarts at this level50 min of film14 chaptersprerequisites: Part 4, Part 6, Part 7

How much does an estimate wobble from sample to sample, and how can one sample tell you?

In 1908 a Guinness brewer with four barley plots finds that the normal table lies for small samples. Gosset checks it by hand: 3,000 cards bearing the heights of Macdonell's prisoners, dealt into 750 samples of four. Redone in the film with one seeded shuffle, the interval with 1.96 covers 87.1% of the time and Student's multiplier 3.18 covers 96.7%. The part builds the sampling machine and the standard error, explains the n - 1 as an expectation and as a dimension, and follows Fisher's rotation of the sample, from which the independence of mean and variance, chi-squared, Cochran's theorem, Student's t and the F distribution all fall out. It then weighs bias against variance (the divisor n + 1 beats n - 1 in mean squared error), builds plug-in estimators and Laplace's ratio estimate of the population of France, and corrects for finite populations. It ends by opening the Coverage Board with seven rows, some kept and some broken, and with Box's 1953 warning that the t-test is fairly robust to non-normality while the F-test for variances is not.

What you need. Calculus, and from earlier parts: projections and orthogonal matrices (Part 4), the central limit theorem and the delta method (Part 6), simulation (Part 7).

Hook
Student at Guinness, 1908
Mathematics
sampling distributions, n − 1 as dimension, Fisher's geometry, χ², t, F, MSE, plug-in
Built
Student's card deck; the Board's first rows

What you will be able to do

Bachelor's

  • Compute a standard error and a Student's t interval for a mean, and explain why 1.96 is the wrong multiplier when sigma is estimated from a few observations.
  • Explain the divisor n - 1 two ways: as what makes the sample variance unbiased, and as the dimension of the space the residuals live in.

Master's

  • Derive from Fisher's rotation that for normal samples the mean and variance are independent, with a normal and a scaled chi-squared law, and obtain t and F from them.
  • Derive the delta-method standard error of a ratio of means, and the divisor that minimizes the mean squared error of a variance estimate.

PhD

  • State which normal-theory results survive without normality (the unbiasedness of the sample variance, the asymptotic t) and which do not (independence of mean and variance, the chi-squared law of the variance), with the role of kurtosis.

Practice

  • Read a Coverage Board row: the method, the setting, the achieved coverage with its Monte Carlo error, and the verdict.
  • Plan a sample size with the finite-population correction, and avoid testing variances by an F-test on data that may not be normal.

Contents

Each chapter has a home level. Choose a track to see what to read and watch: Bachelor's 25 min · Master's 50 min · PhD 50 min · Practice 31 min.

  1. 0Student at GuinnessBachelor's4 min
  2. 1Sampling distributionsBachelor's4 min
  3. 2Why n - 1Bachelor's4 min
  4. 3Fisher's geometryMaster's4 min
  5. 4Chi-squared and CochranMaster's4 min
  6. 5Student's tBachelor's4 min
  7. 6The F distributionMaster's3 min
  8. 7Bias, variance, MSEBachelor's4 min
  9. 8Consistency and plug-inMaster's4 min
  10. 9Standard errors for ratiosMaster's4 min
  11. 10Finite populationsPractice3 min
  12. 11The Coverage Board opensBachelor's3 min
  13. 12How robust is normal theory?Practice3 min
  14. Recap, problems, and the road aheadAll tracks3 min

Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · Build the film.

Lecture

The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.

Student at GuinnessBachelor's4 min

In 1899 the Guinness brewery in Dublin hired a young chemist, William Sealy Gosset, to make its beer more consistent. His experiments were small: four plots of barley, a handful of malting trials. And the statistics of the day were built for large samples, where the sample's standard deviation could simply stand in for the true one. With four observations it can't. The standard deviation of four numbers is itself wildly variable, so the usual interval, the mean plus or minus one point nine six standard errors, is too narrow. Guinness let him publish the answer in 1908, but only under a pen name: Student.

Gosset's problems were real ones. In a 1904 report to the Guinness board he set out to apply the law of error to the work of the brewery. His experiments compared barley varieties, hop resins, and yeast, each with only a few runs, because each run was a season's crop or a brew. In 1906 the company sent him to spend a year in Karl Pearson's laboratory in London, where he learned the theory of the day, and saw that it was built for samples of hundreds, not a brewer's handful. The same year he studied counts of yeast cells under a microscope, and rediscovered the Poisson distribution of Part 3.

How do you check a theory of small samples in 1908, with no computer? Gosset used a table published six years earlier by William Macdonell: the heights of three thousand men in English prisons, measured to the inch. He wrote each man's height on a piece of card, three thousand cards. Shuffled them thoroughly. And dealt them out in fours: seven hundred and fifty samples of four men. For each four he computed the mean, the standard deviation, and the ratio of the mean's error to its estimated standard error. It was an early simulation study of a statistical method, done by hand.

Here is the result, redone with one seeded shuffle of the same three thousand heights. The histogram of the seven hundred and fifty ratios is not the normal curve: it's narrower in the middle and much heavier in the tails. The usual interval, with one point nine six, covers the true mean only percent of the time, not ninety-five. Gosset found the right curve, partly by inspired guesswork that Fisher later made rigorous: Student's t distribution with three degrees of freedom, in gold, which follows the histogram. Its multiplier is three point one eight, and with it the interval covers percent. This is a single shuffled, rounded finite population, not an exact normal sampling model; heights were recorded in whole inches. The same experiment on three thousand residents of the World tells the same story. The tails are heavy because, now and then, four men happen to be similar in height, s comes out far too small, and the ratio explodes.

What it does: Gosset's problem; his 1904 brewery report and year with Pearson; Macdonell's heights; 3,000 cards dealt in fours; t against the normal.; Numbers (computed): z-interval covers 87.1%, t₃ 96.7% (heights rounded to inches); World: 85.1% vs 94.4%

1Sampling distributionsBachelor's4 min

Part 1 met the sampling machine; now we use it in earnest. The source pool: three thousand of the World's adult men. The machine draws four at random. Their heights land on the line, and their mean drops into the chart. Another four, another mean. Keep going. The chart that builds up is the sampling distribution of the mean: the distribution of a statistic over all the samples we might have drawn. It's the single most important idea in this course, because every standard error, interval and test is a statement about it.

Now the full sampling distributions, twenty thousand samples each. Means of four men: a wide bell. Means of sixteen: half as wide. Means of sixty-four: half as wide again. The spread falls like sigma over root n, Part 6's square-root law, and the simulated standard deviations closely approximate the formula within simulation noise. And all three are centred on the true mean: the sample mean is unbiased.

This is the miracle of statistics. The spread of the sampling distribution, the standard deviation of the mean over all possible samples, is sigma over root n. We never see those other samples. But we can estimate sigma from the one sample we have, and so estimate the spread: s over root n, the standard error. One sample tells us how much it would wobble if we sampled again. The catch is that s wobbles too, and with small samples it wobbles badly. That was Gosset's problem, and chapter five is its solution.

The same law covers proportions, the most common statistic of all. What share of the World's adults are taller than a hundred and eighty centimetres? About fourteen and a half percent. Draw samples of a hundred and count. A proportion is just the mean of a variable that's one for yes and zero for no, whose variance is p times one minus p. So the standard error is the root of p times one minus p, over n: three and a half percentage points here, and the simulation agrees to the third decimal. It's largest when p is a half, which is why polls plan for that case.

Every statistic has a sampling distribution, not just the mean. Here are the mean and the median of samples of sixty-four men. They lie near their population centers; the male-height population is approximately symmetric. But the median's distribution is wider. The ratio of their variances, the efficiency, is about , close to two over pi, which theory gives for normal data. To match the mean's precision, the median needs about one point six times as much data. In return it shrugs off outliers, a trade Part 30 weighs carefully. Comparing sampling distributions is how we choose between estimators.

The median's spread has a formula too, found by Laplace. Under regularity conditions, its large-sample standard deviation is approximately one over twice the density at the median, times root n. Where the data are dense near the middle, the median is pinned down tightly; where they're sparse, it wanders. For a normal population the density at the median is one over sigma root two pi, which gives sigma times root pi over two, over root n, and the efficiency of two over pi. For sixty-four men that's one point one one centimetres, and the simulation says one point one oh. To use the formula on real data we need to estimate a density, which is the business of Part 29.

What it does: The sampling machine on the World's men; n = 4, 16, 64; SE = σ/√n; proportions; the median's sampling distribution and Laplace's SE formula.; Numbers (computed): SD of x̄: 3.56, 1.76, 0.89 (σ = 7.10); median efficiency 0.65 at n = 64; SE(median) 1.11 vs 1.10 simulated

2Why n - 1Bachelor's4 min

Every course tells you to divide the sum of squared deviations by n minus one, not n. Here's why. Draw forty thousand samples of each size from the World's heights, and average the variance estimate. Divide by n, and the estimate is too small on average: at n equals two it's only half the true variance. The shortfall follows the curve n minus one over n. Divide by n minus one instead, and the average lands on the truth at every sample size. That's what unbiased means. But why is the sum of squares too small in the first place?

Measure deviations from mu, the true mean, and split them at the sample mean: the sum of squares about the sample mean is the sum about mu, minus n times the squared distance between the two means. The cross term vanishes, by Part 1's fact that deviations from the mean sum to zero. Take expectations. The first part is n sigma squared; the subtracted part is n times the variance of the mean, which is one sigma squared. What's left is n minus one sigma squared. The sample mean is, by construction, the point closest to the data, so deviations about it have an expected total shortfall of n times the variance of the mean, one sigma squared.

Part 4 gave a better reason, in geometry. A sample of three heights is one point in three-dimensional space. The sample mean, times the vector of ones, is the projection of that point onto the diagonal line. And the residual, the deviations from the mean, is the perpendicular from the line to the point. Every possible residual lives in the plane perpendicular to the diagonal: two dimensions, not three. Turn the picture. The sum of squared deviations is the squared length of a vector confined to n minus one dimensions, and each dimension contributes, on average, one sigma squared. That's where n minus one comes from: it's a dimension.

One subtlety. Dividing by n minus one makes the variance unbiased, but not the standard deviation. The square root is concave, so by Jensen's inequality from Part 6, the average of s is below sigma. For normal data the shortfall factor is a ratio of gamma functions, called c four. With two observations s averages eighty percent of sigma; with five, ninety-four; with thirty, ninety-nine. Quality-control engineers divide by it; most of statistics doesn't bother, because unbiasedness isn't preserved by nonlinear functions anyway. The n minus one itself goes back to Gauss in 1823, though it's usually called Bessel's correction.

This idea has a name that will follow us through the course. Degrees of freedom: the dimension of the space the residuals live in. Estimate one mean, lose one dimension: n minus one. Fit a full-column-rank linear regression with p coefficients, and the residuals live in n minus p dimensions, the trace of Part 4's residual projection. Compare k groups, and it's n minus k. Each independent fitted linear direction uses one dimension; redundant coefficients do not.

What it does: Simulated bias of the n divisor; the algebra; the residual's plane in ℝ³ (turned); c₄ and E s < σ; degrees of freedom.; Numbers (computed): divisor n at n = 2: 0.504σ²; n − 1: 1.008σ²; c₄(5) = 0.940

3Fisher's geometryMaster's4 min

Gosset found the t distribution by inspired guesswork. A young Ronald Fisher proved it, by thinking geometrically. A sample of n numbers is a single point in n-dimensional space, and a statistic is a function of where that point is. For independent standard normals, the joint density is a product of n bells, which is e to the minus half the squared length of the vector: it depends only on the distance from the origin. So the cloud of possible samples is perfectly round, and rotating it changes nothing. That one fact gives chi-squared, t and F.

Rotate the axes so that the first one points along the diagonal, the vector of ones. Friedrich Helmert wrote down such a rotation in 1876; for three dimensions, here it is. The first new coordinate is root n times the sample mean. The remaining n minus one coordinates hold everything else: the sum of their squares is exactly the sum of squared deviations. And because the cloud is round, the rotated coordinates are again independent standard normals. The mean lives in one coordinate, the deviations in the others.

The story behind the rotation is worth a minute. In 1912 Fisher, still a Cambridge undergraduate, wrote to Gosset with a proof of Student's distribution, done in n-dimensional geometry. Gosset thought it beyond him, and forwarded it to Karl Pearson, the editor of Biometrika, who didn't publish it. A decade later Gosset sent Fisher his tables of the distribution, remarking that Fisher was probably the only man who would ever use them. He was wrong: Fisher's book of 1925 put t in every laboratory in the world, and recast Student's original statistic into the t we use today.

That has a striking consequence. For normal samples, the sample mean and the sample standard deviation are independent: here are twelve hundred of three thousand samples of three, and the cloud of mean against standard deviation has no tilt and no curve. For exponential samples it's nothing like that: a large mean usually comes with a large spread, correlation point seven five. Independence of the mean and variance is special to the normal; in 1936 Roy Geary showed it characterizes the normal distribution. And it's what makes Student's t exact.

Fisher's picture also explains why t doesn't depend on sigma. Centre the data at mu, and split the vector into its part along the diagonal and its part across it. The ratio of their lengths is the cotangent of the angle theta between the data vector and the diagonal, and that ratio is the absolute t statistic, up to the factor root n minus one. So t measures an angle. Scaling the data by sigma stretches the vector but doesn't turn it. And because the normal cloud is round, every direction is equally likely, so the distribution of the angle, and of t, is the same whatever sigma is. Student's distribution is the distribution of a random direction.

Read off the consequences, for a normal sample with any mean and standard deviation. The mean is normal, with variance sigma squared over n: it's one coordinate. The scaled sum of squares is a sum of n minus one squared standard normals: chi-squared with n minus one degrees of freedom. The two are independent, since they use different coordinates. And their ratio, the t statistic, is a normal divided by the root of an independent chi-squared over its degrees of freedom: Student's t. Three distributions, from one rotation.

What it does: Spherical symmetry; Helmert's rotation; Fisher's 1912 letter; x̄ ⟂ s for normal vs exponential samples; t as the cotangent of an angle; the four consequences.; Numbers (computed): corr(x̄, s): 0.01 (normal), 0.75 (exponential)

4Chi-squared and CochranMaster's4 min

The squared length of a vector of k independent standard normals has its own distribution. Chi-squared with k degrees of freedom: for one degree, piled up near zero; for two, an exponential; for more, a skewed bump that drifts right and becomes more symmetric. Its density follows from Part 3: it's a gamma distribution with shape k over two, Karl Pearson's chi-squared of 1900. Its mean is k, one for each squared normal, and its variance two k.

The distribution has a tangled history. In 1876 Friedrich Helmert, a German geodesist studying the errors of land surveys, derived the distribution of a sum of squared deviations, using the very rotation of chapter three. Hardly anyone noticed. In 1900 Karl Pearson found the same distribution again, for his test of whether data fit a model, and gave it the name chi-squared. But Pearson got the degrees of freedom wrong when parameters were estimated from the data, and in the early 1920s Fisher corrected him: every estimated parameter uses up a dimension. That was chapter two's lesson, established in one of statistics' most bitter public arguments. The test itself comes in Part 10.

Check it on the World. Samples of four heights: n minus one times the sample variance, over the true variance, is compared with chi-squared with three degrees of freedom. Samples of ten: chi-squared with nine. The means come out at three and nine, as they must. But the variances are smaller than six and eighteen, about five and fourteen, because the World's heights mix two normal groups, men and women, which makes their distribution flatter-topped than a normal. The chi-squared law is exact only for normal data, a point that will matter in chapter twelve.

Part 4 proved a general version, and it's worth restating here. William Cochran's theorem of 1934: split the squared length of a standard normal vector into pieces using mutually orthogonal projections summing to the identity, and the pieces are independent chi-squareds, each with degrees of freedom equal to its dimension. For a sample, the pieces are the mean, one dimension, and the deviations, n minus one. In regression, the fitted values and the residuals; in a designed experiment, treatments, blocks and error. Classical Gaussian ANOVA obtains its exact reference laws from this theorem.

Chi-squared gives our first interval for something other than a mean. The scaled variance is a pivot: its distribution doesn't depend on any unknown. So it lies between the two and a half and ninety-seven and a half percentiles of chi-squared with probability ninety-five percent. Turn the inequalities around, and you have an interval for sigma squared. With ten observations and a sample standard deviation of nine, sigma lies between six point two and sixteen point four: lopsided, and wide. Ten observations say little about spread. Part 11 builds intervals from pivots in general.

How far can that interval be trusted? Try it on three populations from the World, with samples of ten. For men's heights, which are normal, it covers ninety-five point two percent: on target. For all adults, a flat-topped mixture with negative excess kurtosis, ninety-six point seven: conservative. For log incomes, with positive excess kurtosis, ninety-three: broken. The chi-squared law is exact only for normal data, and kurtosis is a key source of sensitivity, though it does not determine the whole finite-sample law, a story chapter twelve finishes. One practical note: when tables of chi-squared weren't to hand, the cube root of chi-squared over k is nearly normal, a trick of Edwin Wilson and Margaret Hilferty from 1931, accurate to two decimals even with nine degrees of freedom.

What it does: The χ² family; Helmert (1876), Pearson (1900) and Fisher's df correction; World samples; Cochran's theorem; the interval for σ and its coverage on non-normal data; Wilson–Hilferty.; Numbers (computed): means 3.01, 9.02; n = 10, s = 9: σ ∈ [6.2, 16.4]; coverage 95.2% (men), 96.7% (all adults), 93.0% (log incomes)

5Student's tBachelor's4 min

Now the derivation. The t statistic is a standard normal divided by the square root of an independent chi-squared over its degrees of freedom: the mean's coordinate, over the deviations' length. Given the chi-squared, T is just a normal with a scale set by it. So the density of T is a mixture: average the normal density over the distribution of the scale, Part 5's latent-variable formula. The integral is a gamma integral, and out comes Student's density: a power of one plus t squared over k. It's a scale mixture of normals. Uncertainty about the scale is what fattens the tails.

Here's the family. With one degree of freedom, it's the Cauchy, Part 6's distribution whose average never settles: the chance of an absolute value exceeding two is thirty percent. With three, ten and thirty degrees of freedom the tails thin out, and in the limit the t distribution becomes the normal, because s converges to sigma, which is Part 6's Slutsky argument. By thirty degrees of freedom the two are hard to tell apart in the middle, though not far out in the tails.

What does it mean in practice? The interval for a mean becomes the sample mean plus or minus a t multiplier times the standard error. With two observations, one degree of freedom, the multiplier is twelve point seven. With four observations it's three point one eight, the multiplier Gosset needed. It falls quickly toward one point nine six: two point two six at nine degrees of freedom, about two at sixty. That gap is the price of not knowing sigma, paid in width, and t makes it exactly the right price when the data are normal.

Student's paper ended with real data. Two sleeping drugs had been given to ten patients each, and the extra hours of sleep recorded. Student took, for each patient, the difference between the two drugs. The average difference is one point five eight hours, with a standard deviation of one point two three. The t statistic is four point oh six on nine degrees of freedom, and the ninety-five percent interval runs from point seven to two point four six hours. Treating t as normal would have overstated the evidence: a tail probability of five in a hundred thousand, where the normal-differences t model gives about three in a thousand. Comparing each patient with himself, a paired design, is an idea Part 13 develops.

What if Student had ignored the pairing? Treat the same twenty numbers as two independent groups of ten. The two-sample t statistic is only one point eight six, and the p-value is point oh eight: no clear evidence at all. Paired, it was four point oh six, with p point oh oh three. The difference is the correlation between a patient's two results, point eight. Some patients sleep much more than others on either drug; pairing subtracts that variation out. The way the data were collected decides the right analysis, a theme of Parts 10 and 13.

What it does: Density derived as a scale mixture; the family; multipliers; Student's sleep data, paired and unpaired.; Numbers (computed): t = 4.06, p = 0.003, CI [0.70, 2.46]; unpaired t = 1.86, p = 0.079 (corr 0.80)

6The F distributionMaster's3 min

If chi-squared measures one variance, a ratio of two measures how they compare. The F distribution is a ratio of two independent chi-squareds, each divided by its degrees of freedom. For two independent normal samples, the ratio of sample variances, each scaled by its true variance, has this distribution. So if the two true variances are equal, the ratio of sample variances is F, whatever the common variance is. George Snedecor named it in 1934 after Fisher, who had used half its logarithm ten years earlier. In Part 13 the same ratio compares the variation between groups to the variation within them.

Here are a few F distributions. The value one marks equal sample variances. The curves need not have mean or mode one; they are skewed to the right, since a ratio can be large but not negative. With thirty degrees of freedom on each side, the curve tightens around one: more data, a sharper comparison. And turning the ratio upside down just swaps the two degrees of freedom.

Check it on the World. Take five men and ten men, and divide their sample variances. Twenty thousand times. The histogram follows F with four and nine degrees of freedom. Its middle ninety-five percent runs from about point one one to four point seven: the first group's sample variance can be more than four times the second's by chance alone, when the true variances are equal. Variances are hard to compare with small samples.

The F distribution's most important use isn't comparing two variances at all. With several groups, the total sum of squares splits into a between-group part, how far the group means are from the overall mean, and a within-group part: two orthogonal projections, by Cochran's theorem. Under independent normal errors with a common variance and equal group means, the ratio of the two mean squares has an F distribution. Fisher's analysis of variance, developed at Rothamsted in the early 1920s, compares means by comparing variances, and it's the subject of Part 13.

The four distributions of normal theory are one family. A squared t is an F with one degree of freedom on top. As the denominator's degrees of freedom grow, a times F becomes chi-squared with a degrees of freedom. And a simple transformation of F is a beta, which puts all of them on Part 3's family tree. Normal, chi-squared, t, F, beta, gamma: the normal-theory cases are lengths and ratios of normal coordinates in Fisher's round cloud.

What it does: Definition; shapes; World variance ratios against F₄,₉; ANOVA preview; t² = F, the beta link.; Numbers (computed): 95% range 0.11 to 4.72

7Bias, variance, MSEBachelor's4 min

There are many ways to estimate a quantity from a sample. How do we judge them? Think of each sample's estimate as a dart, and the truth as the bullseye. A good estimator lands close every time: centred, and tight. One can be centred but scattered: unbiased, with high variance. Another can be tight but off-centre: precise, but biased. And the worst is both.

One number combines the two failures. The mean squared error is the average squared distance from the truth. Add and subtract the estimator's own average. The cross term averages to zero, and the mean squared error splits into the variance, the spread of the darts, plus the squared bias, the distance from their centre to the bullseye. A little bias can be worth it, if it buys a big reduction in variance.

Here's a surprise about the n minus one. Divide the sum of squares by any constant c. For normal data we know its distribution exactly, so we can compute its bias and variance. Increasing c lowers the expectation; beyond n minus one it introduces downward bias; but less variance. Their sum, the mean squared error, is smallest not at n minus one, which removes the bias, but at n plus one. For five observations: point five for n minus one, point three six for n, point three three for n plus one, and the simulation agrees. Unbiased is not the same as best. We use n minus one because unbiasedness is convenient and because it's what the t distribution needs, not because it's the most accurate.

Shrinkage in miniature. Estimate a proportion from twenty trials. The obvious estimate, successes over trials, is unbiased, and its mean squared error is p times one minus p over twenty, the blue hump. Now add two imaginary successes and two failures: x plus two over n plus four. That pulls every estimate toward a half, so it's biased. But its mean squared error, in orange, is lower for every p between about point two and point eight. Near zero and one, where the pull toward a half costs the most, it loses. Neither of these two estimators wins everywhere, illustrating the starting point of decision theory in Part 45. Alan Agresti and Brent Coull built an interval on this idea, which Part 11 tests.

This is the first glimpse of an idea that runs through modern statistics. The bias–variance trade-off. Pull an estimate toward a fixed point, accept some bias, and cut the variance. In 1961 Willard James and Charles Stein showed that for three or more means estimated at once, under independent normal observations with a known common variance, shrinking toward a fixed center can beat the observations in expected total squared error, whatever the true means are: Part 25. Ridge regression, the lasso, smoothing and many Bayesian prior are versions of the same bargain. But mean squared error isn't everything: an interval needs its bias to be understood, not just small.

Is there a limit to how good an unbiased estimator can be? Yes. The Cramér–Rao bound, found by Harald Cramér and C. R. Rao in the mid-1940s, under regularity conditions says an unbiased estimator cannot have variance below one over n times the Fisher information, a measure of how sharply the data's distribution depends on the parameter. For the mean of a normal, the information is one over sigma squared, and the sample mean's variance, sigma squared over n, sits exactly on the bound: nothing unbiased beats it. For large normal samples the median's variance is approximately pi over two times larger, which is chapter one's efficiency of two over pi. Part 9 derives the bound and builds estimators that reach it.

What it does: Dartboards; MSE = Var + bias²; the divisor n + 1; add-two shrinkage for a proportion; the bias–variance trade-off; Cramér–Rao preview.; Numbers (computed): MSE/σ⁴ at n = 5: 0.500, 0.360, 0.333 for n − 1, n, n + 1; shrinkage wins for 0.21 < p < 0.80 at n = 20

8Consistency and plug-inMaster's4 min

How do we invent estimators in the first place? The simplest answer is a principle. Most quantities we care about are features of the population's distribution: its mean, its median, its spread, a correlation. Write the feature as T of F. Then estimate it by the same feature of the sample's own distribution, the empirical CDF of Part 1: T of F hat. The population mean becomes the sample mean; the population median, the sample median; the variance, the average squared deviation, with divisor n, and so a small bias that disappears as n grows.

Plug-in estimators are consistent, under mild conditions. Take one sample from the World and let it grow from ten people to ten thousand, recomputing five estimates as it grows: the mean and standard deviation of height, the median and interquartile range of income, and the father–son correlation. Each panel shows the error, relative to the truth. Every path wanders early and settles on zero: the estimates converge to the population values. The empirical CDF converges to the true CDF, uniformly, by the Glivenko–Cantelli theorem of Part 48, and a feature continuous in the relevant topology follows it. Means and variances also require moment control; quantiles require uniqueness and continuity. It is not true that every feature follows merely from uniform CDF convergence.

Plug-in estimates can have awkward sampling distributions, and sometimes a transformation tames them. The sample correlation, with ten independent bivariate-normal pairs whose correlation is point eight, is squeezed against its ceiling of one and badly skewed. Fisher's 1915 paper, the one that introduced his geometry, found the cure: take the inverse hyperbolic tangent. The transformed values are approximately normal, with an approximate standard deviation of one over root n minus three; finite-sample bias and accuracy still depend on the true correlation. Intervals are built on that scale and transformed back.

An estimator that converges in probability to the truth is called consistent. Notice that this is a different property from unbiasedness. The plug-in variance is biased for every finite n, yet consistent. The first observation alone is an unbiased estimate of the mean, yet it never improves, however much data you collect, so it is not consistent. Consistency is the least we should ask of an estimator. Part 9 asks how fast it converges, and whether any estimator could do better.

Plug-in has its limits. Suppose objects carry serial numbers one to N, and we see ten of them at random. To estimate N, the plug-in answer is the largest serial number in the sample. It can equal the endpoint but can never exceed the true maximum, and on average, with ten serials out of a thousand, it's nine hundred and ten. A small correction, scaling up by one plus one over n and subtracting one, is exactly unbiased under simple random sampling without replacement. Where that correction comes from, and why it's the best possible, is the opening story of Part 9: the German tank problem.

The plug-in principle has a second, more powerful use. Apply it one level up. The standard error of any estimator is itself a feature of the unknown population. So estimate it by the same feature of the sample's distribution. There's rarely a formula, but there's always a simulation: draw new samples from the data itself, with replacement, recompute the estimator each time, and measure the spread. That is Bradley Efron's bootstrap of 1979, a resampling standard error under regularity conditions, and the subject of Part 16.

What it does: T(F̂ₙ); five plug-in paths converging; Fisher's z for r; consistent vs unbiased; the sample maximum; the bootstrap preview.; Numbers (computed): Fisher z: SD 0.370 vs 1/√7 = 0.378; E max of 10 from 1,000 = 910

9Standard errors for ratiosMaster's4 min

In 1802 France had no census, but every parish registered its births. Pierre-Simon Laplace proposed to count the nation from a sample. In communes spread across thirty departments, officials counted the people: two million, thirty-seven thousand, six hundred and fifteen. Those communes had registered two hundred and fifteen thousand, five hundred and ninety-nine births over three years, about seventy-one thousand eight hundred a year. So there were about twenty-eight point three five people for every annual birth. France as a whole registered about a million births a year, so its population was about twenty-eight point three five million. Laplace went further: he gave a measure of the estimate's uncertainty, more than a century before sampling became a profession.

In modern terms. The estimate is the known national total of births, times the ratio of two sample means: people per commune over births per commune. This is the ratio estimator, still used by every statistics office. Its uncertainty comes from how both means wobble, and how they wobble together: exactly the job of Part 6's delta method for a function of two means.

Write the error of the ratio as an average of residuals: each commune's people minus the ratio times its births, divided by the average births. To first order, that's all there is. So the ratio's standard error is the standard error of an average of residuals, over the mean number of births. Communes whose population is far from the ratio's prediction add uncertainty; communes that fit the ratio well add almost none. Multiply by the national births, and you have the standard error of France's population. Survey statisticians use this every day.

There's a subtlety in Laplace's survey that took another century to resolve. He didn't pick his communes at random: he chose them for reliable registers and a spread of regions. His error calculation imagined them as a random draw from a larger hypothetical population. The theory of random sampling from an actual finite list came with Arthur Bowley in 1906 and Jerzy Neyman in 1934. Neyman showed that hand-picked samples can fail badly, and that random selection is what makes a standard error trustworthy. The next chapter and Part 18 take this up.

We can't rerun Laplace's survey, but we can run his method on the World. Each of its two hundred towns has a population and a number of babies born in the past year; people per birth is about sixty-seven, and it varies from town to town. Sample thirty towns, form the ratio, scale up by the island's births, ten thousand times. The estimates centre on the true million, with a standard deviation of about twenty-four thousand. The delta-method standard error, including the finite-population correction, is shown alongside the actual simulation spread. An interval of plus or minus one point nine six standard errors has the coverage shown, below ninety-five. With only thirty towns of very different sizes, the ratio's distribution is still skewed. First-order approximations need checking, which is exactly what the Coverage Board is for.

What it does: Laplace's 1802 census; the ratio estimator; the delta-method SE; purposive vs random selection; the World version.; Numbers (computed): 28.35 people per birth → 28.35 million; World: SD 24,195, mean design-linearized SE 21,402 (FPC included), coverage 89.7%

10Finite populationsPractice3 min

Many preceding sampling formulas assumed independent draws, as if sampling from an infinite population or with replacement. Real surveys sample without replacement from a finite list. Then the draw values have negative covariance: drawing a high value leaves a lower average among the remaining values. Here sigma squared uses the population divisor N. The covariance between two draws is minus sigma squared over N minus one. Put that into the variance of a sum. The variance of the mean is the usual sigma squared over n, times a correction: N minus n over N minus one, the finite-population correction.

Here's a population of four hundred heights. The grey curve is the usual standard error. The gold curve includes the correction, and falls to zero at four hundred, since a sample of everyone has no sampling error at all. The blue dots are simulated samples without replacement: they sit on the gold curve. When the sample is one percent of the population or less, the correction is negligible, which is why it's usually ignored.

The correction matters most when planning a survey. To estimate a proportion to within a margin e with ninety-five percent confidence, set one point nine six standard errors equal to e, and solve for n, then round upward. This is a normal-approximation planning rule. The worst case is p equal to a half, and a three-point margin needs about a thousand and sixty-eight people: the familiar size of opinion polls. With the finite-population correction, the required sample shrinks. From a population of two thousand, you need about seven hundred; from ten thousand, nine hundred and sixty-five; from ten million, essentially the full thousand and sixty-seven.

The formula hides a surprise that puzzles people about opinion polls. The precision of a sample depends on its size, n, and hardly at all on the size of the population, N. A random sample of a thousand has a proportion standard error of at most about one point six percentage points; an approximate ninety-five-percent margin is about three point one points, whether the population is a city, a country, or the whole world. A spoonful tastes the soup, whatever the size of the pot, provided the soup is stirred. Stirring is random sampling. Part 18 tells the story of a poll that got two point four million unstirred replies, and missed the election by twenty points. Size is no substitute for randomness: a huge biased sample only measures its own bias very precisely.

What it does: The negative covariance of draws without replacement; FPC; simulation; sample-size planning; n, not N.; Numbers (computed): n₀ = 1,068 after rounding up; N = 2,000: 697; N = 10⁷: 1,067

11The Coverage Board opensBachelor's3 min

In Part 1 we set up an empty scoreboard. Now it gets its first rows. Every interval makes a promise: ninety-five percent of the intervals it produces will catch the truth. On real data we can never check that, because we don't know the truth. In the World we do. So for each method, draw ten thousand samples, compute the interval each time, and count how often it catches the true value. Ten thousand replications pin the coverage with a Monte Carlo standard error of about a fifth of a percentage point, Chapter 6 of Part 7's Monte Carlo standard error. A method whose coverage is within three Monte Carlo standard errors of ninety-five percent is labeled kept by this screening rule, not proven exact for every population. Below that, it's broken; above, conservative.

First, a picture of what coverage means. Forty samples of five heights, each with the naive interval, using one point nine six and s. The red ones miss the true mean. Three of forty miss: this time, by luck, it looks fine. On the right, the same forty samples with Student's multiplier, two point seven eight: every one catches the truth here. Forty intervals can't tell these two methods apart reliably. Ten thousand can.

Here is the board. First, the textbook z-interval when sigma is known, on samples of five heights: ninety-five point oh five percent. Kept. The same interval with s in place of sigma: eighty-seven point six percent. Broken: Gosset's discovery, measured. Student's t with five observations: ninety-four point four, inside the band. Kept. Now Student's t on the World's incomes, skewed with a heavy tail. With twenty people, eighty-eight percent. Broken. With five hundred, still only ninety-two point eight. Broken: chapter seven of Part 6, the central limit theorem's slow arrival, now on the record. And the F-test for equal variances, whose false-alarm rate should be five percent: on normal heights, four point nine. Kept. On log incomes, which are only roughly normal, six point three. Broken.

What do the first rows say? Exact normal theory has exact coverage under its assumptions. These finite-World checks are evidence about these settings, not proof of those assumptions. Plugging in an estimate without paying for its uncertainty breaks them. And large-sample approximations can fail even with large samples, when the data have heavy tails. Look at the widths, too: the broken interval is narrower than Student's, and that's exactly why it fails. An interval that's too good to be true usually is. Every later part will add rows to this board, and Part 65 will show it whole: a public record of which promises statistics keeps, measured rather than assumed.

What it does: The protocol; 40 intervals each way; the first seven rows; what they say.; Numbers (computed): the table above

12How robust is normal theory?Practice3 min

Normal theory gives exact answers for normal data. How wrong are they when the data aren't normal? Test a mean with the t-test, at the five percent level, when the null hypothesis is true, with samples of ten from four distributions. For normal, uniform and t with five degrees of freedom, the false-alarm rate stays close to five percent. Only the strongly skewed exponential pushes it to ten. Now test whether two variances are equal with the F-test. For normal data, five percent. For uniform data, one percent: far too cautious. For t five, twelve and a half; for the exponential, twenty-three. The t-test for means is fairly robust. The F-test for variances is not robust at all.

Why the difference? The t statistic leans on the sample mean, which the central limit theorem makes nearly normal asymptotically under independent identical sampling and finite positive variance; it gives no universal small-sample guarantee. The F-test leans on the variance of the sample variance, and that depends on the data's kurtosis, the heaviness of the tails, through a term whose size relative to the normal-theory variance does not vanish. Normal theory assumes the excess kurtosis is zero. For distributions with excess kurtosis six, the sample variance is three point seven times as variable as normal theory says at n equals ten, so the F-test's reference distribution is wrong, and more data doesn't fix it.

There's more to the exponential's ten percent than a number. Split it by tail. The test rejects in the lower tail nine and a half percent of the time, and in the upper tail less than half a percent. Each should be two and a half. In a right-skewed sample, a high mean comes with a high standard deviation, damping the t statistic, and a low mean with a low one, inflating it. The two errors don't cancel; they pile up on one side. A one-sided conclusion from skewed data can be badly wrong even when the two-sided rate looks tolerable. Part 16's bootstrap-t is can improve skewness corrections under regularity conditions; it is not a universal repair.

George Box made this point in 1953, in the paper where he introduced the word robust into statistics. Testing whether variances are equal before an analysis of variance, he wrote, is like putting to sea in a rowing boat to find out whether conditions are calm enough for an ocean liner to leave port: the preliminary test is far more fragile than the analysis it's meant to protect. The lesson is to know which assumptions a method actually leans on. Remedies for comparing spreads come later: tests based on absolute deviations, the bootstrap in Part 16, and robust statistics in Part 30.

What it does: t-test and F-test sizes under four distributions; Var(s²) and kurtosis (3.7 times the normal-theory variance at n = 10 when excess kurtosis is 6); one-sided misses under skew; Box (1953).; Numbers (computed): t: 4.9–5.4% except exponential 10.0% (9.5% low, 0.4% high); F: 1.0% (uniform) to 23.2% (exponential)

Recap, problems, and the road aheadAll tracks3 min

Part eight in thirteen lines. Gosset's shuffled cards showed that the textbook interval covers only eighty-seven percent with four observations. A statistic has a sampling distribution, and the standard error, sigma over root n, is its spread, estimated from one sample. The n minus one is a dimension: residuals live in a subspace. Fisher's rotation splits a normal sample into its mean and its deviations, independent of each other, and from it come chi-squared and Cochran's theorem, Student's t, a normal over an uncertain scale, and F, a ratio of variances. Mean squared error is variance plus squared bias, and among constant SS divisors for normal data the best is n plus one. Plug-in estimators are consistent under appropriate continuity and moment conditions. Laplace estimated France's population with a ratio, and the delta method gives its standard error; the finite-population correction handles samples from small lists. The Coverage Board has its first rows. And the t-test can be more robust in these examples, while the F-test for variances is not.

Where it comes back. Sampling distributions and standard errors underlie every estimator from Part 9 on, and the bootstrap of Part 16 computes them by simulation. The t, chi-squared and F distributions run the tests of Part 10 and the regressions and designed experiments of Parts 12 and 13. The bias–variance trade-off becomes shrinkage, smoothing and the lasso. Ratio estimation and finite populations return in survey sampling, Part 18. And the Coverage Board grows with every part.

Six problems, with full solutions in the README. The n minus one proved; two intervals from one sample; t squared as an F; the best divisor; the standard error of a ratio; and a sample size from a finite population. Pause here if you want to try them.

The books and papers this part follows: Casella and Berger, Rice, Cochran on sampling, Stigler's history, and Egon Pearson's biography of Gosset, with the original papers from Student to Box.

Eight parts of sixty-five. We know how statistics vary from sample to sample, and we have a board to hold methods to their promises. But where do good estimators come from? During the Second World War, Allied statisticians estimated German tank production from the serial numbers on captured tanks, and beat the intelligence services. Part 9: estimation.

Where it goes next. Sampling distributions and standard errors carry Parts 9, 11 and 16; t, chi-squared, F and Cochran's theorem return in the tests of Part 10, in regression (Part 12), ANOVA (Part 13) and the linear model of Part 23; the bias-variance trade-off returns as shrinkage in Parts 25 and 29; ratio estimators and finite populations in Part 18; the Coverage Board in every part.

Key results

The part's results in one place, for revision.

Standard error and the n - 1\(\displaystyle \operatorname{Var}(\bar x)=\frac{\sigma^2}{n},\qquad\allowbreak E\,s^2=E\Bigl[\frac{1}{n-1}\sum_{i=1}^n (x_i-\bar x)^2\Bigr]=\sigma^2\)
Fisher's geometry\(\displaystyle x_i\overset{\text{iid}}{\sim}N(\mu,\sigma^2):\qquad\allowbreak \bar x\sim N\bigl(\mu,\tfrac{\sigma^2}{n}\bigr)\ \perp\ \frac{(n-1)s^2}{\sigma^2}\sim\chi^2_{n-1}\)
Student's t\(\displaystyle \frac{\bar x-\mu}{s/\sqrt n}\sim t_{n-1},\qquad\allowbreak \bar x\pm t_{n-1,\,0.975}\,\frac{s}{\sqrt n}\ \text{ covers } \mu \text{ with }\allowbreak \text{probability } 0.95\)
Mean squared error (normal samples)\(\displaystyle \operatorname{MSE}=\operatorname{Var}+\operatorname{bias}^2;\qquad\allowbreak \operatorname{MSE}\bigl(\tfrac1c{\textstyle\sum}(x_i-\bar x)^2\bigr)\ \text{is }\allowbreak \text{least }\allowbreak \text{at } c=n+1\)
Standard error of a ratio\(\displaystyle \operatorname{SE}\Bigl(\frac{\bar y}{\bar x}\Bigr)\approx\frac{1}{|\mu_x|}\sqrt{\frac{\sigma_y^2-2R\,\sigma_{xy}+R^2\sigma_x^2}{n}},\qquad\allowbreak R=\frac{\mu_y}{\mu_x}\)
Finite-population correction\(\displaystyle \operatorname{Var}(\bar x)=\frac{\sigma^2}{n}\cdot\frac{N-n}{N-1}\qquad\allowbreak \text{(} n \text{ of } N \text{ drawn }\allowbreak \text{without }\allowbreak \text{replacement)}\)

Try it

Lab 8 · Student's cards: 1.96 against the t multiplier

Shuffle Macdonell's 3,000 heights forty times, deal each shuffle into 750 samples of four as Gosset did, and compare the coverage of mean +/- 1.96 s/sqrt(n) and of Student's interval with what the t distribution with 3 degrees of freedom predicts. Then check two more of the part's claims on simulated samples.

Figure produced by Lab 8: Student's cards: 1.96 against the t multiplier
Produced by the lab below, seed 0, in 0.2 s.
python -m videos.stats.labs 8 needs numpy, scipy, matplotlib · download lab08.py · source on GitHub
cards, mean and sd (cm)                   3000, 166.30, 6.50
first shuffle, 750 samples: 1.96 covers   84.9%   Student's 3.18 covers 93.9%
all 30,000 samples: 1.96 covers           85.8% +/- 0.2%   (t with 3 df predicts 85.5%)
all 30,000 samples: Student's covers      94.9% +/- 0.1%   (promise 95%)
corr(mean, sd), samples of 3              normal +0.000 (theory 0)   exponential +0.762
MSE of SS/c, c = n - 1, n, n + 1 (n = 5)  0.499  0.360  0.334   (theory 0.500, 0.360, 0.333)

Four cards give a standard deviation too shaky for the normal table: the ratio follows Student's t with 3 degrees of freedom, whose 97.5% point is 3.18. The unbiased divisor n - 1 is not the one with the smallest mean squared error.
The code (89 lines; it asserts its own result)
"""Lab 8: deal Student's 3,000 cards into samples of four, and see which multiplier keeps the 95% promise."""

import numpy as np
from scipy import stats

from videos.coursekit import labs
from explainer.stats import museum
from explainer.stats.kit import intervals
from explainer.stats.kit import random as skr

TITLE = "Student's cards: 1.96 against the t multiplier"
GOAL = ("Shuffle Macdonell's 3,000 heights forty times, deal each shuffle into 750 samples of four as Gosset did, "
        "and compare the coverage of mean +/- 1.96 s/sqrt(n) and of Student's interval with what the t distribution "
        "with 3 degrees of freedom predicts. Then check two more of the part's claims on simulated samples.")
TASKS = [
    "Deal samples of 2, 8 and 30 instead of 4. How fast does the 1.96 interval's coverage approach 95%?",
    "Replace the heights by their exponentials, np.exp((h - h.mean()) / h.std()), a skewed population. Which "
    "interval suffers, and on which side does it miss?",
    "Build the chi-squared interval for the variance (intervals.var_interval) on normal and on exponential samples "
    "of ten. Which coverage survives?",
]


def run(seed=0):
    rng = np.random.default_rng(seed)
    lab = labs.Lab()

    # 1. Gosset's experiment on the Museum's cards.
    cards = np.repeat(np.asarray(museum.CRIM_HEIGHT_CM), np.asarray(museum.CRIM_TABLE).sum(0))
    mu, n, shuffles = cards.mean(), 4, 40
    deals = np.concatenate([rng.permutation(cards).reshape(-1, n) for _ in range(shuffles)])  # 30,000 samples of four
    xbar, s = deals.mean(1), deals.std(1, ddof=1)
    tmult = stats.t.ppf(0.975, n - 1)
    err = np.abs(xbar - mu)
    hit_z, hit_t = err <= 1.96 * s / 2, err <= tmult * s / 2
    theory_z = 1 - 2 * stats.t.sf(1.96, n - 1)
    first = intervals.t_interval(deals[0])
    assert abs(first[1] - (xbar[0] + tmult * s[0] / 2)) < 1e-9, "the vectorized interval is statkit's t_interval"
    lab.row("cards, mean and sd (cm)", f"{len(cards)}, {mu:.2f}, {cards.std():.2f}")
    lab.row("first shuffle, 750 samples: 1.96 covers", f"{hit_z[:750].mean():.1%}   Student's {tmult:.2f} covers {hit_t[:750].mean():.1%}")
    lab.row("all 30,000 samples: 1.96 covers", f"{hit_z.mean():.1%} +/- {skr.mc_se(hit_z):.1%}   (t with 3 df predicts {theory_z:.1%})")
    lab.row("all 30,000 samples: Student's covers", f"{hit_t.mean():.1%} +/- {skr.mc_se(hit_t):.1%}   (promise 95%)")
    assert abs(hit_z.mean() - theory_z) < 0.015, "with s from four cards, 1.96 covers about 85.5%, not 95%"
    assert abs(hit_t.mean() - 0.95) < 0.012, "Student's multiplier keeps the promise"

    # 2. Fisher's geometry: mean and sd are independent for normal samples, and only for them.
    reps = 200_000
    z3, e3 = rng.standard_normal((reps, 3)), rng.exponential(size=(reps, 3))
    r_norm = np.corrcoef(z3.mean(1), z3.std(1, ddof=1))[0, 1]
    r_exp = np.corrcoef(e3.mean(1), e3.std(1, ddof=1))[0, 1]
    lab.row("corr(mean, sd), samples of 3", f"normal {r_norm:+.3f} (theory 0)   exponential {r_exp:+.3f}")
    assert abs(r_norm) < 0.012 and r_exp > 0.6, "independence of mean and sd is special to the normal"

    # 3. Bias against variance: the MSE of SS/c for normal samples of five is least at c = n + 1.
    n5 = 5
    ss = ((z5 := rng.standard_normal((reps, n5))) - z5.mean(1, keepdims=True)) ** 2
    ss = ss.sum(1)
    cs = np.array([n5 - 1, n5, n5 + 1])
    mse_sim = np.array([np.mean((ss / c - 1) ** 2) for c in cs])
    mse_th = ((n5 - 1) / cs - 1) ** 2 + 2 * (n5 - 1) / cs ** 2
    lab.row("MSE of SS/c, c = n - 1, n, n + 1 (n = 5)", "  ".join(f"{a:.3f}" for a in mse_sim) + "   (theory " + ", ".join(f"{a:.3f}" for a in mse_th) + ")")
    assert np.allclose(mse_sim, mse_th, rtol=0.04) and mse_sim[2] < mse_sim[1] < mse_sim[0], "n + 1 beats n beats n - 1"
    lab.note = ("Four cards give a standard deviation too shaky for the normal table: the ratio follows Student's t "
                "with 3 degrees of freedom, whose 97.5% point is 3.18. The unbiased divisor n - 1 is not the one "
                "with the smallest mean squared error.")

    fig, ax = labs.figure(2, size=(11, 4.2))
    ok = s > 0
    ratio = (xbar[ok] - mu) / (s[ok] / 2)
    grid = np.linspace(-6, 6, 400)
    counts, edges = np.histogram(ratio, bins=np.linspace(-6, 6, 31))  # wide bins: the heights are whole inches
    ax[0].bar(edges[:-1], counts / (len(ratio) * 0.4), width=0.4, align="edge", color=labs.BLUE, alpha=0.6,
              label="30,000 samples of four cards")
    ax[0].plot(grid, stats.norm.pdf(grid), color=labs.RED, label="normal")
    ax[0].plot(grid, stats.t.pdf(grid, 3), color=labs.GOLD, label="Student's t, 3 df")
    for m, c in ((1.96, labs.RED), (tmult, labs.GOLD)):
        ax[0].axvline(m, color=c, ls="--", lw=1)
        ax[0].axvline(-m, color=c, ls="--", lw=1)
    ax[0].set(title="(mean - true mean) / (s / sqrt(4))", xlabel="the ratio Gosset computed (dashed: 1.96 and 3.18)",
              ylabel="density", ylim=(0, 0.62))
    ax[0].legend(loc="upper left", frameon=True, facecolor=labs.BG, edgecolor=labs.GRID, framealpha=1)
    cgrid = np.linspace(3, 9, 200)
    ax[1].plot(cgrid, ((n5 - 1) / cgrid - 1) ** 2 + 2 * (n5 - 1) / cgrid ** 2, color=labs.GOLD, label="theory")
    ax[1].plot(cs, mse_sim, "o", color=labs.BLUE, label="simulated: c = 4, 5, 6")
    ax[1].axvline(n5 + 1, color=labs.MUTED, ls="--", lw=1)
    ax[1].set(title="MSE of SS/c as a variance estimate, n = 5", xlabel="divisor c", ylabel="MSE / sigma^4")
    ax[1].legend()
    lab.fig = fig
    return lab

Now change it

  1. Deal samples of 2, 8 and 30 instead of 4. How fast does the 1.96 interval's coverage approach 95%?
  2. Replace the heights by their exponentials, np.exp((h - h.mean()) / h.std()), a skewed population. Which interval suffers, and on which side does it miss?
  3. Build the chi-squared interval for the variance (intervals.var_interval) on normal and on exponential samples of ten. Which coverage survives?

Problems, with solutions

Try each problem before opening its solution.

1. E Σ(xᵢ − x̄)² = (n − 1)σ². Show that \(E\sum_i (x_i - \bar x)^2 = (n - 1)\sigma^2\) for any i.i.d. sample with variance \(\sigma^2\).

Solution

Σ(xᵢ − x̄)² = Σ(xᵢ − μ)² − n(x̄ − μ)². The cross term is 2(x̄ − μ)Σ(xᵢ − x̄) = 0. Taking expectations gives nσ² − n·σ²/n = (n − 1)σ². Identical means and variances, independence, and a finite variance are sufficient.

2. Two intervals. n = 9, x̄ = 50, s = 6.

Solution
  • For μ: 50 ± t₈,₀.₉₇₅ · 6/3 = 50 ± 2.306 · 2 = [45.39, 54.61].
  • For σ²: [8 · 36/χ²₈,₀.₉₇₅, 8 · 36/χ²₈,₀.₀₂₅] = [288/17.53, 288/2.180] = [16.4, 132.1]. So σ ∈ [4.05, 11.49].

Both intervals have exact coverage under IID normal data; the variance interval is especially sensitive to nonnormality (chapter 4's coverage check).

3. t² = F. Show that if \(T \sim t_k\) then \(T^2 \sim F_{1,k}\).

Solution

T = Z/√(V/k) with Z ⟂ V ~ χ²ₖ. Then T² = (Z²/1)/(V/k), and Z² ~ χ²₁ is independent of V, so T² is a ratio of independent χ²s over their df: F₁,ₖ.

4. The best divisor. Normal data: find the \(c\) minimizing \(E\big(\tfrac1c\sum (x_i - \bar x)^2 - \sigma^2\big)^2\), and the minimum MSE.

Solution

SS/σ² ~ χ²ₙ₋₁, so

MSE(c)/σ⁴ = ((n − 1)/c − 1)² + 2(n − 1)/c².

The derivative is −2(n − 1)/c² · ((n − 1)/c − 1) − 4(n − 1)/c³. Setting it to zero gives (n − 1) − c + 2 = 0, so c = n + 1. The minimum is

MSE = σ⁴((n − 1 − n − 1)² + 2(n − 1))/(n + 1)² = 2σ⁴/(n + 1),

against 2σ⁴/(n − 1) for the unbiased divisor.

5. The SE of a ratio. Use the delta method to find the SE of \(\bar y/\bar x\) when \((x_i, y_i)\) are i.i.d. pairs.

Solution

With R = μ_y/μ_x,

ȳ/x̄ − R = (ȳ − Rx̄)/x̄ ≈ (1/μ_x) · mean(yᵢ − Rxᵢ).

So SE(ȳ/x̄) ≈ (1/|μ_x|)√((σ_y² − 2Rσ_xy + R²σ_x²)/n). Estimate it by plugging in x̄, R̂ and the sample variance of the residuals eᵢ = yᵢ − R̂xᵢ.

6. A sample size from N = 2,000. How large a simple random sample (without replacement) from \(N = 2{,}000\) gives \(\mathrm{SE}(\bar x) = \sigma/20\)?

Solution

We need (σ²/n)(N − n)/(N − 1) = σ²/400, so n = 400N/(N + 399) = 800,000/2,399 = 333.5, and the sample needs 334. Without the correction it would need 400.

Notes and sources

Where it comes back

Idea Returns in
sampling distributions, standard errors 9, 11, 16, 47
t, χ², F; Cochran's theorem; degrees of freedom 10, 12, 13, 23
bias–variance, shrinkage, Cramér–Rao 9, 25, 29, 32, 45
plug-in, consistency, the bootstrap 9, 16, 47, 48
ratio estimation, delta-method SEs 14, 18, 22
finite populations, random vs purposive sampling 18, 41
the Coverage Board every part; 65
robustness to non-normality 16, 30, 60

Sources

  • Student. "Student" (W. S. Gosset), "The probable error of a mean", Biometrika 6 (1908).
    • Data: W. R. Macdonell, Biometrika 1 (1902); A. Cushny & A. Peebles, J. Physiology 32 (1905).
    • E. S. Pearson, 'Student': A Statistical Biography of William Sealy Gosset (1990).
  • Fisher.
    • R. A. Fisher, Biometrika 10 (1915); "Applications of 'Student's' distribution", Metron 5 (1925).
    • Statistical Methods for Research Workers (1925).
  • Distributions. F. R. Helmert (1876); K. Pearson (1900); W. G. Cochran, Proc. Camb. Phil. Soc. 30 (1934); G. Snedecor (1934); E. B. Wilson & M. Hilferty, PNAS 17 (1931); R. C. Geary (1936).
  • Laplace. P.-S. Laplace, Théorie analytique des probabilités (1812).
    • W. G. Cochran, "Laplace's ratio estimator" (1978); S. Stigler, The History of Statistics (1986).
    • A. Bowley (1906); J. Neyman, JRSS 97 (1934).
  • MSE and bounds. W. James & C. Stein (1961); A. Agresti & B. Coull, Am. Stat. 52 (1998); H. Cramér (1946); C. R. Rao (1945).
  • Robustness. G. E. P. Box, "Non-normality and tests on variances", Biometrika 40 (1953).
  • Textbooks.
    • G. Casella & R. Berger, Statistical Inference (2nd ed., 2002), ch. 5.
    • J. Rice, Mathematical Statistics and Data Analysis (3rd ed., 2007), chs. 6–8.
    • W. G. Cochran, Sampling Techniques (3rd ed., 1977).
About this partfrom its README

Part 8 of a sixty-five-part course in statistics, from a first course to a PhD (see the series plan and the syllabus), in Stage I, Bachelor's: Foundations. Parts 6 and 7 gave the laws of averages and the machinery of simulation. This part turns both on statistics themselves: how much does an estimate wobble from sample to sample, and how can one sample tell you?

It opens with Student (W. S. Gosset) at Guinness, 1908. He shuffled 3,000 cards bearing the heights of Macdonell's criminals and dealt 750 samples of four. Redone here with one seeded shuffle, the textbook interval x̄ ± 1.96 s/√n covers only 87.1% of the time; Student's t₃ multiplier, 3.18, covers 96.7%. From there the part covers:

  • sampling distributions and standard errors (the sampling machine);
  • the n − 1, as an expectation and as a dimension;
  • Fisher's rotation of the sample, and from it χ², Cochran's theorem, Student's t and Snedecor's F;
  • bias, variance and mean squared error;
  • consistency and plug-in estimators;
  • standard errors for ratios, with Laplace's 1802 census of France;
  • finite populations;
  • the robustness of normal theory (Box 1953).

The Coverage Board opens with its first seven rows.

Every number on screen is computed in compute.py. The Museum supplies:

  • Macdonell's 3,000 heights (museum.CRIM_*, from R's crimtab);
  • Student's sleep data (museum.SLEEP_*);
  • Laplace's census figures (museum.LAPLACE).

Everything else is the World (seed 1662) or a seeded simulation, and is tagged as such.

Built in this part: the first rows of the Coverage Board (explainer/stats/board.py), written to .cache/stats8/board.json by python -m videos.stats.stats8.compute --force board. Each row has R = 10,000 replications.

Method Setting Achieved Verdict
z, known σ heights, n = 5 95.05% kept
z with s heights, n = 5 87.60% broken
Student's t heights, n = 5 94.39% kept
Student's t incomes, n = 20 88.24% broken
Student's t incomes, n = 500 92.78% broken
F-test, σ₁ = σ₂ (size) heights, n = 10, 10 4.89% kept
F-test, σ₁ = σ₂ (size) log incomes, n = 10, 10 6.28% broken
Chapter notes
# Chapter What it does Numbers (computed)
0 Student at Guinness Gosset's problem; his 1904 brewery report and year with Pearson; Macdonell's heights; 3,000 cards dealt in fours; t against the normal. z-interval covers 87.1%, t₃ 96.7% (heights rounded to inches); World: 85.1% vs 94.4%
1 Sampling distributions The sampling machine on the World's men; n = 4, 16, 64; SE = σ/√n; proportions; the median's sampling distribution and Laplace's SE formula. SD of x̄: 3.56, 1.76, 0.89 (σ = 7.10); median efficiency 0.65 at n = 64; SE(median) 1.11 vs 1.10 simulated
2 Why n − 1 Simulated bias of the n divisor; the algebra; the residual's plane in ℝ³ (turned); c₄ and E s < σ; degrees of freedom. divisor n at n = 2: 0.504σ²; n − 1: 1.008σ²; c₄(5) = 0.940
3 Fisher's geometry Spherical symmetry; Helmert's rotation; Fisher's 1912 letter; x̄ ⟂ s for normal vs exponential samples; t as the cotangent of an angle; the four consequences. corr(x̄, s): 0.01 (normal), 0.75 (exponential)
4 χ² and Cochran The χ² family; Helmert (1876), Pearson (1900) and Fisher's df correction; World samples; Cochran's theorem; the interval for σ and its coverage on non-normal data; Wilson–Hilferty. means 3.01, 9.02; n = 10, s = 9: σ ∈ [6.2, 16.4]; coverage 95.2% (men), 96.7% (all adults), 93.0% (log incomes)
5 Student's t Density derived as a scale mixture; the family; multipliers; Student's sleep data, paired and unpaired. t = 4.06, p = 0.003, CI [0.70, 2.46]; unpaired t = 1.86, p = 0.079 (corr 0.80)
6 The F distribution Definition; shapes; World variance ratios against F₄,₉; ANOVA preview; t² = F, the beta link. 95% range 0.11 to 4.72
7 Bias, variance, MSE Dartboards; MSE = Var + bias²; the divisor n + 1; add-two shrinkage for a proportion; the bias–variance trade-off; Cramér–Rao preview. MSE/σ⁴ at n = 5: 0.500, 0.360, 0.333 for n − 1, n, n + 1; shrinkage wins for 0.21 < p < 0.80 at n = 20
8 Consistency and plug-in T(F̂ₙ); five plug-in paths converging; Fisher's z for r; consistent vs unbiased; the sample maximum; the bootstrap preview. Fisher z: SD 0.370 vs 1/√7 = 0.378; E max of 10 from 1,000 = 910
9 Standard errors for ratios Laplace's 1802 census; the ratio estimator; the delta-method SE; purposive vs random selection; the World version. 28.35 people per birth → 28.35 million; World: SD 24,195, mean design-linearized SE 21,402 (FPC included), coverage 89.7%
10 Finite populations The negative covariance of draws without replacement; FPC; simulation; sample-size planning; n, not N. n₀ = 1,068 after rounding up; N = 2,000: 697; N = 10⁷: 1,067
11 The Coverage Board opens The protocol; 40 intervals each way; the first seven rows; what they say. the table above
12 How robust is normal theory? t-test and F-test sizes under four distributions; Var(s²) and kurtosis (3.7 times the normal-theory variance at n = 10 when excess kurtosis is 6); one-sided misses under skew; Box (1953). t: 4.9–5.4% except exponential 10.0% (9.5% low, 0.4% high); F: 1.0% (uniform) to 23.2% (exponential)
13 Outro Recap, payoffs, problems, references, the Transcript, Part 9's question. —
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. Hook: Student (1908). Gosset's card-deck simulation of 750 samples of 4, redone on 3,000 World residents.
  2. Sampling distributions. The SamplingMachine; standard errors; σ/√n.
  3. The n − 1. E s² = σ²; residuals live in an (n − 1)-dimensional subspace (Part 4).
  4. Fisher's geometry (1915, 1925). Spherical symmetry; x̄ ⟂ s² by rotation.
  5. χ² and Cochran (1934). Squared lengths of projections (Part 4).
  6. Student's t. Its density derived; Gosset's cards vs the formula.
  7. F. A ratio of χ²s; comparing variances.
  8. Bias, variance, MSE. MSE = bias² + variance; the n + 1 divisor beats n − 1 for MSE.
  9. Consistency and plug-in. T(F̂) for T(F): mean, variance, quantiles, correlation.
  10. Standard errors for nonlinear statistics. The delta method for ratios; Laplace's estimate of France's population (1802).
  11. Finite populations. The finite-population correction (Part 18).
  12. The Coverage Board opens. The rows of §3.
  13. Robustness of normal theory. The t-test is fairly robust; the F-test for variances is not (Box 1953).
  14. Outro.

Board rows: Part 8 in §3. Data: Student (1908).

Build the film

python -m videos.stats.stats8.compute        # the part's numbers, into .cache/stats8
python tools/build.py stats8                  # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py stats8 Hook   # one chapter, silent, with a contact sheet

Scenes: videos/stats/stats8. Setup: see the course page. Source of these notes: the README and the scenes' narration.

Build it
python -m videos.stats.stats8.compute          # once: every computed item (seconds; cached in .cache/stats8)
python tools/build.py stats8 -q l              # fast 480p preview
python tools/build.py stats8                   # 1080p30 -> renders/stats8.mp4
python tools/qa_scene.py stats8 Board          # one chapter, silent, with a contact sheet
python tools/lecture_length.py stats8 --floor 50