Probability

The largest serial number seen

Allied statisticians in the Second World War estimated German tank production from the serial numbers on captured tanks, and their estimates beat the intelligence reports by a factor of five. The method is simple. The largest serial number seen always falls short of the total, and the shortfall can be estimated: it is about one gap between serial numbers. Adding the average gap gives the best unbiased estimate there is, and its error shrinks like one over the number of tanks seen.

Worth reading first: Counting a population by its repeats · A stick broken in three.

During the Second World War, Allied intelligence wanted to know how many tanks Germany was building each month. Spies and aerial photographs gave one answer. A group of statisticians gave another, starting from a fact about the tanks themselves: their parts were numbered in sequence. Gearboxes, chassis, engines and the moulds for road wheels carried serial numbers, and captured or destroyed tanks could be examined. From a handful of serial numbers, they estimated the total.

After the war the German production records became available, and the comparison was published by Richard Ruggles and Henry Brodie in 1947. For June 1941, intelligence had estimated 1,550 tanks a month; the statistical estimate was 244; the records said 271. For August 1942 the figures were 1,550, 327 and 342. The intelligence estimates were too high by a factor of about five. The serial numbers were close.

The mathematics behind the estimate is a small, complete piece of probability, and it inverts the question asked in counting a population by its repeats. There, items carry no labels, and the size of a population is read from how often the same item is seen twice. Here every item carries its own number, and the size is read from the largest number seen. The opening figure draws four samples of five serial numbers from tanks numbered 1 to 60. The largest number seen is never more than 60 and is usually less. The question is how much less.

Five serial numbers out of sixty. 16,22,23,27,47 -> 55.40; 9,11,31,42,44 -> 51.80; 10,17,51,53,55 -> 65.00; 25,34,38,48,49 -> 57.80
Fig. 1 Four samples of five serial numbers from 1 to 60. The stretch beyond each largest number is shaded, and the estimate m+m/5−1m + m/5 - 1 is marked on each line.

Five serial numbers out of sixty

Suppose there are NN tanks, numbered 1,2,…,N1, 2, \ldots, N, and kk of them are seen, each set of kk equally likely. Write mm for the largest serial number among them. It is the obvious estimate of NN, and it is always too small or exactly right. Since it can never be too large, it is too small on average. In the opening figure’s four samples the largest numbers are 47, 44, 55 and 49; the shaded stretch beyond each is the range of tanks that exist and were not seen.

What should be added? The figure’s blue marks show the answer this essay arrives at: add the average gap between the serial numbers seen, m/km/k, and subtract one. The four estimates are 55.4, 51.8, 65.0 and 57.8: two below 60, one above, none exactly right, and — as the later figures show — exactly right on average, with less scatter than any other estimate that is right on average.

The estimate uses only mm and kk. The other four numbers in each sample, the ones below the largest, appear to carry information — a sample bunched near the top seems to say something different from one spread evenly — and yet the best estimate ignores them entirely. That is the surprising part of the answer, and it says that once the largest number is known, the positions of the rest are pure noise.

The largest number seen falls short

The largest number seen falls short. N=60, k=5: E[max] 50.8333; simulated 50.869
Fig. 2 The exact chance that the largest of 5 different numbers drawn from 1 to 60 is mm: (m−14)/(605)\binom{m-1}{4}/\binom{60}{5}. It is most likely to be 60 itself, yet it averages only 50.83.

The distribution of mm is a counting argument. For the largest of the kk numbers to be mm, the number mm must be among them and the other k−1k - 1 must be chosen from the m−1m - 1 numbers below it, so

P(largest=m)=(m−1k−1)/(Nk).P(\text{largest} = m) = \binom{m-1}{k-1} \Big/ \binom{N}{k}.

The figure draws it for N=60N = 60 and k=5k = 5. The chance rises steeply towards the top, and the single most likely value of the largest number is 60, the true total. But the distribution has a long left tail and no right tail at all, so its average is pulled down. The average works out to

E[m]=k(N+1)k+1,E[m] = \frac{k(N + 1)}{k + 1},

which for five numbers from 60 is 50.8350.83, short by (N−k)/(k+1)=9.17(N - k)/(k + 1) = 9.17. The figure checks the exact average against 20,000 simulated samples.

This is the difference between the most likely value and the average, which matters for estimation in a way it rarely does elsewhere. The largest number seen is the maximum-likelihood estimate of NN: for any sample, the total that makes it most probable is the smallest total consistent with it, which is mm. Maximum likelihood is often a good rule, and here it is systematically wrong, always on the same side. It is wrong because the probability of a sample, 1/(Nk)1/\binom{N}{k}, falls as NN grows, so the most likely NN is the smallest allowed — a rule that ignores the cost of having seen only a few. Estimating from too little and acting on the estimate has a price that can be computed, as it is for a bettor who does not know the coin; here the price is a steady shortfall of about one gap.

Six gaps of the same average size

Six gaps of the same average size. N=60,k=5 gaps 10.132,10.143,10.232,10.229,10.195,10.069; expected 10.167
Fig. 3 In 20,000 samples of five numbers from 1 to 60, the average length of each of the six gaps the five numbers cut out of the range from 0 to 61: all six are the same, 61/6.

Where does the correction come from? Mark the five serial numbers on a line from 0 to N+1=61N + 1 = 61. They cut it into six gaps: below the smallest, between consecutive numbers, and above the largest. The figure measures the average length of each across 20,000 samples, and all six are the same, 61/6=10.1761/6 = 10.17, to within the noise of the simulation.

That they must be equal is a symmetry argument of the kind used for a stick broken in three. Choose k+1k + 1 points at random among N+1N + 1 positions arranged round a circle, and cut the circle at one of them; the remaining kk points are a random sample from 11 to NN, and the k+1k + 1 gaps between the original points are the k+1k + 1 gaps of the sample. On the circle no gap is special, so all have the same average. The gap above the largest serial number, from mm to N+1N + 1, is therefore on average the same size as each of the gaps that can be seen.

So the best guess at the unseen gap is the average of the seen ones. The seen gaps together run from 0 to mm, so their average is m/km/k. Adding it to mm gives an estimate of N+1N + 1, and subtracting one gives

N^=m+mk−1.\hat N = m + \frac{m}{k} - 1.

Its average is exactly NN, because the average of mm is k(N+1)/(k+1)k(N+1)/(k+1) and multiplying by (k+1)/k(k+1)/k undoes the shrinkage. The other numbers in the sample were used only to justify the correction, not to compute it.

Three ways to estimate sixty

Three ways to estimate sixty. largest seen, m: mean 50.886 sd 8.099; twice the average, minus 1: mean 60.166 sd 15.000; m + m/k − 1: mean 60.063 sd 9.718; exact sd 14.955, 9.791
Fig. 4 Twenty thousand samples of five numbers from 1 to 60 and three estimates: the largest number seen, averaging 50.9; twice the sample average minus one, right on average but spreading by 15.0; and the largest plus the average gap, right on average and spreading by only 9.7.

The new estimate is not the only one that is right on average. The serial numbers seen are a random sample from 11 to NN, whose average is (N+1)/2(N + 1)/2, so twice the sample average minus one is also unbiased. It uses every number in the sample equally, and the figure compares it with the other two. Both corrected estimates centre on 60. But twice the average spreads by 15.0 — its exact standard deviation is (N+1)(N−k)/(3k)=14.96\sqrt{(N + 1)(N - k)/(3k)} = 14.96 — while the corrected maximum spreads by 9.7, against an exact (N−k)(N+1)/(k(k+2))=9.79\sqrt{(N - k)(N + 1)/(k(k + 2))} = 9.79.

That the corrected maximum is better is not luck. The largest serial number is a sufficient statistic: given mm, the other k−1k - 1 numbers are a uniformly random choice from 11 to m−1m - 1, and their distribution does not depend on NN at all. Whatever they look like — bunched, spread, all near the top — they carry no information about how many tanks there are. An estimate that uses them, like twice the average, is mixing in pure noise. The Lehmann–Scheffé theorem makes this precise: an unbiased estimate that depends only on a complete sufficient statistic has the smallest variance of all unbiased estimates, and m+m/k−1m + m/k - 1 is that estimate.

The difference shows up in the formulas as a factor of kk. Twice the average has a standard deviation that falls like N/3kN/\sqrt{3k}, the familiar square-root law of averages settling down. The corrected maximum’s falls like N/kN/k, much faster, because the maximum of a sample sits within about one gap of the end of the range, and the gaps shrink like 1/k1/k. A statistic at the edge of a distribution converges faster than one at its centre whenever the distribution has a sharp edge. Extremes behave by their own rules — the longest run of heads never settles into a limiting shape at all — and the serial-number problem is the rare case where the extreme is better behaved than the average, because the edge it sits against is fixed.

When the numbering does not start at one

The wartime problem was rarely as clean as numbers running from 1. A factory might begin its series at an unknown value, so that the serial numbers run from s+1s + 1 to s+Ns + N with both ss and NN unknown. The gap argument handles this at once. The kk numbers seen now cut the range into k+1k + 1 gaps, of which two — below the smallest and above the largest — are hidden, and all k+1k + 1 still have the same average size. The visible span from the smallest to the largest consists of k−1k - 1 gaps, so the whole range is about (k+1)/(k−1)(k + 1)/(k - 1) times the span, and

N^=k+1k−1 (max⁡−min⁡)−1\hat N = \frac{k + 1}{k - 1}\,(\max - \min) - 1

is unbiased for the number of tanks. It needs at least two serial numbers, since one number gives no span at all, and it is noisier than the estimate with a known start, since two gaps must now be guessed instead of one.

The same reasoning extends to the unseen gaps of any kind. A sample of kk numbers carries k−1k - 1 observed gaps whatever the setting, and every hidden gap — at either end, or between two factories’ ranges — is estimated by their average. It is the waiting-time symmetry that makes a fresh draw equally likely to fall into any of the gaps already cut, read as a statement about estimation rather than about waiting: what has not been seen is, on average, exactly like what has.

Serial numbers against repeats

Serial numbers against repeats. N=1000: serial rel sd 0.353,0.169,0.091,0.047,0.019,0.009,0.004; P(no repeat) 1.000,0.987,0.954,0.822,0.281,0.005,0.000
Fig. 5 Estimating a population of 1,000. With serial numbers, the error of the best unbiased estimate falls like 1/k1/k: 17% from five items, 9% from ten, under 1% from a hundred. Without them, the information lies in repeats, and the chance of not yet having seen a single repeat stays near one until about 32 sightings.

The comparison with the birthday problem’s estimates is instructive. Without serial numbers, an observer who can only recognise an item when it is seen again learns the population size from coincidences. The number of matching pairs among kk sightings averages (k2)/N\binom{k}{2}/N, so pairs begin to appear only when kk is near N\sqrt N — the same arithmetic that puts a shared birthday among twenty-three people. For a population of 1,000, the figure shows the chance of having seen no repeat at all: 95% after ten sightings, 82% after twenty, 28% after fifty.

Serial numbers change the rate of learning completely. After five tanks the estimate’s typical error is 17% of the total; after ten it is 9%; after a hundred it is under one per cent. The figure plots both curves on one axis, and the serial numbers win at every sample size. Labels make each observation informative on its own, where unlabelled observations are informative only in pairs.

This is why serial numbers are treated as secrets. After the war, manufacturers of military equipment learned to randomise them, and the same arithmetic has been applied in peacetime: to estimate the number of computers of a particular model built, from the serial numbers seen in repair shops, and to estimate how many of a product a company has sold, from order numbers that customers happen to report. A sequence of consecutive numbers announces its own length to anyone who sees a few of them.

What a flat prior says after seeing 60

What a flat prior says after seeing 60. k=2: median 118, umvu 89.00; k=3: median 84, umvu 79.00; k=5: median 70, umvu 71.00; k=10: median 64, umvu 65.00
Fig. 6 The chance, on a logarithmic scale, of each total after seeing a largest serial of 60 among kk numbers, starting from equal belief in every total up to 20,000. The most probable total is always 60, but with two numbers the median is 118; with ten it is 64.

A Bayesian answers differently: not with an estimate but with a distribution of belief over NN, by the rule that turns a prior into a posterior. Start from equal belief in every total up to some large bound. After seeing kk serial numbers whose largest is mm, the posterior chance of a total NN is proportional to the chance of the observation, 1/(Nk)1/\binom{N}{k}, for every N≥mN \geq m. The figure draws it for a largest serial of 60 seen among 2, 3, 5 and 10 numbers.

Every posterior peaks at 60 — the maximum-likelihood answer again — and falls away. With ten serial numbers it falls fast, like N−10N^{-10}, and the posterior median is 64, close to the unbiased estimate of 65. With two it falls like N−2N^{-2}, its tail reaches far, and its median is 118, against an unbiased estimate of 89. With one serial number the posterior falls like 1/N1/N, which does not add up to anything finite, and the answer depends entirely on the arbitrary bound: a single serial number is not enough evidence to overcome a prior that is indifferent among totals up to a million.

That dependence is the honest content of small samples. Different reasonable priors — flat in NN, flat in log⁡N\log N, or reflecting a factory’s known capacity — give similar answers once kk is ten or so, because the likelihood then dominates. For two or three serial numbers they disagree, and the disagreement is not a defect of the method but a fact about how little two numbers say. The wartime statisticians had dozens of serial numbers a month from different parts of each tank, which is why their estimates were good.

Uniform sampling and the factories it ignores

The figures assume an idealised sampling: every tank equally likely to be captured, numbers running consecutively from 1, and no tank seen twice. None of these held exactly. Serial numbers were assigned in blocks to different factories, some ranges were skipped, and a tank captured in one month may have been built in another. The statisticians modelled these departures — estimating each factory’s range separately, and using the serial numbers on wheels, whose moulds could be counted, to estimate production rates — and the agreement with the records reflects that work as much as the formula.

Nor do the figures show what happens when the sampling is not uniform. If tanks from early production are more likely to be destroyed — because they have been in service longer — the sample is biased towards low numbers, and every estimate here is biased low with it. Correcting for that requires a model of which tanks are seen, and no amount of arithmetic on the numbers alone can supply it.

And the optimality is narrow. The corrected maximum has the least variance among unbiased estimates, but an estimate that accepts a small bias can have a smaller total error; multiplying mm by (k+2)/(k+1)(k + 2)/(k + 1) instead of (k+1)/k(k + 1)/k, for instance, has smaller mean squared error at the cost of being slightly low on average. Which criterion to optimise is a choice, and the figures make none.

Still open: estimating the size of what cannot be numbered

The serial-number problem is solved: exact distributions, an optimal unbiased estimate, and clear Bayesian answers. The harder problems sit beside it. Estimating the number of species from a sample — how many new kinds the next sample will show — has no labels to exploit, and it is known that no estimate can be uniformly good: the data can always be explained by a few common species or by a vast number of rare ones that have not yet appeared. How much can be said, with what guarantees and under what assumptions about the rare species, is the subject of active research in statistics and ecology, and its answers are much weaker than the clean formula here.

Mixtures of the two situations are common and less understood: items that are partly labelled, numbering schemes that are partly random, or sequences that start at an unknown value as well as end at one. Each needs its own analysis, and the general question — how much of the information in a sample lives in its extreme values, and how fast estimates built from them converge — is answered for particular families of distributions rather than in general.

One gap beyond the last

The largest serial number seen is the natural guess at how many there are, and it is always short. It is short by about one gap, because kk random numbers cut the range into k+1k + 1 gaps of equal average size and the last gap is hidden. Adding the average of the visible gaps gives m+m/k−1m + m/k - 1, right on average and less scattered than any other estimate that is right on average, because once the largest number is known the others carry no information at all. Its error falls like one over the number of serial numbers seen, where unlabelled counts learn only from coincidences that take N\sqrt N sightings to appear. That difference — a factor of five between the statisticians and the spies — is what a sequence of consecutive numbers gives away.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

EstimatorEstimator biasMaximum likelihoodOrder statisticsPosteriorUnbiased estimator