Five serial numbers and a missing ledger
Five surviving tickets carry IDs 12, 29, 43, 58 and 80. You know that the ledger numbered trades consecutively starting at 1 and that five distinct tickets were sampled uniformly. The highest ID tells you at least 80 tickets existed. What can it tell you about the missing upper end?
A sample maximum hints at unseen labels
Five labels sampled uniformly without replacement from 1,…,N; German-tank estimator (k+1)m/k−1.
Count the samples that fit below a ceiling
Call the ledger size , the sample size and the sample maximum . Each of the possible subsets is equally likely. The event says that the entire sample fits among the first IDs. For ,
For the second expression, reserve ID and take the other tickets from the preceding . The same counting works whichever particular smaller IDs you saw. Indeed the likelihood of the observed five-ticket set is for every candidate , and zero below 80. It decreases as grows. Maximum likelihood therefore picks 80, a value that can only equal or underestimate the true endpoint.
The empty gaps have exchangeable sizes
Line up the sampled IDs. Count the unsampled IDs before the first ticket, between adjacent tickets, and after the last ticket. For our five observations the gap counts are
Their sum is . Every nonnegative vector of gaps summing to corresponds to exactly one possible sample, by inserting a sampled ticket between consecutive gaps. Thus all such vectors are equally likely and every gap has the same expectation, .
The final gap equals . Rearranging its expectation gives
With and , the unbiased estimate is 95. You can read the correction directly from the observed gaps. The first five contain 75 unsampled tickets in total. Use their average of 15 as the estimate of the last gap. Unbiasedness describes repeated sampling at a fixed . It does not assign probabilities to possible values of after observing these tickets.
How large a ledger would make 80 surprising?
Try a candidate of . The chance all five tickets would land among the first 80 is . For it is about 0.05178. Larger candidates make a maximum this small increasingly unlikely.
A one-sided 95% confidence procedure rejects each candidate for which . At the true , the rejection event is a lower tail of the discrete maximum distribution with probability at most 5%. For the observed maximum, the retained integers run from 80 through 143. The gap between a point estimate of 95 and an upper limit of 143 conveys what five tickets leave unresolved.
from math import comb
def upper_95(max_id, k):
if not 1 <= k <= max_id:
raise ValueError("incompatible sample size and maximum")
numerator = comb(max_id, k)
low, high = max_id, 2 * max_id
while comb(high, k) < 20 * numerator:
high *= 2
while high - low > 1:
mid = (low + high) // 2
if comb(mid, k) < 20 * numerator:
low = mid
else:
high = mid
return low
print(upper_95(80, 5)) # 143
The comparison uses integers so that even a tail probability exactly equal to 5% gets the stated treatment.
Practice
Model checkThe desk assigns odd IDs to buys and even IDs to sells. Your five tickets came only from the sell archive. Can you use the same calculation?Show answer
Even if the five sells were uniformly sampled, they are not a uniform sample of all IDs. If sell IDs run consecutively as 2, 4, 6 and so on, dividing by two creates a consecutive sequence for the sell population. Inferring the total trade count requires additional information about the buys.
Edge caseWhat does a single randomly sampled ticket with ID 80 imply?Show answer
The unbiased estimate is 159 because a uniform integer on has mean . The same confidence procedure retains candidates up to 1,599. At 1,600 the probability of a ticket at or below 80 is exactly 5%.