SStatistics, Built

Stage I · Bachelor's: Foundations

Part 3 of 65

The Family of Distributions

Bachelor'sstarts at this level51 min of film16 chaptersprerequisites: Part 2

Why do the same few shapes keep appearing?

Bortkiewicz's 200 corps-years of deaths by horse kick (109, 65, 22, 3, 1) follow Poisson's formula with mean 0.61. The part explains why, and assembles the family tree of distributions arrow by arrow. The binomial counts lattice paths; many rare chances make a Poisson, and Le Cam's inequality says how closely, even when the chances are unequal. The geometric and the exponential forget the past, sampling without replacement counts the fish in the World's lake, and the Poisson process produces the inspection paradox. The normal is derived three ways (de Moivre, Gauss, Herschel-Maxwell), and chi-squared, t and F arrive as statistics' own distributions, beside a lighthouse whose Cauchy beam has no mean. Order statistics count German tanks, power laws are fitted by likelihood rather than by a straight line, and mixtures and exponential families tie the relatives together before all 24 arrows of the tree are walked.

What you need. Calculus: series, the exponential limit, integration by substitution and polar coordinates.

Hook
Bortkiewicz's horse kicks
Mathematics
binomial→Poisson, three derivations of the normal, χ²/t/F, order statistics, generating functions, the family tree
Built
the family-tree explorer

What you will be able to do

Bachelor's

  • Compute binomial, Poisson, geometric, hypergeometric and exponential probabilities, and say which story (trials, rare events, waiting, sampling without replacement) calls for which.
  • Explain the law of rare events and check a table of counts against a Poisson by its mean and variance.
  • Explain memorylessness and the inspection paradox.

Master's

  • Derive the Poisson limit of the binomial, the Gaussian integral, and the density of the k-th order statistic.
  • Derive the gamma-Poisson and beta-binomial mixtures and their overdispersion from the law of total variance.
  • Write a distribution in exponential-family form and read its mean and variance from A.

PhD

  • State Le Cam's inequality for unequal success probabilities and say what it gives that the pointwise limit does not.
  • State which arrows of the family tree are limits whose proofs need the tools of Parts 6 and 43.

Practice

  • Estimate a population size by capture-recapture, and explain why Chapman's version is preferred to the Lincoln-Petersen ratio.
  • Fit a power-law exponent by maximum likelihood, and explain what goes wrong with least squares on a log-log plot.

Contents

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

  1. 0Deaths by horse kickBachelor's3 min
  2. 1Bernoulli to binomialBachelor's3 min
  3. 2The law of rare eventsBachelor's3 min
  4. 3WaitingBachelor's3 min
  5. 4Without replacementPractice3 min
  6. 5Continuous timeBachelor's3 min
  7. 6The normal, three waysBachelor's4 min
  8. 7TransformationsMaster's4 min
  9. 8The sampling familyBachelor's4 min
  10. 9Order statisticsBachelor's4 min
  11. 10Heavy tailsPractice3 min
  12. 11Generating functionsMaster's3 min
  13. 12Mixtures and hierarchiesMaster's3 min
  14. 13Exponential familiesMaster's3 min
  15. 14The family treeMaster's2 min
  16. 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.

Deaths by horse kickBachelor's3 min

In 1898 a Russian-born statistician working in Germany, Ladislaus von Bortkiewicz, published a small book with a strange subject. For twenty years, 1875 to 1894, the Prussian army had recorded every cavalryman killed by the kick of a horse, corps by corps and year by year. Take ten of the corps: two hundred corps-years. In most of them, nobody died. In some, one man. Rarely two, or three. Once, four. deaths in all, an average of per corps per year. Random misfortunes, as unpredictable as anything could be. And yet Bortkiewicz showed they follow a formula.

Here is his count. A hundred and nine corps-years with no deaths, sixty-five with one, twenty-two with two, three with three, and one with four. If deaths were rare and independent, each soldier on each day carrying a tiny chance, what shape should this be?

Bortkiewicz's answer was a formula Siméon Denis Poisson had derived in 1837. The chance of k events is lambda to the k, times e to the minus lambda, over k factorial, with lambda the average rate, here zero point six one. Multiply by two hundred, and the formula predicts a hundred and eight point seven corps-years with no deaths, sixty-six point three with one, twenty point two with two, four point one with three, under one with four or more. Gold dots, the formula; the historical counts, the bars. They agree closely. The observed mean and sample variance both round to zero point six one. Equality of mean and variance is a property of a Poisson population, not a requirement that every finite sample matches exactly. A law, hidden inside two hundred tragedies.

Bortkiewicz's horse kicks raise the question of this part. Why do the same few shapes keep appearing: the Poisson for rare events, the bell curve for measurements, the exponential for waiting times? The answer is that the distributions of probability are not a zoo but a family, and every member is related to the others by an operation: a sum, a limit, a transformation, a mixture. Here is the family tree, still dark. Each arrow names a relationship. We will derive central examples, map the others, and identify the limit results whose full proofs come later.

What it does: Bortkiewicz's 200 corps-years against 200 × Poisson(0.61); mean and variance; the dark family tree; objectives.; Numbers (computed): 109, 65, 22, 3, 1 vs 108.7, 66.3, 20.2, 4.1, 0.7

1Bernoulli to binomialBachelor's3 min

The simplest random variable is a single trial that succeeds or fails: one if it succeeds, with probability p, zero if not. It's named for Jacob Bernoulli, whose book on probability appeared in 1713. Now repeat it, n times, independently, and count the successes. Draw each repetition as a path: one step right per trial, and one step up for each success. Here n is ten and p is . Each path ends at its number of successes, and piling up the endpoints of many paths builds the distribution of the count.

The formula is two ideas from Part 2. Any one path with k up-steps has probability p to the k times one minus p to the n minus k, because the trials are independent. And the number of such paths is n choose k: choose which of the n trials succeed. Multiply, and you have the binomial distribution. For ten trials with p equal to zero point three, it peaks at three, and the engine computes it exactly.

The mean and variance need no sums over the formula at all. Write the count as a sum of the n trials' indicators. By linearity, the expectation is n times p. By independence, the variances add, and each trial has variance p minus p squared, so the variance is n p times one minus p. For our example, three and two point one, and twenty thousand simulated runs agree.

Binomials describe counts of independent yes-or-no trials with the same success chance. In the World, the share of adults taller than a hundred and eighty centimetres is a parameter: . Poll a hundred adults at random and count the tall ones. Two thousand polls, blue, against the binomial with n a hundred and that p, gold. They agree, mean about and variance about . Strictly, a poll samples without replacement, so the count isn't exactly binomial; chapter four shows why, from a population this large, the difference is tiny. The spread of this count determines a simple random poll's sampling error; Part 8 builds it into an interval.

So the first arrow of the family tree: add up n independent Bernoulli trials, and you get a binomial.

What it does: Lattice paths; the formula from Part 2's counting; mean and variance by indicators; a World poll of 100 adults (how many over 180 cm).; Numbers (computed): p = 0.1446; 2,000 polls: mean 14.42, variance 12.60

2The law of rare eventsBachelor's3 min

Why should horse kicks follow Poisson's formula? Think of each soldier on each day as a trial, with a tiny chance of a fatal kick. Many trials, each with a small chance, the expected number fixed at lambda. That's a binomial with n trials and success chance lambda over n. Regroup it into four factors. As n grows with k fixed, the first factor, k terms each nearly n over n, goes to one. The second doesn't depend on n. The third is one minus lambda over n, to the n, which goes to e to the minus lambda, the definition of the exponential. And the last goes to one. What's left is Poisson's formula. It's called the law of rare events: count many independent rare chances, and you get a Poisson, whatever the details.

Watch it happen. The gold dots are the Poisson with lambda two. A binomial with four trials, each with chance a half, is a poor match. Ten trials with chance a fifth is closer; fifty trials, closer still; and a thousand trials with chance one in five hundred is indistinguishable. To measure the gap we use total variation distance: the biggest difference the two distributions could give to the probability of any event. It falls from to .

How fast does the binomial approach the Poisson? On log scales, the actual distance, blue, falls in a straight line: one over n. Lucien Le Cam proved in 1960 a bound that holds far more generally. For independent trials with different chances p i, the distance between their total and a Poisson with the same mean is at most the sum of the squared chances. For our equal chances that's lambda squared over n, the gold line, always above the truth. And it's why the law of rare events is so robust: the soldiers needn't have equal risks. As long as each chance is small and they're independent, the count is nearly Poisson.

One more property of the Poisson, and it's the one Bortkiewicz checked. Its mean: cancel one k against the factorial, and what's left is lambda times a whole Poisson distribution, which sums to one. Cancel two, and the expectation of X times X minus one is lambda squared. So the variance is lambda too: for a Poisson, mean and variance are equal. The horse kicks pass this test, point six one and point six one. When real counts have a variance far above their mean, something else is going on, and chapter twelve says what.

The second arrow: a binomial with many trials and a small chance of success, n times p held at lambda, becomes a Poisson.

What it does: Binomial(n, λ/n) → Poisson, derived on screen; total variation as n grows; Le Cam's inequality; the Poisson's mean and variance.; Numbers (computed): TV 0.174 (n = 4) → 0.0005 (n = 1,000)

3WaitingBachelor's3 min

Instead of counting successes in a fixed number of trials, wait for the first one. Throw a die until it shows a six. The wait T is k throws if the first k minus one fail and the k-th succeeds: probability one minus p to the k minus one, times p. That's the geometric distribution. Each extra throw multiplies the chance by five sixths, so the bars decay geometrically, which is the name. On average you wait one over p throws: six for a die. The layer-cake formula of Part 2 gives it in one line, and fifty thousand simulated waits agree.

The geometric has a remarkable property. Suppose you've already thrown five times without a six. Throw away the first five bars, rescale the rest so they add to one, and slide them back to the start. They match the original exactly. Having waited tells you nothing about how much longer you'll wait: the die has no memory. In symbols, the chance of waiting t more, given that you've waited s, is the chance of waiting t from scratch. The gambler who thinks a six is overdue is wrong, and this is why.

Memorylessness gives a second, slicker way to the mean, and it's Pascal's method from Part 2. Condition on the first throw. With probability p it's a six, and you're done in one throw. Otherwise you've used one throw, and because the die has no memory, you're back where you started: the rest of the wait is a fresh copy of T. So the expected wait satisfies an equation involving itself: p times one, plus one minus p times one plus the expected wait. Solve it, and the expected wait is one over p. This first-step analysis solves waiting problems far harder than this one, from the gambler's ruin to Markov chains in Part 7.

Wait for more than one success and you get the negative binomial. The wait for the third six is k throws if the k-th throw is a six and exactly two of the first k minus one were: k minus one choose two, times p cubed, times the failures. It's also a sum: the wait for the first six, plus the further wait for the second, plus the wait for the third, three independent geometric waits, because the die has no memory. So the mean is r over p, eighteen. Count failures instead of total trials, subtracting r, and the negative binomial has a second life as a Poisson count whose rate is itself random, and in that guise it's the workhorse for counts more variable than a Poisson allows. We'll derive that in chapter twelve.

Two more arrows: waiting for the first success turns Bernoulli trials into a geometric, and adding r independent geometric waits gives a negative binomial.

What it does: The geometric; memorylessness shown by rescaling the tail; first-step analysis (Pascal's method) for E T = 1/p; the negative binomial (total trials; subtract the success count for the failures convention).; Numbers (computed): simulated mean wait 5.996; P(T > 8 | T > 5) = 0.578 vs 0.579

4Without replacementPractice3 min

The World has a lake, and the lake has fish. How many? You can't count them; they won't hold still. So catch some, five hundred, tag them, and let them go. Wait for them to mix back in, then catch another sample, four hundred. Count how many of the second catch carry tags: . From those three numbers, estimate the size of the whole population. The method is called capture–recapture, and it's how ecologists count everything from fish to whales; Laplace used the same ratio in 1802 to estimate the population of France.

First, what should the number of tagged fish look like, if there are N fish in all? The second catch is four hundred fish drawn without replacement. The chance of exactly m tagged is the number of ways to pick m of the tagged fish and the rest from the untagged, over the number of possible catches. That's the hypergeometric distribution. With the World's true N, it's centred near twenty-five. And it's almost exactly a binomial: when the lake is much bigger than the catch, taking a fish out barely changes the chances for the next one, so sampling without replacement is nearly sampling with it.

Now estimate. The share of the lake that's tagged, five hundred over N, should be about the share of the catch that's tagged, m over four hundred. Solve for N: five hundred times four hundred, over , about fish. It's called the Lincoln–Petersen estimate. It assumes a closed population, retained tags, mixing and comparable capture chances; with no recaptured tags this ratio has no finite estimate. And because this is the World, we can check it. The lake actually holds fish. Our estimate is off by a fifth. Was the method wrong, or were we unlucky?

In the World we can find out, by doing the whole experiment again, two thousand times. Here are two thousand Lincoln–Petersen estimates. They spread from about five thousand to fourteen thousand; ours was in the low tail. So partly we were unlucky. But their average is , above the truth: the estimate is biased upward, because dividing by a random m exaggerates the small values of m. In 1951 Douglas Chapman proposed adding one to each count, and his version averages , almost exactly right. Bias, and how to remove it, is the subject of Part 9.

The fourth arrow: sampling without replacement from a population much larger than the sample is almost the same as sampling with replacement, so the hypergeometric becomes the binomial.

What it does: The hypergeometric; capture–recapture on the World's lake; Lincoln–Petersen and Chapman over 2,000 repetitions.; Numbers (computed): N = 8,107; one estimate 6,452; L–P mean 8,525, Chapman 8,198

5Continuous timeBachelor's3 min

Now let rare events happen in continuous time. Buses that run without a timetable, on average one every ten minutes, arriving at random. Chop time into tiny slices; in each, a bus arrives with a tiny probability, independently. By the law of rare events, the number in any hour is Poisson, with mean six. That's the Poisson process. Two thousand simulated hours agree: mean and variance both about six, and the Poisson shape.

What about the gaps between buses? The gap after a bus is longer than t exactly when no bus comes in the next t minutes, and the Poisson count for that interval is zero with probability e to the minus lambda t. So the gaps are exponential, with mean ten minutes. The exponential is the continuous geometric, and it's memoryless too: having waited five minutes, you can expect to wait ten more. The time until the third bus is a sum of three independent gaps, and its distribution is the gamma. Simulated gaps and waits, blue, match the formulas, gold.

Poisson processes combine beautifully. Two independent bus routes stop at the same corner, one every ten minutes on average and one every fifteen, each a Poisson process. Watch for either bus, and the arrivals merge into one Poisson process whose rate is the sum: a tenth plus a fifteenth, one bus every six minutes. Run it the other way: if each bus has room for you with probability point six, independently, the buses with room form a Poisson process too, with the rate multiplied by point six. Superposition and thinning, and simulation confirms both: mean gaps of six minutes and sixteen and two thirds.

And now a paradox. You walk to the stop at a random moment. How long, on average, until the next bus? The gaps average ten minutes, so surely, landing somewhere in a gap, you wait half of one: five. Simulate it: twenty thousand passengers, arriving at random. They wait minutes on average, not five. And the gap they land in averages minutes, twice the average gap. Both facts have the same cause. Long gaps cover more of the clock, so a random moment is more likely to fall in a long one. And memorylessness says that from the moment you arrive, the wait is a fresh exponential, ten minutes on average. It's called the inspection paradox, and it's everywhere: the class sizes students report are bigger than the average class, and, on average, a randomly chosen person's friends have more friends than you.

Three arrows: the gaps of a Poisson process are exponential; sums of exponential gaps are gamma; and the geometric, shrunk to infinitely many tiny trials, becomes the exponential.

What it does: The Poisson process; exponential gaps; the gamma wait; superposition and thinning; the inspection paradox.; Numbers (computed): wait 10.04 min, gap you land in 20.09 min

6The normal, three waysBachelor's4 min

The bell curve was found first as an approximation. In 1733 Abraham de Moivre, a French Protestant exile living in London and making his living as a consultant to gamblers, wanted binomial probabilities for large numbers of tosses, where the factorials are hopeless. Rescale the binomial so it's centred and has unit spread. For ten tosses, a lumpy histogram; for fifty, smoother; for two hundred, a smooth curve. De Moivre found the limit, one over root two pi, times e to the minus z squared over two, using the approximation to n factorial that we now call Stirling's formula. It's already accurate for small n. This is the first central limit theorem, proved in general in Part 6.

The second way came from astronomy. In 1809 Carl Friedrich Gauss asked: if we average repeated measurements of a star's position, for which law of errors is the average the most probable value? Write the error density as f, and its logarithm as g. The average maximizes the likelihood for every possible data set exactly when the derivative of g balances whenever the deviations balance. That forces g prime to be linear, and integrating gives e to the minus c u squared over two: the same curve. This characterizes a smooth positive error density under independent, identically distributed errors. It does not establish those assumptions for real measurements, but it bound the normal to least squares, and Laplace soon connected both to sums of many small errors.

The third way is the most beautiful. Throw darts at a target, or think of the velocity of a gas molecule. Suppose the errors in the two directions are independent, and their joint law looks the same in every direction: it doesn't care how you turn the axes. We assume a nondegenerate, regular density. Here's a cloud of independent normal pairs; turn it, and nothing changes. Independence says the joint density is f of x times f of y; rotation invariance says it depends only on the distance from the centre, x squared plus y squared. A product that's a function of a sum of squares: the only solutions are exponentials of x squared. John Herschel gave this argument in 1850, and James Clerk Maxwell used it ten years later to derive the distribution of molecular velocities.

One loose end: where does the root two pi come from? Call the integral of e to the minus x squared over two I. The integrand has no elementary antiderivative. But I squared is the same integral in two variables, over the whole plane: the volume under the two-dimensional bell. Herschel's rotation invariance suggests polar coordinates. The area of a thin ring is r d r d theta, and that extra r makes the integral easy: two pi. So I is root two pi, and the normal density, with its constant, integrates to one. It's Poisson's trick, and it's one of the great one-line proofs in mathematics.

With the constant in hand, the normal gives the most quoted numbers in statistics. Within one standard deviation of the mean lies sixty-eight point three percent of the probability; within two, ninety-five point four; within three, ninety-nine point seven. The World's men's heights are close to normal by construction, and their actual fractions match to a tenth of a percent: , and . But the rule is a fact about the normal, not about data: for the World's incomes it fails badly, as Part 1's heavy tails would predict.

Two arrows into the normal: de Moivre's, from the binomial with many trials, and the Poisson with a large mean, which is a sum of many small Poissons.

What it does: de Moivre (1733) and Stirling; Gauss (1809); Herschel–Maxwell rotation invariance; ∫e^{−x²/2} = √(2π) in polar coordinates; 68–95–99.7 on the World's men.; Numbers (computed): 68.24%, 95.41%, 99.73% vs 68.27%, 95.45%, 99.73%

7TransformationsMaster's4 min

If X has a known distribution, what's the distribution of a function of X? Start with a uniform random number between zero and one, the kind every computer produces. Take minus its logarithm. The result is never negative, and it piles up near zero. The CDF method says exactly how. The chance that minus log U is at most y is the chance that U is at least e to the minus y, which is one minus e to the minus y: the exponential distribution, gold. Run this idea backwards and it lets a computer turn uniform random numbers into draws from any distribution at all, the subject of Part 7.

The general rule is about conserving probability. For a smooth one-to-one transformation, Y lands in a tiny interval near y exactly when X lands in the matching interval near x. The two probabilities are equal, but the intervals have different widths, so the density of Y is the density of X at the matching point, times the stretch factor, the derivative of the inverse. Where the map stretches, the density thins; where it squeezes, the density piles up. In several dimensions a smooth invertible map uses the absolute Jacobian of its inverse. Multiple inverse branches must be added. That determinant is determinant: how much the map changes small areas, or volumes.

Here's a two-dimensional transformation that's in every statistics library. In 1958 George Box and Mervin Muller showed how to turn two independent uniforms into two independent normals. Start with a cloud of points spread evenly over a square. Use the first coordinate to choose a radius, the square root of minus twice its log, and the second to choose an angle. Watch the square become a bell. Why does it work? Half the squared radius is minus log U one, which we just saw is exponential, and the angle is uniform; that's exactly the polar description of two independent normals, Herschel's rotation invariance built in. The Jacobian makes it precise, and the sample's mean and SD come out zero and one.

One last transformation, and it explains Part 1's incomes. Take sixty random factors, each between point eight and one point two five, and multiply them: growth that compounds, a year of good luck or bad luck at a time. The products are wildly skewed. But their logarithms are sums of sixty small random terms, and sums make bells: the logarithm is approximately normal, with skewness essentially zero; a finite sum of log-uniform terms is not exactly Gaussian. A variable whose logarithm is normal is called log-normal. Under central-limit conditions, independent small effects give approximately normal sums and approximately log-normal products. This is one useful model for positive skewed measurements; it does not establish a log-normal law for every income, city size or particle.

Four arrows from transformations: minus the log of a uniform is exponential; Box and Muller turn two uniforms into normals; e to a normal is log-normal; and e to an exponential is a Pareto.

What it does: The CDF method (−log U); the Jacobian in 1D and nD; Box–Muller (1958) as a square morphing into a bell; the log-normal as a product of 60 factors.; Numbers (computed): skewness 4.6 → −0.005 after the log

8The sampling familyBachelor's4 min

Some distributions are created by statistics itself, as the laws of the quantities we compute from normal data. The first is the sum of k squared independent standard normals: chi-squared with k degrees of freedom. Its mean is k, since each square has mean one, and its variance two k. Here it is for one, two, three and five degrees of freedom. Twenty thousand sums of three simulated squares fall right on the curve for k equals three. Friedrich Helmert found it in 1876 as the law of the sample variance, and Karl Pearson in 1900 made it the basis of his famous test. And it's a relative we already know: chi-squared is a gamma, with shape k over two and scale two.

The second was found in a brewery. William Sealy Gosset worked for Guinness in Dublin, testing barley and yeast in small samples. Guinness let him publish only under a pseudonym, Student, and in 1908 Student worked out the law of the sample mean minus the population mean, divided by its estimated standard error. In modern form: a standard normal, divided by the square root of an independent chi-squared over its degrees of freedom. Compared with the normal, grey, its tails are heavier, because the estimated spread is itself uncertain. As the degrees of freedom grow the estimate firms up and t becomes the normal. With one degree of freedom its tails are so heavy that it has no mean at all: that's the Cauchy. Part 8 puts t to work.

The third is a ratio. Divide one chi-squared by its degrees of freedom, and another, independent one by its own, and take the ratio. Ronald Fisher studied it in 1924, and George Snedecor named it F in his honour. It's the law of a ratio of two estimated variances, and it powers the analysis of variance in Parts 12 and 13.

The Cauchy has a vivid story. A lighthouse stands a kilometre off a straight shore. Its lamp spins, and flashes at a random moment, so in a random direction. Condition on the beam pointing toward the shore, and record independent flashes. The position is the tangent of a uniform angle, and the CDF method gives its density: one over pi times one plus x squared, the Cauchy. Now average the recorded positions. For normal data, green, the running mean settles down. For the lighthouse, red, it never does: every so often a flash at a shallow angle lands kilometres down the coast and drags the average away. The Cauchy has no mean, and the average of Cauchy draws is just another Cauchy, no more concentrated than one draw. The laws of averages in Part 6 will need a condition, and this is why.

Six arrows for the sampling family: squares of normals give chi-squared, a special gamma; a normal over the root of a chi-squared gives Student's t; a ratio of chi-squareds gives F; t with one degree of freedom is Cauchy, and with infinitely many, the normal.

What it does: χ² (Helmert 1876, Pearson 1900) and its gamma identity; Student's t (1908); F (Fisher 1924, Snedecor 1934); the lighthouse Cauchy and its running mean.; Numbers (computed): χ²₃ simulated mean 2.99, variance 6.23

9Order statisticsBachelor's4 min

Sort a sample, and its values become order statistics: the smallest, the second smallest, up to the largest. Here are ten uniform draws, sorted. What's the distribution of the k-th smallest, say the third? For it to sit in a tiny window at x, we need k minus one of the draws below x, one in the window, and the rest above. That's a multinomial count, from Part 2: n factorial over the three factorials, times the chance of each part. Divide by the window's width and you have the density of the k-th order statistic, for independent, identically distributed draws from a distribution with a density.

For uniform draws, F of x is just x, and the formula becomes a polynomial: x to the k minus one times one minus x to the n minus k. That's the beta distribution. Here are twenty thousand simulated samples of ten: the smallest, the third, the eighth and the largest of each, against the beta densities. The smallest hugs zero, the largest hugs one, and the k-th averages k over n plus one, as if the ten points split the interval into eleven equal gaps on average. The beta has another parent too: if X and Y are independent gammas with the same scale, X over X plus Y is beta. That's the arrow from gamma, and it's why the beta returns in Part 15 as the natural prior for a probability.

Put k in the middle and you get the law of the sample median. For an odd number of uniform draws, n equals two m plus one, the median is the m plus first order statistic, a symmetric beta. With five draws it's broad; with twenty-one, narrower; with a hundred and one, sharply peaked at a half. Its standard deviation shrinks like one over twice the square root of n, the same root n rate as the mean. The median has a sampling distribution of its own, and Part 30 uses it to build estimators that heavy tails can't break.

Order statistics once helped win a war. During the Second World War the Allies wanted to know how many tanks Germany was producing. Captured tanks carried serial numbers, numbered in sequence. Here are eight serials from a factory that, in our simulation, built three hundred. The largest serial, , is a lower bound. But the sorted serials split the range into k plus one gaps of missing serials, with expected size N minus k over k plus one. In particular the expected maximum is k times N plus one over k plus one. Solve that expectation identity: the unbiased estimate is the maximum times one plus one over k, minus one, here . Over five thousand repetitions it averages , unbiased, while the maximum alone falls short. After the war, the statisticians' estimates turned out to be far closer to Germany's own records than the intelligence reports had been. Part 9 proves that this estimator is the best unbiased one.

Two arrows into the beta: the order statistics of uniforms, and the share X over X plus Y of two independent gammas with the same scale.

What it does: The density of the k-th; uniform order statistics are beta; the sample median; the German tank problem (Ruggles & Brodie 1947).; Numbers (computed): 8 serials, N = 300: estimate 270; 5,000 repetitions average 300.0

10Heavy tailsPractice3 min

Part 1 met heavy tails in the World's incomes. Here's the distribution behind them. A Pareto tail: the chance of exceeding x falls like a power of x, not exponentially. On log–log axes a power law is a straight line with slope minus alpha, while an exponential tail falls off a cliff. Moments of order alpha and above are infinite in the idealized Pareto law. The World uses a tail exponent of two point one: its generating law has finite variance but no third moment. Its fixed finite population has finite empirical moments of every order, although rare high incomes can make sample variances unstable. And the logarithm of a Pareto variable is exponential: the arrow we drew in chapter seven.

A power law also shows up as Zipf's law. Rank the World's two hundred towns by population and plot log population against log rank. The points fall near a line with slope about : the second-largest town has about half the population of the largest, the tenth about a tenth. Felix Auerbach noticed this for German cities in 1913, and George Zipf for cities and words in 1949. In the World it's no discovery: we built the towns with Zipf weights in Part 1, and we're only reading them back.

Pareto's own observation was about concentration. For a whole-population Pareto model with exponent alpha greater than one, the richest fraction q of people hold a share q to the one minus one over alpha of the total. With alpha about one point one six, the top twenty percent hold eighty percent: the famous eighty–twenty rule. Heavier tails, smaller alpha, concentrate more. In the World, the top twenty percent of adults earn percent of all income, and the top one percent . Far from eighty–twenty: most of the World's incomes come from its log-normal body, and only a thin slice from the Pareto tail.

Power laws are easy to claim and hard to establish. The tempting method: draw a histogram on log–log axes and fit a straight line by least squares. Here's one simulated sample of five hundred from a power law whose density falls like x to the minus two and a half; in this convention, the tail exponent of the card above is one less. Repeat that four hundred times. The least-squares slopes, red, average : biased, and noisy. The maximum likelihood estimate, green, a closed formula, averages , with half the spread. Aaron Clauset, Cosma Shalizi and Mark Newman showed in 2009 that the log–log method is systematically misleading, and that many published power laws, tested properly, were no better than a log-normal. A straight line on a log–log plot is a hypothesis, not a proof.

What it does: Pareto and the log–log line; Zipf on the World's 200 towns; the 80/20 rule against the World's incomes; log–log least squares vs maximum likelihood (Clauset, Shalizi & Newman 2009).; Numbers (computed): slope −1.05; top 20% earn 43.8%; LS 2.24 ± 0.14 vs MLE 2.50 ± 0.07 (true 2.5)

11Generating functionsMaster's3 min

Part 2 represented finite counting distributions as polynomials. For distributions whose moment generating function is finite around zero, the idea extends to a power series. The moment generating function of X is the expectation of e to the t X, a function of t. Expand the exponential, and by linearity every moment of X appears as a coefficient, with t to the k over k factorial. So the k-th derivative at zero is the k-th moment, which is where the name comes from. It's Part 2's probability generating function, with s replaced by e to the t.

For the standard normal the moment generating function takes one trick. Write out the integral. Complete the square in the exponent: t z minus z squared over two is t squared over two minus z minus t, squared, over two. What's left is a normal density shifted by t, which integrates to one, so M of t is e to the t squared over two. For a normal with mean mu and variance sigma squared, shift and scale: e to the mu t plus sigma squared t squared over two. Differentiate at zero and out come the mean and the second moment.

Like Part 2's polynomials, moment generating functions turn sums into products. For independent X and Y, the generating function of the sum is the product of theirs. A Poisson with mean lambda has generating function e to the lambda times e to the t minus one. Multiply two of them and the exponents add: the sum of independent Poissons is Poisson, with the means added. Fifty thousand simulated sums agree. That last step needs one more fact: a moment generating function that's finite near zero determines its distribution uniquely. It's true, and Part 43 proves it.

Uniqueness turns generating functions into a proof machine. Chapter five claimed that the wait for the third bus is gamma; here's the proof. The exponential's moment generating function is lambda over lambda minus t. The wait for the k-th bus is a sum of k independent exponential gaps, so its generating function is that, to the k. And the gamma density, integrated against e to the t x with one substitution, gives exactly the same function. Same generating function, same distribution: the k-th arrival of a Poisson process is gamma.

Some distributions, like the Cauchy, have no moment generating function: e to the t X has infinite expectation for every t except zero. The cure is to use an imaginary t. The characteristic function, the expectation of e to the i t X, always exists, because e to the i t X has size one. For the normal it's e to the minus t squared over two; even the Cauchy has one, e to the minus the absolute value of t. Characteristic functions are how Laplace first glimpsed the central limit theorem, and how Part 6 will prove it.

What it does: MGFs and moments; the normal's by completing the square; Poisson sums; sums of exponentials are gamma; characteristic functions.

12Mixtures and hierarchiesMaster's3 min

So far every parameter has been a fixed number. Let the parameter itself be random. Choose a success chance p from a beta distribution, then run twenty trials with that p. Each unit, a player, a hospital, a batch, has its own rate. The count is beta-binomial. Compared with a binomial with the same average chance, grey, it's far more spread out: variance against about five. That extra spread is called overdispersion, and it is common in real counts, although underdispersion is possible too.

Where does the extra variance come from? The law of total variance splits it in two: the average variance within units, given their p, plus the variance of their means between units. For our mixture, the binomial variance twenty p times one minus p, averaged over the beta, is four; the variance of twenty p is sixteen; total twenty, exactly what the simulation found. This decomposition, within plus between, is the seed of the analysis of variance in Part 13 and of the mixed models in Part 25.

Now chapter three's promise. Give each unit its own Poisson rate, drawn from a gamma distribution: some corps more dangerous than others, some roads more accident-prone. The resulting counts are exactly negative binomial in the failures convention, starting at zero. Add the shape parameter r to recover chapter three's total-trials convention when r is an integer. Integrating the Poisson against the gamma gives its formula. The mean is three, but the variance is about seven and a half, where a Poisson's would equal its mean. That's why the negative binomial is the standard model for overdispersed counts, in Part 24.

Mixtures explain heavy tails too. Draw a normal, but first choose its variance at random, from an inverse chi-squared: most of the time a modest spread, occasionally a huge one. The mixture is exactly Student's t. Every component has light normal tails, yet the occasional wide component makes the mixture's tails heavy. It's the basis of robust statistical models, in Part 30.

The last two arrows are mixtures: a Poisson whose rate is gamma is negative binomial, and a binomial whose success chance is beta is beta-binomial.

What it does: Beta-binomial overdispersion; the law of total variance (4 + 16 = 20); gamma–Poisson = negative binomial; a normal scale mixture is t.; Numbers (computed): variance 20.0 vs 4.9; NB mean 3.04, variance 7.71

13Exponential familiesMaster's3 min

Look across the family tree and one formula keeps appearing. The density is a function of x alone, times the exponential of a parameter eta times a statistic T of x, minus a function A of eta. Eta is the natural parameter, T is the sufficient statistic, and A, the log-normalizer, is whatever makes the density integrate to one. Families of this form are called exponential families. Three mathematicians, Darmois, Koopman and Pitman showed independently in the mid-1930s that, under regularity conditions including parameter-independent support, these are the families in which a fixed number of summaries can capture everything a sample of any size says about the parameter.

Many of our distributions fit the form. The Bernoulli: write p to the x times one minus p to the one minus x as an exponential, and the natural parameter is the log odds, the logit. The Poisson: the natural parameter is log lambda. The normal with known variance: the mean itself when the known variance is one, as in this table. The exponential, and the binomial with a fixed number of trials. Not everything fits: the uniform on zero to theta, whose support moves with the parameter, and the usual Cauchy location-scale and Student location-scale or degrees-of-freedom families. Heavy tails alone are not an exclusion: a Pareto with known lower threshold is an exponential family.

The log-normalizer is more than a constant: it generates the moments. The density integrates to one for every value of eta. Differentiate that identity with respect to eta. The derivative of A is the expectation of the sufficient statistic. Differentiate again and A's second derivative is its variance, which is never negative, so A is convex. For the Poisson, A is e to the eta, and both derivatives give lambda: mean and variance equal, as we've seen. Numerical derivatives confirm it.

Why care? Because the form makes almost everything easy. The sum of T over a sample carries all the information about the parameter: that's sufficiency, Parts 9 and 45. Maximum likelihood reduces to matching A prime to the sample average of T. Make the natural parameter a linear function of covariates and you have the canonical-link generalized linear models of Part 24, logistic and log-link Poisson regression among them. Other GLMs use other links. And with a conjugate prior, Bayesian updating stays inside that prior family, in Part 15.

What it does: h(x) exp(ηT − A(η)); Bernoulli, Poisson, normal, exponential, binomial; A′ = E T, A″ = Var T; what the form buys (Parts 9, 15, 22, 24).; Numbers (computed): A′ checked numerically

14The family treeMaster's2 min

Here is the whole tree, dark again, so we can walk it once more. On the discrete side: Bernoulli trials add up to the binomial; sampling without replacement from a big population is nearly binomial; the binomial with many rare chances is Poisson; and waiting for successes gives the geometric and the negative binomial. In continuous time, the gaps of a Poisson process are exponential, the exponential is the geometric's limit, and sums of exponentials are gamma. The normal arrives from the binomial, de Moivre's arrow, and from the Poisson with a large mean. Transformations link the uniform to the exponential and, by Box and Muller, to the normal, the normal to the log-normal, and the exponential to the Pareto. The sampling family grows from the normal: chi-squared, a special gamma, then Student's t, Fisher's F, and at the edges of t, the Cauchy and the normal again. Order statistics of uniforms are beta, and so is X over X plus Y for independent gammas with a common scale. And mixing closes two loops: a Poisson with a gamma rate is negative binomial, and a binomial with a beta chance is beta-binomial. Twenty-four relationships, introduced through derivations and simulation. Some limit proofs await Part 6, and the general theory returns in Part 43. This is why the same few shapes keep appearing. They aren't independent inventions; they're relatives, and the operations that relate them, sums, limits, transformations and mixtures, are the operations nature performs.

Our tree is a small part of a much bigger one. In 2008 Lawrence Leemis and Jacquelyn McQueston published a chart of seventy-six distributions and the arrows between them. Ours has eighteen: the ones this degree will use every day. And one thing is conspicuously missing: every distribution here describes one variable. Real data come in rows of many variables at once, and to describe them we need matrices.

What it does: All 24 relationships walked and lit; Leemis & McQueston (2008).

Recap, problems, and the road aheadAll tracks3 min

Part three in fourteen lines. The horse-kick counts fit a Poisson model. The binomial counts paths, with mean n p and variance n p q. Many rare chances make a Poisson, and Le Cam said how closely. The geometric and the exponential forget the past. Sampling without replacement is hypergeometric, and the capture–recapture ratio is biased. You land in long gaps between buses. The normal came three ways. Densities transform with the Jacobian, and two uniforms make two normals. Chi-squared, t and F are statistics' own distributions, and the lighthouse has no mean. Uniform order statistics are beta, and they counted tanks. Power laws need likelihood, not straight lines. Generating functions turn sums into products; mixtures make overdispersion and heavy tails; and exponential families tie most of it together.

And where it comes back. The normal and sums return in the laws of averages of Part 6 and the sampling theory of Part 8; chi-squared, t and F in every interval and test from Part 8 on. Order statistics and the tank problem return in estimation and in rank methods. Exponential families are the backbone of estimation, likelihood and generalized linear models. Mixtures become Bayesian and mixed models. The Poisson process returns in time series and survival analysis, heavy tails in robust statistics, and capture–recapture in surveys and missing data.

Six problems, with full solutions in the README. Splitting a Poisson sum; why only the exponential is memoryless; two transformations of a uniform; the first of several buses; a capture–recapture estimate; and the gamma as an exponential family. Pause here if you want to try them.

The books and papers this part follows are on screen and in the README: Blitzstein and Hwang, Casella and Berger, the encyclopedic volumes of Johnson, Kotz and Balakrishnan, Feller and Stigler, and the original papers, from Poisson to Clauset, Shalizi and Newman.

Three parts of sixty-five. We now have a family of distributions for one variable at a time. But every real data set is a table: heights and weights and incomes and ages, measured on the same people, moving together. To see the shape of a cloud of points in many dimensions, its directions of greatest spread, its correlations, its projections, we need the language of matrices. That's Part 4.

Where it goes next. The normal and sums return in the laws of averages of Part 6 and the sampling theory of Part 8; chi-squared, t and F in every interval and test from Part 8 on; the tank problem in the estimation of Part 9; exponential families in Parts 9, 15, 22 and 24; the full limit proofs come in Parts 6 and 43.

Key results

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

Law of rare events (Le Cam)\(\displaystyle d_{\mathrm{TV}}\Bigl(\sum_{i=1}^n \operatorname{Bern}(p_i),\ \operatorname{Poisson}\bigl(\textstyle\sum_i p_i\bigr)\Bigr)\le\sum_{i=1}^n p_i^2\ \Bigl(=\tfrac{\lambda^2}{n}\text{ when }p_i=\tfrac{\lambda}{n}\Bigr)\)
Memorylessness\(\displaystyle P(T>s+t\mid T>s)=P(T>t)\quad\allowbreak \text{for }\allowbreak \text{geometric }\allowbreak \text{and }\allowbreak \text{exponential }T\)
The Gaussian integral\(\displaystyle \int_{-\infty}^{\infty}e^{-x^2/2}\,dx=\sqrt{2\pi}\)
Order statistics of n uniforms\(\displaystyle U_{(k)}\sim\operatorname{Beta}(k,\ n-k+1),\qquad\allowbreak \mathbb E\,U_{(k)}=\frac{k}{n+1}\)
Mixtures overdisperse\(\displaystyle X\mid\Lambda\sim\operatorname{Poisson}(\Lambda)\ \Longrightarrow\ \operatorname{Var}X=\mathbb E\Lambda+\operatorname{Var}\Lambda\ \ge\ \mathbb E X\)
Exponential family\(\displaystyle f(x\mid\eta)=h(x)\exp\{\eta\,T(x)-A(\eta)\},\qquad\allowbreak A'(\eta)=\mathbb E\,T(X),\quad\allowbreak A''(\eta)=\operatorname{Var}T(X)\)

Try it

Lab 3 · The law of rare events, with Le Cam's bound

Compare Bortkiewicz's 200 corps-years with 200 x Poisson(0.61), then measure the exact total variation distance between a sum of rare Bernoulli trials and a Poisson, with equal and with unequal chances, against Le Cam's bound: the sum of the squared chances.

Figure produced by Lab 3: The law of rare events, with Le Cam's bound
Produced by the lab below, seed 0, in 0.2 s.
python -m videos.stats.labs 3 needs numpy, scipy, matplotlib · download lab03.py · source on GitHub
corps-years with 0, 1, 2, 3, 4 deaths       109  65  22  3  1
200 x Poisson(0.61)                         108.7  66.3  20.2  4.1  0.7
mean and variance of the counts             0.610 and 0.611   (a Poisson's are equal)
chi-squared distance from the Poisson       0.32 on 2 df   (p = 0.85)
TV(Binomial(4, 1/2), Poisson(2))            0.174   Le Cam's bound 1.000
TV(Binomial(1000, 1/500), Poisson(2))       0.00045   Le Cam's bound 0.00400
log-log slope of the distance for n >= 100  -1.002   (1 / n would be -1)
600 unequal risks summing to 0.61: TV       0.00072   Le Cam's bound 0.00186   (equal risks: 0.00024)

Rare, independent chances add up to a Poisson whether or not they are equal: the distance is at most the sum of the squared chances, and for equal chances it falls like 1 / n.
The code (100 lines; it asserts its own result)
"""Lab 3: the horse kicks against Poisson's formula, and how fast many rare chances become a Poisson."""

import numpy as np
from scipy import stats

from videos.coursekit import labs
from explainer.stats import museum
from explainer.stats.kit import limits

TITLE = "The law of rare events, with Le Cam's bound"
GOAL = ("Compare Bortkiewicz's 200 corps-years with 200 x Poisson(0.61), then measure the exact total variation "
        "distance between a sum of rare Bernoulli trials and a Poisson, with equal and with unequal chances, against "
        "Le Cam's bound: the sum of the squared chances.")
TASKS = [
    "Give a tenth of the 600 soldiers ten times the risk of the rest, keeping the total at 0.61. How much does the "
    "distance to the Poisson grow, and does Le Cam's bound still hold?",
    "Make the kicks contagious: draw each corps-year's rate from a gamma distribution with mean 0.61. Compare the "
    "variance of the counts with their mean.",
    "Replace lambda = 2 by lambda = 0.61 in the right-hand panel. Does the distance still fall like 1 / n?",
]


def bernoulli_sum_pmf(ps) -> np.ndarray:
    """The exact distribution of a sum of independent Bernoulli(p_i): one convolution per trial."""
    pmf = np.array([1.0])
    for p in ps:
        pmf = np.convolve(pmf, [1 - p, p])
    return pmf


def tv_to_poisson(pmf, lam) -> float:
    k = np.arange(len(pmf))
    return float(0.5 * (np.abs(pmf - stats.poisson.pmf(k, lam)).sum() + stats.poisson.sf(k[-1], lam)))


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

    # 1. Bortkiewicz's horse kicks against 200 x Poisson(lambda).
    k, counts = np.array(museum.HORSEKICK_K), np.array(museum.HORSEKICK_N)
    total = counts.sum()
    lam = (k * counts).sum() / total
    var = ((k - lam) ** 2 * counts).sum() / (total - 1)
    expected = total * stats.poisson.pmf(k, lam)
    expected[-1] = total * stats.poisson.sf(k[-2], lam)  # 4 or more
    lab.row("corps-years with 0, 1, 2, 3, 4 deaths", "  ".join(str(c) for c in counts))
    lab.row("200 x Poisson(0.61)", "  ".join(f"{e:.1f}" for e in expected))
    lab.row("mean and variance of the counts", f"{lam:.3f} and {var:.3f}   (a Poisson's are equal)")
    obs3 = np.append(counts[:3], counts[3:].sum())  # pool 3 and more, so every expected count is near 5 or above
    exp3 = np.append(expected[:3], expected[3:].sum())
    chi2 = ((obs3 - exp3) ** 2 / exp3).sum()
    pval = stats.chi2.sf(chi2, len(obs3) - 2)
    lab.row("chi-squared distance from the Poisson", f"{chi2:.2f} on 2 df   (p = {pval:.2f})")
    assert abs(lam - 0.61) < 1e-9 and abs(var - lam) < 0.01, "mean and variance both round to 0.61"
    assert np.allclose(expected, [108.7, 66.3, 20.2, 4.1, 0.7], atol=0.06), "the film's table"
    assert pval > 0.2, "the horse kicks are consistent with a Poisson"

    # 2. Equal chances: Binomial(n, lambda / n) against Poisson(lambda), exactly.
    lam2 = 2.0
    ns = np.unique(np.round(np.logspace(np.log10(4), 4, 40)).astype(int))
    tv = np.array([limits.tv_binomial_poisson(int(n), lam2 / n) for n in ns])
    bound = np.array([limits.le_cam_bound(np.full(int(n), lam2 / n)) for n in ns])
    tv4, tv1000 = limits.tv_binomial_poisson(4, 0.5), limits.tv_binomial_poisson(1000, 0.002)
    lab.row("TV(Binomial(4, 1/2), Poisson(2))", f"{tv4:.3f}   Le Cam's bound {min(1.0, lam2 ** 2 / 4):.3f}")
    lab.row("TV(Binomial(1000, 1/500), Poisson(2))", f"{tv1000:.5f}   Le Cam's bound {lam2 ** 2 / 1000:.5f}")
    slope = np.polyfit(np.log(ns[ns >= 100]), np.log(tv[ns >= 100]), 1)[0]
    lab.row("log-log slope of the distance for n >= 100", f"{slope:.3f}   (1 / n would be -1)")
    assert abs(tv4 - 0.174) < 0.001 and abs(tv1000 - 0.0005) < 0.0001, "the film's two distances"
    assert np.all(tv <= bound), "Le Cam's bound holds at every n"
    assert abs(slope + 1) < 0.02, "the distance falls like 1 / n"

    # 3. Unequal chances: 600 soldiers whose risks differ, summing to 0.61.
    raw = rng.gamma(0.5, 1.0, 600)  # a few careless riders carry much of the risk
    ps = 0.61 * raw / raw.sum()
    pmf = bernoulli_sum_pmf(ps)
    tv_unequal, bound_unequal = tv_to_poisson(pmf, ps.sum()), limits.le_cam_bound(ps)
    tv_equal = limits.tv_binomial_poisson(600, 0.61 / 600)
    lab.row("600 unequal risks summing to 0.61: TV", f"{tv_unequal:.5f}   Le Cam's bound {bound_unequal:.5f}   (equal risks: {tv_equal:.5f})")
    assert tv_equal < tv_unequal <= bound_unequal, "unequal risks are further from the Poisson, but inside the bound"
    assert bound_unequal < 0.02, "and still close: the count is nearly Poisson"
    simulated = (rng.random((200, 600)) < ps).sum(1)  # one simulated table of 200 corps-years
    sim_counts = np.array([(simulated == j).sum() for j in range(4)] + [(simulated >= 4).sum()])
    lab.note = ("Rare, independent chances add up to a Poisson whether or not they are equal: the distance is at most "
                "the sum of the squared chances, and for equal chances it falls like 1 / n.")

    fig, ax = labs.figure(2, size=(11, 4.2))
    ax[0].bar(k - 0.2, counts, width=0.4, color=labs.BLUE, alpha=0.8, label="Bortkiewicz's 200 corps-years")
    ax[0].bar(k + 0.2, sim_counts, width=0.4, color=labs.TEAL, alpha=0.6, label="one simulation, 600 unequal risks")
    ax[0].plot(k, expected, "o", color=labs.GOLD, ms=8, label="200 x Poisson(0.61)")
    ax[0].set(title="Deaths by horse kick per corps per year", xlabel="deaths (the last bar is 4 or more)",
              ylabel="corps-years", xticks=k)
    ax[0].legend()
    ax[1].loglog(ns, tv, color=labs.BLUE, label="exact TV, Binomial(n, 2/n) to Poisson(2)")
    ax[1].loglog(ns, np.minimum(bound, 1), color=labs.GOLD, label="Le Cam's bound, 4 / n")
    ax[1].set(title="How fast the binomial becomes a Poisson", xlabel="number of trials n",
              ylabel="total variation distance")
    ax[1].legend()
    lab.fig = fig
    return lab

Now change it

  1. Give a tenth of the 600 soldiers ten times the risk of the rest, keeping the total at 0.61. How much does the distance to the Poisson grow, and does Le Cam's bound still hold?
  2. Make the kicks contagious: draw each corps-year's rate from a gamma distribution with mean 0.61. Compare the variance of the counts with their mean.
  3. Replace lambda = 2 by lambda = 0.61 in the right-hand panel. Does the distance still fall like 1 / n?

Problems, with solutions

Try each problem before opening its solution.

1. Splitting a Poisson sum. X ~ Poisson(a) and Y ~ Poisson(b), independent.

Solution

Use P(X + Y = n) = e^{−(a+b)}(a + b)ⁿ/n!, from chapter 11:

P(X = k | X + Y = n) = [e^{−a}aᵏ/k! · e^{−b}b^{n−k}/(n−k)!] / [e^{−(a+b)}(a+b)ⁿ/n!] = C(n, k) (a/(a+b))ᵏ (b/(a+b))^{n−k}.

That is the binomial(n, a/(a+b)) pmf. It is thinning, run backwards.

2. Only the exponential is memoryless. Show that the exponential is the only continuous law on \((0, \infty)\) with \(P(T > s + t \mid T > s) = P(T > t)\) for all \(s, t \ge 0\).

Solution

Let G(t) = P(T > t). Memorylessness says G(s + t) = G(s)G(t) for all s, t ≥ 0, with G non-increasing and G(0) = 1. Then:

  • g = −log G is additive and non-decreasing;
  • additivity gives g(q) = q·g(1) for rationals q;
  • monotonicity extends this to all t.

So G(t) = e^{−λt} with λ = g(1). (λ = 0 is excluded for a proper waiting time.)

3. Two transformations of a uniform. \(U\) is uniform on \((0, 1)\). Find the laws of \(U^2\) and of \(-2\log U\); name both families.

Solution
  • P(U² ≤ y) = P(U ≤ √y) = √y, so U² has density 1/(2√y) on (0, 1): beta(½, 1).
  • P(−2 log U ≤ y) = P(U ≥ e^{−y/2}) = 1 − e^{−y/2}. This is an exponential with mean 2, which is χ²₂ = gamma(1, 2).

The second is half of Box–Muller: it is R², where R is the Box–Muller radius.

4. The first of several buses. Show that the minimum of \(n\) independent exponential\((\lambda)\) waits is exponential\((n\lambda)\). Three bus routes each run every 10 minutes on average: how long until the first bus?

Solution

P(min Tᵢ > t) = ∏ P(Tᵢ > t) = e^{−nλt}, so the minimum is exponential(nλ). With three routes of mean 10 minutes, the rate is 3/10 and the expected wait is 10/3 ≈ 3.3 minutes. This is superposition.

5. Capture–recapture. n₁ = 200, n₂ = 150, m = 12.

Solution
  • Lincoln–Petersen: 200·150/12 = 2,500.
  • Chapman: 201·151/13 − 1 = 30,351/13 − 1 ≈ 2,334.

The Chapman version is smaller because the naive ratio is biased upward (chapter 4; Part 9).

6. The gamma as an exponential family (α known).

Solution

f(x) = x^{α−1}e^{−x/θ}/(Γ(α)θ^α) = [x^{α−1}/Γ(α)] · exp(−x/θ − α log θ).

So η = −1/θ, T(x) = x, and A(η) = α log θ = −α log(−η). Then:

  • A′(η) = −α/η = αθ = E X;
  • A″(η) = α/η² = αθ² = Var X.

Notes and sources

Where it comes back

Idea Returns in
the normal and sums 6 (laws of averages, CLT), 8 (sampling distributions)
χ², t, F 8, 10, 11, 12
order statistics, the tank problem 9 (UMVUE), 16 (ranks)
exponential families 9, 22, 24, 45
mixtures, overdispersion, total variance 15, 24, 25
the Poisson process 17, 40
heavy tails 30, 60
capture–recapture 18, 41

Sources

  • Horse kicks. L. von Bortkiewicz, Das Gesetz der kleinen Zahlen (1898). The 200 corps-years as usually quoted come from M. P. Quine & E. Seneta, "Bortkiewicz's data and the law of small numbers", Int. Statist. Rev. 55 (1987). S. D. Poisson, Recherches sur la probabilité des jugements (1837).
  • Rare events. L. Le Cam, "An approximation theorem for the Poisson binomial distribution", Pacific J. Math. 10 (1960).
  • Capture–recapture. C. G. J. Petersen (1896); F. C. Lincoln (1930); D. G. Chapman (1951). Laplace's 1802 estimate of the population of France.
  • The normal. A. de Moivre (1733), later The Doctrine of Chances (1738, 1756). C. F. Gauss, Theoria motus (1809). J. Herschel, Edinburgh Review (1850). J. C. Maxwell (1860). Background: S. Stigler, The History of Statistics (1986).
  • Transformations. G. E. P. Box & M. E. Muller, "A note on the generation of random normal deviates", Ann. Math. Statist. 29 (1958).
  • The sampling family. F. R. Helmert (1876). K. Pearson (1900). "Student", "The probable error of a mean", Biometrika 6 (1908). R. A. Fisher (1924). G. W. Snedecor (1934).
  • Order statistics. R. Ruggles & H. Brodie, "An empirical approach to economic intelligence in World War II", JASA 42 (1947).
  • Heavy tails. F. Auerbach (1913). G. K. Zipf, Human Behavior and the Principle of Least Effort (1949). A. Clauset, C. R. Shalizi & M. E. J. Newman, "Power-law distributions in empirical data", SIAM Review 51 (2009).
  • Exponential families. G. Darmois (1935); B. O. Koopman (1936); E. J. G. Pitman (1936).
  • The tree. L. M. Leemis & J. T. McQueston, "Univariate distribution relationships", The American Statistician 62 (2008).
  • Textbooks.
    • J. Blitzstein & J. Hwang, Introduction to Probability (2nd ed., 2019).
    • G. Casella & R. Berger, Statistical Inference (2nd ed., 2002).
    • N. L. Johnson, S. Kotz & N. Balakrishnan, Univariate Discrete and Continuous Univariate Distributions.
    • W. Feller, vols. 1–2.
About this partfrom its README

Part 3 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. Part 2 built the language of chance; this part names the shapes that chance keeps making. It opens with Bortkiewicz's horse kicks (1898), which follow Poisson's formula, and asks why the same few distributions turn up everywhere. The answer is that they are one family. Every member is related to the others by a sum, a limit, a transformation or a mixture.

Built in this part: the family-tree explorer (explainer.stats.FamilyTree), 18 distributions joined by 24 arrows. Each chapter lights its relationships, and the finale walks the whole tree. Several limit results receive their full proofs in Parts 6 and 43.

New in the World and the Museum:

  • the World's lake (World.lake, about 8,000 fish, for capture–recapture);
  • Bortkiewicz's 200 corps-years (museum.HORSEKICK_*).
Chapter notes
# Chapter What it does Numbers (computed)
0 Deaths by horse kick Bortkiewicz's 200 corps-years against 200 × Poisson(0.61); mean and variance; the dark family tree; objectives. 109, 65, 22, 3, 1 vs 108.7, 66.3, 20.2, 4.1, 0.7
1 Bernoulli to binomial Lattice paths; the formula from Part 2's counting; mean and variance by indicators; a World poll of 100 adults (how many over 180 cm). p = 0.1446; 2,000 polls: mean 14.42, variance 12.60
2 The law of rare events Binomial(n, λ/n) → Poisson, derived on screen; total variation as n grows; Le Cam's inequality; the Poisson's mean and variance. TV 0.174 (n = 4) → 0.0005 (n = 1,000)
3 Waiting The geometric; memorylessness shown by rescaling the tail; first-step analysis (Pascal's method) for E T = 1/p; the negative binomial (total trials; subtract the success count for the failures convention). simulated mean wait 5.996; P(T > 8 | T > 5) = 0.578 vs 0.579
4 Without replacement The hypergeometric; capture–recapture on the World's lake; Lincoln–Petersen and Chapman over 2,000 repetitions. N = 8,107; one estimate 6,452; L–P mean 8,525, Chapman 8,198
5 Continuous time The Poisson process; exponential gaps; the gamma wait; superposition and thinning; the inspection paradox. wait 10.04 min, gap you land in 20.09 min
6 The normal, three ways de Moivre (1733) and Stirling; Gauss (1809); Herschel–Maxwell rotation invariance; ∫e^{−x²/2} = √(2π) in polar coordinates; 68–95–99.7 on the World's men. 68.24%, 95.41%, 99.73% vs 68.27%, 95.45%, 99.73%
7 Transformations The CDF method (−log U); the Jacobian in 1D and nD; Box–Muller (1958) as a square morphing into a bell; the log-normal as a product of 60 factors. skewness 4.6 → −0.005 after the log
8 The sampling family χ² (Helmert 1876, Pearson 1900) and its gamma identity; Student's t (1908); F (Fisher 1924, Snedecor 1934); the lighthouse Cauchy and its running mean. χ²₃ simulated mean 2.99, variance 6.23
9 Order statistics The density of the k-th; uniform order statistics are beta; the sample median; the German tank problem (Ruggles & Brodie 1947). 8 serials, N = 300: estimate 270; 5,000 repetitions average 300.0
10 Heavy tails Pareto and the log–log line; Zipf on the World's 200 towns; the 80/20 rule against the World's incomes; log–log least squares vs maximum likelihood (Clauset, Shalizi & Newman 2009). slope −1.05; top 20% earn 43.8%; LS 2.24 ± 0.14 vs MLE 2.50 ± 0.07 (true 2.5)
11 Generating functions MGFs and moments; the normal's by completing the square; Poisson sums; sums of exponentials are gamma; characteristic functions. —
12 Mixtures and hierarchies Beta-binomial overdispersion; the law of total variance (4 + 16 = 20); gamma–Poisson = negative binomial; a normal scale mixture is t. variance 20.0 vs 4.9; NB mean 3.04, variance 7.71
13 Exponential families h(x) exp(ηT − A(η)); Bernoulli, Poisson, normal, exponential, binomial; A′ = E T, A″ = Var T; what the form buys (Parts 9, 15, 22, 24). A′ checked numerically
14 The family tree All 24 relationships walked and lit; Leemis & McQueston (2008). —
15 Outro Recap, where it comes back, problems, references, the Transcript, Part 4's question. —
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
  1. Hook: Bortkiewicz (1898). 200 corps-years: counts 109, 65, 22, 3, 1 in death categories 0, 1, 2, 3, 4+, against Poisson(0.61): 108.7, 66.3, 20.2, 4.1, 0.7.
  2. Bernoulli → binomial. Lattice paths; mean and variance by indicators.
  3. The law of rare events. Binomial(n, λ/n) → Poisson, derived; Le Cam's inequality.
  4. Waiting. Geometric and negative binomial; memorylessness; subtract the success count to pass from total trials to the gamma–Poisson failures convention.
  5. Without replacement. The hypergeometric; capture–recapture on the World's lake.
  6. Continuous time. The Poisson process; exponential and gamma waits; the inspection paradox (computed).
  7. The normal, three ways. de Moivre (1733) via Stirling; Gauss (1809) from "the mean is best"; Herschel–Maxwell from independent coordinates and rotation invariance; the Gaussian integral in polar coordinates.
  8. Transformations. The CDF method; Jacobians in 1D and 2D; Box–Muller; the log-normal as a multiplicative CLT.
  9. The sampling family. χ² (Helmert 1876), t, F; Cauchy as t₁ and as a lighthouse beam; Beta and gamma relations.
  10. Order statistics. The k-th's density; uniform order statistics are Beta; the maximum (Part 9's tanks); Rényi's representation.
  11. Heavy tails. Pareto and Zipf; log–log plots and their misuse (Clauset, Shalizi & Newman 2009).
  12. Generating functions. MGFs and characteristic functions; moments from derivatives; uniqueness (proved in Part 43); sums by products.
  13. Mixtures and hierarchies. Beta-binomial, gamma–Poisson, scale mixtures → t.
  14. Exponential families, first look. h(x) exp(ηT(x) − A(η)); A′(η) is the expectation of T(X).
  15. The family tree (Leemis & McQueston 2008), relationships introduced and lit, with several full limit proofs deferred to Parts 6 and 43.
  16. Outro.

Built: the family-tree explorer (each arrow a live transformation).

Build the film

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

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

Build it

From the repo root, after the one-time setup in the top-level README:

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