Probability

How many new kinds the next sample will show

Count how many kinds were seen once, twice, three times. Good and Toulmin's alternating sum f₁t − f₂t² + f₃t³ − … then predicts, with no bias at all, how many new kinds a further sample t times as large will reveal. It works perfectly up to t = 1 and is worthless just beyond: past that point the kinds seen most often are multiplied by t to a high power, and the spread of the estimate passes 10⁴⁰ by t = 1.5. Truncating the sum at a random point rescues it, and each fourfold increase in the first sample buys about half a unit more of future.

Worth reading first: Counting a population by its repeats · Twenty-three people.

Counting a population by its repeats ran the birthday problem backwards. Instead of a known year and the chance of a shared birthday, it took the shared birthdays and inferred the year: the number of matching pairs among the draws measures how concentrated the population is, and the number of kinds seen exactly once measures, by a rule Alan Turing and I. J. Good worked out at Bletchley Park, how much of the population’s probability lies on kinds not yet seen at all. It ended on a question that rule cannot answer — how many kinds there are in total — and on the observation that without a model of the population’s long tail, nothing can.

There is a question between the two that can be answered, exactly, and it is the one a collector actually asks. A naturalist who has spent two years trapping butterflies in Malaya and found some hundreds of species wants to know how many new species another year of trapping would add. The question is not how many species exist in Malaya; it is how many will turn up in a sample of a given size. In 1956 Good and Geoffrey Toulmin gave an answer built from nothing but the counts of species seen once, twice, three times and so on. It is unbiased, it is simple, and it has a cliff in it at exactly the point where the future sample becomes larger than the past one.

Predicting the unseen works until the future outgrows the past. Zipf population of 5000, mean sample 2000: seen 756, f1 561, f2 95; at t = 1, 2, 4: truth 489/873/1462, smoothed 492/843/1243.
Fig. 1 Two thousand draws, on average, from 5,000 kinds whose shares fall like one over their rank: this sample saw 756 kinds, 561 of them once and 95 twice. From those counts alone, the number of new kinds a further sample tt times as large would reveal, against its true expected value. Good and Toulmin’s sum tracks the truth to t=1t = 1 and at t=1.04t = 1.04 is already off by more than the whole answer. The smoothed sum stays close to t=2t = 2 and then falls behind.

An alternating sum of the counts

Write fkf_k for the number of kinds that appeared exactly kk times in the sample: f1f_1 singletons, f2f_2 doubletons, and so on. Suppose the further sample is tt times as large as the first. Good and Toulmin’s estimate of the number of kinds that will appear in it and did not appear in the first is

U(t)=f1t−f2t2+f3t3−f4t4+⋯ .U(t) = f_1 t - f_2 t^2 + f_3 t^3 - f_4 t^4 + \cdots.

The first term is the obvious guess: the kinds seen once are the ones that only just made it into the sample, and a similar number of kinds only just failed to, so a sample of the same size should turn up about f1f_1 new kinds. The later terms correct that guess, and they alternate because the correction alternates — the doubletons say the singletons overstated the rare tail, the tripletons that the doubletons overcorrected, and so on.

The reason the sum is exactly right is a short calculation. Suppose a kind appears in the first sample a Poisson-distributed number of times with mean λ\lambda, and in the second with mean tλt\lambda. It contributes to fkf_k with probability e−λλk/k!e^{-\lambda}\lambda^k/k!, so its expected contribution to U(t)U(t) is

∑k≥1(−1)k+1tke−λλkk!=e−λ(1−e−tλ),\sum_{k \ge 1} (-1)^{k+1} t^k e^{-\lambda} \frac{\lambda^k}{k!} = e^{-\lambda}\bigl(1 - e^{-t\lambda}\bigr),

which is exactly the probability that the kind is missed by the first sample and caught by the second. Adding over all kinds, the expected value of U(t)U(t) is the expected number of new kinds, whatever the population is. No assumption about the shape of the population’s tail was needed: the alternating sum knows nothing about the population, and is unbiased for every population at every tt.

The hero figure takes one sample of about two thousand draws from a population in which the ii-th commonest kind has a share proportional to 1/i1/i — the shape that word frequencies and many species counts roughly follow, which the one that hardly ever comes up met as Zipf’s law. The sample saw 756 kinds, 561 of them once. At t=1t = 1, a second sample as large as the first, the sum predicts 492 new kinds, and the true expected number is 489. For every tt below 1 the prediction lies on the truth. Then, at t=1.04t = 1.04, it is off by more than the whole answer and leaves the chart.

Why the samples are Poisson

The calculation above assumed that each kind’s count is a Poisson variable, and the figures sample that way: each kind is drawn its own Poisson number of times, independently of the others, so that the sample’s size is itself random with mean two thousand. A real naturalist’s sample has a fixed size, or a fixed duration, and then the counts of different kinds are not independent — if one kind takes more of the sample, the others must take less. For a sample in which no single kind is a large share, the difference is negligible, for the same reason that how many get their own hat found the number of people who receive their own hat settling on a Poisson law even though the hats are not handed out independently. Good and Toulmin worked with fixed-size samples and found the same sum, with corrections that vanish as the sample grows; the Poisson version is the one in which the sum is exactly unbiased and the algebra is a single line.

The independence is also what makes the population’s shape irrelevant to the mean. Each kind contributes its own term to the expectation, and those terms add whatever the kinds’ shares are. A population with a few dominant kinds and a long tail of rare ones, like the Zipf population here, and a population of equally common kinds, give the same unbiasedness. What they do not give is the same variance, and that difference is where the rest of this essay goes. It is a familiar asymmetry from any unevenness brings the match sooner, where an uneven distribution of birthdays always produced a shared birthday sooner: unevenness concentrates the sample on the common kinds, produces more repeats, and leaves fewer new kinds for a later sample to find — and here it also produces the large counts that make the extrapolation unstable.

The terms shrink, then grow

The cliff is visible in the terms themselves.

The terms shrink before t = 1 and grow after it. largest count 222; t=0.5: k=1 2.81e+2, k=2 2.38e+1, k=5 2.81e-1, k=10 4.88e-3, k=222 1.48e-67; t=1: k=1 5.61e+2, k=2 9.50e+1, k=5 9.00e+0, k=10 5.00e+0, k=222 1.00e+0; t=1.5: k=1 8.42e+2, k=2 2.14e+2, k=5 6.83e+1, k=10 2.88e+2, k=222 1.24e+39.
Fig. 2 The sizes of the terms tkfkt^k f_k of the alternating sum for one sample, on a logarithmic scale, for every kk at which some kind was seen — up to 222, the count of the commonest kind — and t=0.5t = 0.5, 11 and 1.51.5. At t=0.5t = 0.5 the terms die away; at t=1t = 1 they are just the counts fkf_k; at t=1.5t = 1.5 they grow, and the kind seen 222 times contributes a term near 1.2×10391.2 \times 10^{39}.

At t=0.5t = 0.5 each term is the count fkf_k multiplied by a half to the power kk, and the terms fall away so fast that the first four or five settle the sum. At t=1t = 1 the terms are just the counts fkf_k, which fall slowly in a population like this one because it has a long head as well as a long tail: there are kinds seen dozens of times, and the commonest was seen 222 times. At t=1.5t = 1.5 every term is multiplied by 1.5k1.5^k, and for the commonest kinds that is an astronomically large number. The kind seen 222 times contributes a term of about 103910^{39}, with a sign depending on whether 222 is odd or even, to a sum whose true value is about 690.

In expectation those enormous terms cancel exactly, which is why the estimator is still unbiased. In any one sample they do not, because the counts of the common kinds fluctuate: a kind expected 220 times might appear 210 times or 235, and moving it from f221f_{221} to f222f_{222} changes the sum by more than 1.52221.5^{222}. The estimate is correct on average and has a spread that dwarfs its average.

Right on average and useless beyond one

The figure below draws two hundred independent samples from the same population and measures, at each tt, how much the estimates vary from sample to sample.

Right on average and useless beyond one. t=0.25: truth 136.3, sum sd 5.43e+0, smoothed mean 136.2 sd 5.4; t=0.5: truth 262.2, sum sd 1.12e+1, smoothed mean 261.8 sd 11.2; t=0.75: truth 379.5, sum sd 1.75e+1, smoothed mean 378.7 sd 17.5; t=1: truth 489.4, sum sd 2.55e+1, smoothed mean 488.3 sd 25.5; t=1.25: truth 593.0, sum sd 3.43e+24, smoothed mean 586.7 sd 33.0; t=1.5: truth 691.1, sum sd 3.26e+45, smoothed mean 675.8 sd 41.2; t=2: truth 873.0, sum sd 4.18e+78, smoothed mean 827.2 sd 57.3; t=3: truth 1190.9, sum sd 1.93e+125, smoothed mean 1049.1 sd 85.8; t=4: truth 1462.1, sum sd Infinity, smoothed mean 1202.8 sd 109.1; t=6: truth 1905.1, sum sd Infinity, smoothed mean 1403.5 sd 145.5.
Fig. 3 Two hundred independent samples: the standard deviation of each estimate of new kinds across the samples, divided by the true expected number, on a logarithmic scale. The plain sum’s spread is 5.2%5.2\% of the answer at t=1t = 1 and about 5×10425 \times 10^{42} times the answer at t=1.5t = 1.5. The smoothed sum keeps its spread between 5% and 8% all the way to t=6t = 6.

Up to t=1t = 1 the plain sum is excellent. Averaged over two hundred samples it is within a fraction of a per cent of the truth at every tt, and its spread from sample to sample is about 5% of the answer at t=1t = 1 — most of which is the genuine randomness of the first sample, not a fault of the method. At t=1.25t = 1.25 the spread is 102410^{24} times the answer; at t=1.5t = 1.5, 104210^{42}; at t=3t = 3 it passes 1012010^{120}, and beyond that it is too large for double-precision arithmetic to represent. The point at which it fails is not approximate. Below t=1t = 1 the variance is a convergent series; above it, for any population with kinds of large mean, it diverges.

That t=1t = 1 is the boundary has a clean interpretation. A sample can say a great deal about a future sample of its own size or smaller: every kind that will turn up in a smaller sample has, in expectation, already left a trace in the counts. A larger future sample will reach kinds rarer than anything the first sample could detect, and the alternating sum tries to estimate their number by extrapolating the counts to a region they do not cover. The extrapolation is unbiased, but extrapolating a power series past its radius of convergence is the problem that turning a slow series geometric faced from the other side, and it fails here for the same reason.

The common kinds are what break the sum

Since the trouble comes from large kk, a population without common kinds should not suffer from it. That can be tested.

The common kinds are what break the sum. equal kinds: t=0.5 2.64e-2, t=1 2.89e-2, t=1.5 3.24e-2, t=2 3.74e-2, t=2.5 4.46e-2, t=3 5.48e-2, t=4 9.07e-2; Zipf: t=0.5 4.32e-2, t=1 5.18e-2, t=1.5 2.49e+43, t=2 7.74e+76, t=2.5 7.58e+102, t=3 1.32e+124, t=4 Infinity.
Fig. 4 The root-mean-square error of the plain sum, as a share of the true answer, over two hundred samples of 2,000 expected draws, from 10,000 equally common kinds and from the Zipf population. With every kind rare, no kind is seen more than five times, the high terms never appear, and the sum is within 5.5% at t=3t = 3. The Zipf population’s error passes 1012010^{120} at t=3t = 3.

With ten thousand equally common kinds and two thousand draws, each kind is expected only 0.2 times. No kind appears more than five times in any of the two hundred samples, so the sum has at most five terms, each of moderate size, and the plain estimate works far beyond t=1t = 1: its typical error is 3.7% at t=2t = 2 and 5.5% at t=3t = 3. The same estimator on the Zipf population, with the same number of draws, explodes past t=1t = 1. The difference is entirely in the head of the distribution. The kinds the estimator is trying to count are the rare ones, and the kinds that break it are the common ones, which contribute nothing to the answer because they are certain to have been seen already.

That is what makes the failure avoidable rather than fundamental. The common kinds carry no information about new kinds, so their terms can be suppressed without losing anything the sum needs, and every repair of the estimator is a way of doing that.

Truncating the sum at a random point

The obvious repair, cutting the sum off after a fixed number of terms, introduces a bias that depends sharply on where the cut is made. Bradley Efron and Ronald Thisted, estimating in 1976 how many new words a further body of Shakespeare’s writing would contain, smoothed the sum instead, damping its later terms by factors that fall from one towards zero, and their estimate was used again in 1985 to test the attribution of a newly found poem. In 2016 Alon Orlitsky, Ananda Theertha Suresh and Yihong Wu gave a version with a proof attached. Choose a random cut-off LL from a Poisson distribution with mean

r=12tlog⁡n(t+1)2t−1,r = \frac{1}{2t} \log \frac{n (t+1)^2}{t - 1},

where nn is the size of the first sample, and keep the term tkfkt^k f_k only if k≤Lk \le L — or, averaging over LL, multiply the term by the probability that L≥kL \ge k. The weights fall off faster than tkt^k grows, so the common kinds are suppressed, and the choice of rr balances the bias this introduces against the variance it removes.

Smoothing trades the explosion for a shortfall. t=0.25: truth 136, smoothed 136 ± 5; t=0.5: truth 262, smoothed 262 ± 11; t=0.75: truth 379, smoothed 379 ± 18; t=1: truth 489, smoothed 488 ± 26; t=1.25: truth 593, smoothed 587 ± 33; t=1.5: truth 691, smoothed 676 ± 41; t=2: truth 873, smoothed 827 ± 57; t=3: truth 1191, smoothed 1049 ± 86; t=4: truth 1462, smoothed 1203 ± 109; t=6: truth 1905, smoothed 1404 ± 146.
Fig. 5 The true expected number of new kinds and the mean of the smoothed estimate over two hundred samples, with a bar one standard deviation either side, for tt from 0.25 to 6. Beyond 1 the smoothed sum is 5% low at t=2t = 2, 18% at 4 and 26% at 6: it leaves out kinds too rare for any sample of this size to show.

The smoothed sum behaves exactly as the theory says. Up to t=1t = 1 it is the plain sum. Beyond 1 its spread grows only slowly, to 8% of the answer at t=6t = 6, and it acquires a bias that is always in one direction: it falls short, by 5% at t=2t = 2, 18% at t=4t = 4 and 26% at t=6t = 6. The shortfall has the right sign to be honest. A sample of two thousand draws contains no evidence about kinds so rare that they would be expected less than once in five thousand, and a sample six times as large would turn up many of them. The smoothed estimate leaves those kinds out rather than guessing at them, and reports a lower bound that is close to the truth for small tt and increasingly conservative for large.

How far a sample can see

The last figure asks how the reach of the smoothed estimate depends on the size of the first sample.

Each fourfold sample buys a fixed step further. n=500: reach 1.69; t=1 6.4%, t=1.5 8.3%, t=2 12.9%, t=2.5 18.4%, t=3 23.6%, t=3.5 28.4%, t=4 32.6%, t=5 39.7%, t=6 45.4%; n=2000: reach 2.28; t=1 3.7%, t=1.5 4.2%, t=2 7.5%, t=2.5 12.0%, t=3 16.7%, t=3.5 21.1%, t=4 25.2%, t=5 32.2%, t=6 37.9%; n=8000: reach 2.55; t=1 2.0%, t=1.5 3.2%, t=2 6.0%, t=2.5 9.6%, t=3 13.5%, t=3.5 17.2%, t=4 20.8%, t=5 27.1%, t=6 32.5%; n=32000: reach 3.20; t=1 1.2%, t=1.5 1.7%, t=2 3.4%, t=2.5 5.9%, t=3 8.8%, t=3.5 11.8%, t=4 14.7%, t=5 20.0%, t=6 24.6%.
Fig. 6 The typical error of the smoothed estimate, as a share of the truth, for first samples of 500, 2,000, 8,000 and 32,000 expected draws from 200,000 Zipf kinds, against tt; the dashed line is an error of 10%, and each label gives the tt at which the error crosses it. Quadrupling the first sample moves the reach from 1.7 to 2.3 to 2.6 to 3.2.

The population here is large — two hundred thousand kinds, so that even the largest sample sees only a small part of it — and the first sample is quadrupled three times, from 500 draws to 32,000. The point at which the typical error passes 10% moves from t=1.7t = 1.7 to 2.32.3, 2.62.6 and 3.23.2: about half a unit further for each factor of four. That is growth like the logarithm of the sample size, and Orlitsky, Suresh and Wu proved that it is the best possible. For any estimator whatsoever, there are populations on which the error stays bounded only if tt grows no faster than a constant times log⁡n\log n. At the rate the figure measures, a sample a thousand times larger buys only two or three more units of tt, and no amount of statistical ingenuity will let any sample predict a future one a thousand times its size.

The birthday problem, run forwards from the sample

The essays on the birthday problem have moved from a known population to the chance of a repeat, and then from observed repeats back to the population. The Good–Toulmin sum sits between those directions. It uses the repeats in a sample — the counts f2,f3,…f_2, f_3, \ldots are precisely the birthday problem’s matches, sorted by how many people share each day — to predict the matches and non-matches of a future sample, without passing through any estimate of the population at all. Twenty-three people showed how quickly repeats appear in a known population; here the repeats that have appeared are used to forecast the ones that will not. And a room where nobody is alone asked how long it takes until every kind present has been seen twice, which is the question of when f1f_1 falls to zero — the moment at which the sum’s first term, and with it the whole prediction of new kinds, runs out.

The method’s history runs back to the same place as the Turing–Good rule for the missing mass. Good described in later accounts how he and Turing reasoned about frequencies of frequencies while breaking the naval Enigma, where the “kinds” were the naval cipher’s code groups and the question was how much of its codebook remained unseen; evidence measured in decibans followed the other half of that work, the scoring of evidence for and against a guess. The Good–Toulmin paper of 1956 was the peacetime sequel, and its first application was to the naturalist’s question: R. A. Fisher had been asked in the 1940s, by the entomologist Steven Corbet, how many new species of butterfly another stretch of trapping in Malaya would produce, and the alternating sum is the general answer to that question.

Still open: the tail itself

The smoothed estimator’s reach is limited because the first sample says nothing about kinds rarer than it can detect. Every extension past tt of order log⁡n\log n needs an assumption about those kinds — a parametric form for the tail of the population, or a bound on how many kinds it can contain — and which assumptions are safe, in which applications, is the open part of the subject. Ecologists estimating species richness, linguists estimating vocabularies, and computer scientists estimating the number of distinct values in a database column all use estimators that extrapolate beyond the Good–Toulmin range, and the theory says that each of them is right only on the populations its assumptions describe.

There is a sharper question inside that one. The bound of Orlitsky, Suresh and Wu is a worst case over all populations. For the populations that occur — word frequencies, species abundances, which follow power laws with particular exponents — it is not known how much further than log⁡n\log n a sample can see, or whether the smoothing that is optimal in the worst case is close to optimal on them. A theory that measured the extrapolation range from properties of the observed counts themselves, and told a naturalist with a given set of fkf_k how far ahead it was safe to predict, would be the natural completion of what Good and Toulmin began, and it does not yet exist.

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.

Alternating seriesEstimatorEstimator biasPoisson approximationPower seriesSamplingUnbiased estimatorVariance