German tank problem



In the statistical theory of estimation, the problem of estimating the maximum of a discrete uniform distribution from sampling without replacement, is known, in the English-speaking world, as the German tank problem, due to its application in World War II to the estimation of the number of German tanks.

The analyses illustrate the difference between frequentist inference and Bayesian inference.

Estimating the population maximum based on a single sample yields divergent results, while the estimation based on multiple samples is an instructive practical estimation question whose answer is simple but not obvious.

Example
Suppose an intelligence officer has spotted tanks with serial numbers, 2, 6, 7, and 14, with the maximum observed serial number,. The unknown total number of tanks is called N.

The formula for estimating the total number of tanks suggested by the frequentist approach outlined below is
 * $$N \approx m - 1 + \frac{m}{k} = 16.5$$

Whereas, the Bayesian analysis below yields (primarily) a probability mass function for the number of tanks
 * $$\Pr(N=n) = \begin{cases}

0 &\text{if } n < m \\ \frac {k - 1}{k}\frac{\binom{m - 1}{k - 1}}{\binom n k} &\text{if } n \ge m \end{cases}$$

from which we can estimate the number of tanks according to


 * $$\begin{align}

N &\approx \mu \pm \sigma = 19.5 \pm 10 \\ \mu &= (m - 1)\frac{k - 1}{k - 2} \\ \sigma &= \sqrt{\frac{(k-1)(m-1)(m-k+1)}{(k-3)(k-2)^2}} \end{align}$$

This distribution has positive skewness, related to the fact that there are at least 14 tanks.

Historical problem
During the course of the war the Western Allies made sustained efforts to determine the extent of German productivity, and approached this in two major ways: conventional intelligence gathering and statistical estimation. In many cases statistical analysis substantially improved on conventional intelligence. In some cases conventional intelligence was used in conjunction with statistical methods, as was the case in estimation of Panther tank production just prior to D-Day.

The allied command structure had thought the Panther tanks seen in Italy, with their high velocity, long barreled 75 mm/L70 guns, were an unusual heavy tank, and would only be seen in northern France in small numbers, much the same way as the Tiger I was seen in Tunisia. The US Army was confident that the Sherman tank would perform well against the German Panzer Mk III and IV tanks which they expected to meet. Shortly before D-Day, rumors indicated that large numbers of Panther tanks were being used in the panzer divisions.

To ascertain if this were true the Allies attempted to estimate the number of Panther tanks being produced. To do this they made use of the serial numbers printed on captured or destroyed German tanks. The principal numbers used were gearbox numbers, as these fell in two unbroken sequences. Chassis and engine numbers were also used, though their use was more complicated. Various other components were used to cross-check the analysis. Similar analyses were done on tires which were observed to be sequentially numbered (i.e., 1, 2, 3, …, N).

The analysis of Panther tank wheels yielded an estimate for the number of wheel molds that were in use. A discussion with British road wheel makers then estimated the number of wheels that could be produced from this many molds, which yielded the total number of Panthers that were being produced each month. Analysis of road wheels from the two tanks obtained (consisting of 48 wheels each, for 96 wheels total) yielded an estimate of 270 Panthers produced in February 1944, substantially more than had previously been suspected.

German records after the war showed production for the month of February 1944 was 276. The statistical approach proved to be far more accurate than conventional intelligence methods, and the phrase German tank problem became accepted as a descriptor for this type of statistical analysis.

Estimating production was not the only use of this serial number analysis. It was also used to understand German production more generally, including number of factories, relative importance of factories, length of supply chain (based on lag between production and use), changes in production, and use of resources such as rubber.

Specific data
According to conventional Allied intelligence estimates the Germans were producing around 1,400 tanks a month between June 1940 and September 1942. Applying the formula below to the serial numbers of captured German tanks, (both serviceable and destroyed) the number was calculated to be 246 a month. After the war, captured German production figures from the ministry of Albert Speer showed the actual number to be 245.

Estimates for some specific months are given as:

Similar analyses
Similar serial number analysis was used for other military equipment during World War II, most successfully for the V-2 rocket.

During World War II, German intelligence analyzed factory markings on Soviet military equipment, and during the Korean War, factory markings on Soviet equipment was again analyzed. The Soviets also estimated German tank production during World War II.

In the 1980s, some Americans were given access to the production line of Israel's Merkava tanks. The production numbers were classified, but the tanks had serial numbers, allowing estimation of production.

The formula has also been used in non-military contexts, for example to estimate the number of Commodore 64 computers ever built, where the result (12.5 million) matches the official figures quite well.

Countermeasures
To prevent serial number analysis, one can most simply not include serial numbers, or reduce auxiliary information that can be usable. Alternatively, one can design serial numbers that resist cryptanalysis, most effectively by randomly choosing numbers without replacement from a list that is much larger than the number of objects you produce (compare the one-time pad), or simply produce random numbers and check them against the list of already assigned numbers; collisions are likely to occur unless the number of digits possible is more than twice as many as the number of digits in the number of objects produced (where the serial number can be in decimal, hexadecimal or indeed in any base); see birthday problem. For this, one may use a cryptographically secure pseudorandom number generator. All these methods require a lookup table (or breaking the cypher) to back out from serial number to production order, which complicates use of serial numbers: one cannot simply recall a range of serial numbers, for instance, but instead must look them each up individually, or generate a list.

Alternatively, one can simply use sequential serial numbers and encrypt them, which allows easy decoding, but then there is a known-plaintext attack: even if one starts from an arbitrary point, the plaintext has a pattern (namely, numbers are in sequence). One example is given in Ken Follett's novel "Code to Zero", where the encryption of the Jupiter C rocket serial numbers is described as:

The code word here is Huntsville (with repeated letters omitted) to get a 10-letter key. The rocket number 13 was therefore "HN", or the rocket number 24 was "UT".

Minimum-variance unbiased estimator
For point estimation (estimating a single value for the total), the minimum-variance unbiased estimator (MVUE, or UMVU estimator) is given by:


 * $$\hat{N} = m\left(1 + k^{-1}\right) - 1$$

where m is the largest serial number observed (sample maximum) and k is the number of tanks observed (sample size). Note that once a serial number has been observed, it is no longer in the pool and will not be observed again.

This has a variance of


 * $$ \operatorname{var}(\hat{N}) = \frac{1}{k}\frac{(N-k)(N+1)}{(k+2)} \approx \frac{N^2}{k^2} \text{ for small samples } k \ll N$$

so a standard deviation of approximately N/k, the (population) average size of a gap between samples; compare m/k above.

Intuition
The formula may be understood intuitively as:
 * "The sample maximum plus the average gap between observations in the sample",

the gap being added to compensate for the negative bias of the sample maximum as an estimator for the population maximum, and written as


 * $$\hat{N} = m + \frac{m-k}{k}= m + \frac{\text{missing numbers}}{k}$$

This can be visualized by imagining that the samples are evenly spaced throughout the range, with additional samples just outside the range at 0 and N + 1. If one starts with an initial gap being between 0 and the lowest sample (sample minimum), then the average gap between samples is m/k &minus; 1; the &minus;1 being because one does not count the samples themselves in computing the gap between samples.

This philosophy is formalized and generalized in the method of maximum spacing estimation.

Derivation
The probability that the sample maximum equals m is $$\tbinom{m - 1}{k - 1}\big/\tbinom Nk$$, where $$\tbinom \cdot\cdot$$ is the binomial coefficient.

The expected value of the sample maximum is
 * $$\begin{align}

\mu &= \sum_{m=k}^N m\frac{\tbinom{m - 1}{k - 1}}{\tbinom Nk} = \frac{k(N + 1)}{k + 1} \\ \Rightarrow N &= \mu\left(1 + k^{-1}\right) - 1 \end{align}$$

Then
 * $$\begin{align}

\mu\left(1 + k^{-1}\right) - 1 &= E\left[m\left(1 + k^{-1}\right) - 1\right] \\ \Rightarrow \hat{N} &= m\left(1 + k^{-1}\right) - 1 \end{align}$$

is an unbiased estimator of N.

To show that this is the UMVU estimator:
 * One first shows that the sample maximum is a sufficient statistic for the population maximum, using a method similar to that detailed at sufficiency: uniform distribution (but for the German tank problem we must exclude the outcomes in which a serial number occurs twice in the sample);
 * Next, one shows that it is a complete statistic.
 * Then the Lehmann–Scheffé theorem states that the sample maximum, corrected for bias as above to be unbiased, is the UMVU estimator.

Confidence intervals
Instead of, or in addition to, point estimation, one can do interval estimation, such as confidence intervals. These are easily computed, based on the observation that the odds that k samples will fall in an interval covering p of the range (0 ≤ p ≤ 1) is pk (assuming in this section that draws are with replacement, to simplify computations; if draws are without replacement, this overstates the likelihood, and intervals will be overly conservative).

Thus the sampling distribution of the quantile of the sample maximum is the graph x1/k from 0 to 1: the pth to qth quantile of the sample maximum m are the interval [p1/kN, q1/kN]. Inverting this yields the corresponding confidence interval for the population maximum of [m/q1/k, m/p1/k].

For example, taking the symmetric 95% interval p = 2.5% and q = 97.5% for k = 5 yields $$\scriptstyle 0.025^{1/5} \;\approx\; 0.48,\,$$ $$\scriptstyle 0.975^{1/5} \;\approx\; 0.995$$, so a confidence interval of approximately $$\scriptstyle\left[1.005m,\, 2.08m\right]$$. The lower bound is very close to m, so more informative is the asymmetric confidence interval from p = 5% to 100%; for k = 5 this yields $$\scriptstyle 0.05^{1/5} \;\approx\; 0.55,$$ so the interval [m, 1.82m].

More generally, the (downward biased) 95% confidence interval is $$\scriptstyle\left[m,\, m/0.05^{1/k}\right] \;=\; \left[m,\, m \cdot 20^{1/k}\right]$$. For a range of k, with the UMVU point estimator (plus 1 for legibility) for reference, this yields:

Immediate observations are:
 * For small sample sizes, the confidence interval is very wide, reflecting great uncertainty in the estimate.
 * The range shrinks rapidly, reflecting the exponentially decaying likelihood that all samples will be significantly below the maximum.
 * The confidence interval exhibits positive skew, as N can never be below the sample maximum, but can potentially be arbitrarily high above it.

Note that one cannot naively use m/k (or rather (m + m/k &minus; 1)/k) as an estimate of the standard error SE, as the standard error of an estimator is based on the population maximum (a parameter), and using an estimate to estimate the error in that very estimate is circular reasoning.

Bayesian analysis
The Bayesian approach to the German tank problem is to consider the probability $$\scriptstyle \Pr(N\;=\;n\mid M\;=\;m,\, K\;=\;k)$$ that the number of enemy tanks $$\scriptstyle N$$ is equal to $$\scriptstyle n$$, when the number of observed tanks, $$\scriptstyle K$$ is equal to the number $$\scriptstyle k$$, and the largest of the serial numbers $$\scriptstyle M$$ is equal to $$\scriptstyle m$$.

For brevity $$\scriptstyle \Pr(N\;=\;n\mid M\;=\;m,\, K\;=\;k)$$ is written $$\scriptstyle (n\mid m,\,k)$$

The rule for conditional probability gives
 * $$(n\mid m, k) = (m\mid n, k)\frac {(n\mid k)}{(m\mid k)}$$

The expression $$\scriptstyle (m\mid n,\, k) \;=\; \Pr(M\;=\;m\mid N\;=\;n,\, K\;=\;k)$$ is the conditional probability that the largest tank serial number observed is equal to $$\scriptstyle m$$, when the number of enemy tanks is known to be equal to $$\scriptstyle n$$, and $$\scriptstyle k$$ enemy tanks have been observed. It is

(m\mid n,k) = \begin{cases} \frac{\binom{m - 1}{k - 1}}{\binom{n}{k}} &\text{if } k \le m \le n\\ 0                                        &\text{otherwise} \end{cases} $$

where the binomial coefficient $$\scriptstyle \binom n k$$ is the number of $$\scriptstyle k$$-sized samples from an $$\scriptstyle n$$-sized population.

The expression $$\scriptstyle (m|k) \;=\; \Pr(M\;=\;m\mid K\;=\;k)$$ is the probability that the maximum serial number is equal to m once k tanks have been observed but before the serial numbers have actually been observed. $$\scriptstyle (m\mid k)$$ can be removed from the formula by the following trick.
 * $$\begin{align}

(m|k) &=(m\mid k)\cdot 1 \\ &=(m\mid k){\sum_{n=0}^\infty(n\mid m, k)} \\ &=(m\mid k){\sum_{n=0}^\infty(m\mid n, k)\frac {(n\mid k)}{(m\mid k)}} \\ &=\sum_{n=0}^\infty(m\mid n, k)(n\mid k) \end{align}$$

The expression $$\scriptstyle (n|k) \;=\; \Pr(N\;=\;n|K\;=\;k)$$ is the probability that the total number of tanks is equal to n when k tanks have been observed but before the serial numbers have actually been observed. Assume that it is some discrete uniform distribution

(n|k) = \begin{cases} \frac 1{\Omega - k} &\text{if } k \le n < \Omega \\ 0                  &\text{otherwise} \end{cases} $$

The upper limit $$\Omega$$ must be finite, because the function

f(n)=\lim_{\Omega\rarr\infty} \begin{cases} \frac 1{\Omega - k} &\text{if } k \le n < \Omega \\ 0                  &\text{otherwise} \end{cases} $$

is
 * $$f(n) = 0$$

which is not a probability mass function.

Then

(n\mid m,k) = \begin{cases} \frac{(m\mid n, k)}{\sum_{n=m}^{\Omega - 1} (m\mid n, k)} &\text{if } m \le n < \Omega \\ 0                                                &\text{otherwise} \end{cases} $$

If $$\scriptstyle \sum_{n=m}^\infty(m\mid n,\, k) \;<\; \infty$$, then the unwelcome variable $$\scriptstyle \Omega$$ disappears from the expression.



(n|m,k) = \begin{cases} 0                                         &\text{if } n < m \\ \frac{(m\mid n, k)}{\sum_{n=m}^\infty(m\mid n, k)} &\text{if } n \ge m \end{cases} $$

For k ≥ 1 the mode of the distribution of the number of enemy tanks is m.

For k ≥ 2, the probability that the number of enemy tanks is equal to $$n$$, is

\Pr(N=n\mid M=m\ge k,K=k\ge 2) = \begin{cases} 0                                                     &\text{if } n < m \\ \frac k{k - 1}\frac {\binom{m - 1}{k - 1}}{\binom n k} &\text{if } n \ge m \end{cases} $$

and the probability that the number of enemy tanks, $$\scriptstyle N$$, is greater than $$\scriptstyle n$$, is

\Pr(N>n\mid M=m\ge k,K=k\ge 2) = \begin{cases} 1                                             &\text{if } n < m \\ \frac {\binom{m - 1}{k - 1}}{\binom n {k - 1}} &\text{if } n \ge m \end{cases} $$

For k ≥ 3, $$N$$ has the finite mean value:
 * $$\frac{(m - 1)(k - 1)}{k - 2}$$

For k ≥ 4, $$\scriptstyle N$$ has the finite standard deviation:
 * $$\sqrt{\frac{(m - 1)(k - 1)(m + 1 - k)}{(k - 2)^2(k - 3)}}$$

These formulas are derived below.

Summation formula
The following important formula $$ from Binomial coefficient is used below for simplifying series relating to the German Tank Problem.
 * $$\sum_{n=m}^\infty \frac 1 {\binom n k} = \frac k{k - 1}\frac 1 {\binom{m - 1}{k - 1}}$$

This sum formula is somewhat analogous to the integral formula
 * $$\int_{n=m}^\infty \frac {dn}{n^k} = \frac 1{k - 1}\frac 1{m^{k - 1}}$$

These formulas apply for k > 1.

One tank
If you observe one tank randomly out of a population of n tanks, you get serial number m with probability 1/n for m ≤ n, and zero probability for m > n. Using Iverson bracket notation this is written
 * $$\Pr(M=m\mid N=n,K=1) = (m|n) = [m \le n]\frac{1}{n}$$

This is the conditional probability mass function of $$\scriptstyle m$$.

When considered a function of n for fixed m this is a likelihood function.
 * $$\mathcal{L}(n) = [n \ge m]\frac{1}{n}$$

The maximum likelihood estimate for the total number of tanks is N0 = m.

The total likelihood is infinite, being a tail of the harmonic series.


 * $$\sum_n \mathcal{L}(n) = \sum_{n=m}^\infty \frac{1}{n} = \infty$$

but
 * $$\begin{align}

\sum_n \mathcal{L}(n)[n < \Omega] &= \sum_{n=m}^{\Omega - 1} \frac{1}{n} \\ &= H_{\Omega-1} - H_{m - 1} \end{align}$$

where $$H_n$$ is the harmonic number.

The probability mass function depends explicitly on the prior limit $$\scriptstyle \Omega$$:
 * $$\begin{align}

&\Pr(N=n\mid M=m,K=1) \\ = {} &(n\mid m) = \frac{[m \le n]}{n} \cdot \frac{[n < \Omega]}{H_{\Omega - 1} - H_{m - 1}} \end{align}$$

The mean value of $$\scriptstyle N$$ is
 * $$\begin{align}

\sum_n n\cdot(n\mid m) &= \sum_{n=m}^{\Omega - 1} \frac{1}{H_{\Omega - 1} - H_{m - 1}} \\ &= \frac{\Omega - m}{H_{\Omega - 1} - H_{m - 1}} \\ &\approx \frac{\Omega - m}{\log\left(\frac{\Omega - 1}{m - 1}\right)} \end{align}$$

Two tanks
If you observe two tanks rather than one, then the probability that the larger of the observed two serial numbers is equal to m, is


 * $$\Pr(M=m\mid N=n,K=2) = (m|n) = [m \le n]\frac{m - 1}{\binom{n}{2}}$$

When considered a function of n for fixed m this is a likelihood function
 * $$\mathcal{L}(n) = [n \ge m]\frac{m - 1}{\binom{n}{2}}$$

The total likelihood is


 * $$\begin{align}

\sum_{n}\mathcal{L}(n) &= \frac{m - 1}{1} \sum_{n=m}^\infty \frac{1}{\binom n 2} \\ &= \frac{m - 1}{1} \cdot \frac{2}{2 - 1} \cdot \frac{1}{\binom {m - 1}{2 - 1}} \\ &= 2 \end{align}$$

and the probability mass function is


 * $$\begin{align}

&\Pr(N=n\mid M=m,K=2) \\ = {} &(n\mid m) \\ = {} &\frac{\mathcal{L}(n)}{\sum_n \mathcal{L}(n)} \\ = {} &[n \ge m]\frac{m - 1}{n(n - 1)} \end{align}$$

The median $$\scriptstyle \tilde{N}$$ satisfies
 * $$\sum_n [n \ge \tilde{N}](n\mid m) = \frac{1}{2}$$

so
 * $$\frac{m - 1}{\tilde N - 1} = \frac{1}{2}$$

and so the median is
 * $$\tilde{N} = 2m - 1$$

but the mean value of N is infinite
 * $$\mu = \sum_n n \cdot (n|m) = \frac{m - 1}1\sum_{n=m}^\infty \frac{1}{n - 1} = \infty$$

Probability mass function
The conditional probability that the largest of k observations taken from the serial numbers {1,…,n}, is equal to m, is
 * $$\begin{align}

&\Pr(M=m\mid N=n,K=k\ge 2) \\ = {} &(m\mid n, k) \\ = {} &[m \le n]\frac{\binom{m - 1}{k - 1}}{\binom{n}{k}} \end{align}$$

The likelihood function of n is the same expression
 * $$\mathcal{L}(n) = [n \ge m]\frac{\binom{m - 1}{k - 1}}{\binom{n}{k}}$$

The total likelihood is finite for k ≥ 2:
 * $$\begin{align}

\sum_n \mathcal{L}(n) &= \frac{\binom{m - 1}{k - 1}}{1} \sum_{n=m}^\infty {1 \over \binom n k} \\ &= \frac{\binom{m - 1}{k - 1}}{1} \cdot \frac{k}{k-1} \cdot \frac{1}{\binom{m - 1}{k - 1}} \\ &= \frac k{k - 1} \end{align}$$

The probability mass function is
 * $$\begin{align}

&\Pr(N=n\mid M=m,K=k \ge 2) = (n\mid m,k) \\ = {} &\frac{\mathcal{L}(n)}{\sum_n \mathcal{L}(n)} \\ = {} &[n\ge m]\frac{k-1}{k} \cdot \frac{\binom{m - 1}{k - 1}}{\binom n k} \\ = {} &[n\ge m]\frac{m-1}{n} \cdot \frac{\binom{m - 2}{k - 2}}{\binom{n - 1}{k - 1}} \\ = {} &[n\ge m]\frac{m-1}{n} \cdot \frac{m - 2}{n - 1} \cdot \frac{k - 1}{k - 2} \cdot \frac{\binom{m - 3}{k - 3}}{\binom{n-2}{k-2}} \end{align}$$

The complementary cumulative distribution function is the probability that N > x
 * $$\begin{align}

&\Pr(N>x\mid M=m,K=k) \\ = {} &\begin{cases} 1 &\text{if }x  < m \\ \sum_{n=x+1}^\infty (n\mid m,k) &\text{if }x \ge m       \end{cases} \\ = {} &[x<m] + [x \ge m]\sum_{n=x+1}^\infty \frac{k - 1}{k}\frac{\binom{m - 1}{k - 1}}{\binom{N}{k}} \\ = {} &[xx\mid M=m,K=k) \\ = {} &[x \ge m]\left(1 - \frac{\binom{m - 1}{k - 1}}{\binom{x}{k - 1}}\right) \end{align}$$

Expected value and standard deviation
The expected number of enemy tanks is
 * $$\begin{align}

\mu &= \sum_n n\cdot\Pr(N=n\mid M=m,K=k) \\& = \sum_n n\cdot [n\ge m]\frac {m-1}n \cdot \frac {\binom{m-2}{k-2}}{\binom{n-1}{k-1}} \\& = \frac{m-1}1 \cdot \frac{\binom{m-2}{k-2}}1\sum_{n=m}^\infty \frac 1{\binom{n-1}{k-1}}\\& = \frac{m-1}1 \cdot \frac{\binom{m-2}{k-2}}1 \cdot \frac{k-1}{k-2} \cdot \frac {1}{\binom{m-2}{k-2}}\\& = \frac{m-1}1 \cdot \frac{k-1}{k-2} \end{align}$$

The standard deviation σ satisfies the equation
 * $$\sigma^2 + \mu^2 = \sum_n n^2 \cdot \Pr(N=n\mid M=m,K=k)$$

So
 * $$\begin{align}

\sigma^2+\mu^2-\mu &= \sum_n n(n-1)\cdot\Pr(N=n\mid M=m,K=k)\\& = \sum_{n=m}^\infty n(n-1)\frac{m-1}n \cdot \frac{m-2}{n-1} \cdot \frac{k-1}{k-2} \cdot \frac{\binom{m-3}{k-3}}{\binom{n-2}{k-2}}\\& = \frac{m-1}1 \cdot \frac{m-2}1 \cdot \frac{k-1}{k-2} \cdot \frac{\binom{m-3}{k-3}}1 \sum_{n=m}^\infty \frac 1{\binom{n-2}{k-2}}\\ & = \frac{m-1}1 \cdot \frac{m-2}1 \cdot \frac{k-1}{k-2} \cdot \frac{\binom{m-3}{k-3}}1 \cdot \frac{k-2}{k-3} \cdot \frac 1{\binom{m-3}{k-3}}\\ & = \frac{m-1}1 \cdot \frac{m-2}1 \cdot \frac{k-1}{k-3}\\& \end{align}$$

and the standard deviation is
 * $$\begin{align}

\sigma &= \sqrt{\frac{m-1}1 \cdot \frac{m-2}1 \cdot \frac{k-1}{k-3}+\mu-\mu^2} \\& = \sqrt{\frac{(k-1)(m-1)(m-k+1)}{(k-3)(k-2)^2}} \\& \end{align}$$

The variance-to-mean ratio is simply
 * $$\frac{\sigma^2}\mu = \frac{m - k + 1}{(k - 3)(k - 2)}$$

Other discussions of the estimation

 * Maximum likelihood
 * Bias of an estimator
 * Likelihood function