Coupon collector's problem

{{Short description|Problem in probability theory}}

File:Coupon collector problem.svg

In probability theory, the coupon collector's problem refers to mathematical analysis of "collect all coupons and win" contests. It asks the following question: if each box of a given product (e.g., breakfast cereals) contains a coupon, and there are n different types of coupons, what is the probability that more than t boxes need to be bought to collect all n coupons? An alternative statement is: given n coupons, how many coupons do you expect you need to draw with replacement before having drawn each coupon at least once? The mathematical analysis of the problem reveals that the expected number of trials needed grows as \Theta(n\log(n)).{{efn|Here and throughout this article, "log" refers to the natural logarithm rather than a logarithm to some other base. The use of Θ here invokes big O notation.}} For example, when n = 50 it takes about 225E(50) = 50(1 + 1/2 + 1/3 + ... + 1/50) = 224.9603, the expected number of trials to collect all 50 coupons. The approximation n\log n+\gamma n+1/2 for this expected number gives in this case 50\log 50+50\gamma+1/2 \approx 195.6011+28.8608+0.5\approx 224.9619. trials on average to collect all 50 coupons.

Solution

= Via generating functions =

By definition of Stirling numbers of the second kind, the probability that exactly T draws are needed is\frac{S(T-1, n-1)n!}{n^T}By manipulating the generating function of the Stirling numbers, we can explicitly calculate all moments of T:f_k(x) := \sum_T S(T, k) x^T = \prod_{r=1}^k \frac{x}{1-rx}In general, the k-th moment is (n-1)! ((D_x x)^kf_{n-1}(x)) \Big|_{x=1/n}, where D_x is the derivative operator d/dx.

For example, the 0th moment is\sum_T \frac{S(T-1, n-1)n!}{n^T} = (n-1)! f_{n-1}(1/n) = (n-1)! \times \prod_{r=1}^{n-1} \frac{1/n}{1-r/n} = 1 and the 1st moment is (n-1)! (D_x xf_{n-1}(x)) \Big|_{x=1/n}, which can be explicitly evaluated to nH_n, etc.

=Calculating the expectation=

Let time T be the number of draws needed to collect all n coupons, and let ti be the time to collect the i-th coupon after i − 1 coupons have been collected. Then T=t_1 + \cdots + t_n. Think of T and ti as random variables. Observe that the probability of collecting a {{em|new}} coupon is p_i = \frac{n - (i - 1)}{n} = \frac{n - i + 1}{n}. Therefore, t_i has geometric distribution with expectation \frac{1}{p_i} = \frac{n}{n - i + 1}. By the linearity of expectations we have:

:

\begin{align}

\operatorname{E}(T) & {}= \operatorname{E}(t_1 + t_2 + \cdots + t_n) \\

& {}= \operatorname{E}(t_1) + \operatorname{E}(t_2) + \cdots + \operatorname{E}(t_n) \\

& {}= \frac{1}{p_1} + \frac{1}{p_2} + \cdots + \frac{1}{p_n} \\

& {}= \frac{n}{n} + \frac{n}{n-1} + \cdots + \frac{n}{1} \\

& {}= n \cdot \left(\frac{1}{1} + \frac{1}{2} + \cdots + \frac{1}{n}\right) \\

& {}= n \cdot H_n.

\end{align}

Here Hn is the n-th harmonic number. Using the asymptotics of the harmonic numbers, we obtain:

:

\operatorname{E}(T) = n \cdot H_n = n \log n + \gamma n + \frac{1}{2} + O(1/n),

where \gamma \approx 0.5772156649 is the Euler–Mascheroni constant.

Using the Markov inequality to bound the desired probability:

:\operatorname{P}(T \geq cn H_n) \le \frac{1}{c}.

The above can be modified slightly to handle the case when we've already collected some of the coupons. Let k be the number of coupons already collected, then:

:

\begin{align}

\operatorname{E}(T_k) & {}= \operatorname{E}(t_{k+1} + t_{k+2} + \cdots + t_n) \\

& {}= n \cdot \left(\frac{1}{1} + \frac{1}{2} + \cdots + \frac{1}{n-k}\right) \\

& {}= n \cdot H_{n-k}

\end{align}

And when k=0 then we get the original result.

=Calculating the variance=

Using the independence of random variables ti, we obtain:

:

\begin{align}

\operatorname{Var}(T)& {}= \operatorname{Var}(t_1 + \cdots + t_n) \\

& {} = \operatorname{Var}(t_1) + \operatorname{Var}(t_2) + \cdots + \operatorname{Var}(t_n) \\

& {} = \frac{1-p_1}{p_1^2} + \frac{1-p_2}{p_2^2} + \cdots + \frac{1-p_n}{p_n^2} \\

& {} = \left(\frac{n^2}{n^2} + \frac{n^2}{(n-1)^2} + \cdots + \frac{n^2}{1^2}\right) - \left(\frac{n}{n} + \frac{n}{n-1} + \cdots + \frac{n}{1}\right) \\

& {} = n^2 \cdot \left(\frac{1}{1^2} + \frac{1}{2^2} + \cdots + \frac{1}{n^2} \right) - n \cdot \left(\frac{1}{1} + \frac{1}{2} + \cdots + \frac{1}{n} \right)\\

& {} < \frac{\pi^2}{6} n^2

\end{align}

since \frac{\pi^2}6=\frac{1}{1^2}+\frac{1}{2^2}+\cdots+\frac{1}{n^2}+\cdots (see Basel problem).

Bound the desired probability using the Chebyshev inequality:

:\operatorname{P}\left(|T- n H_n| \geq cn\right) \le \frac{\pi^2}{6c^2}.

=Tail estimates=

A stronger tail estimate for the upper tail be obtained as follows. Let {Z}_i^r denote the event that the i-th coupon was not picked in the first r trials. Then

:

\begin{align}

P\left [ {Z}_i^r \right ] = \left(1-\frac{1}{n}\right)^r \le e^{-r / n}.

\end{align}

Thus, for r = \beta n \log n, we have P\left [ {Z}_i^r \right ] \le e^{(-\beta n \log n ) / n} = n^{-\beta}. Via a union bound over the n coupons, we obtain

:

\begin{align}

P\left [ T > \beta n \log n \right ] = P \left [ \bigcup_i {Z}_i^{\beta n \log n} \right ] \le n \cdot P [ {Z}_1^{\beta n \log n} ] \le n^{-\beta + 1}.

\end{align}

Extensions and generalizations

  • Pierre-Simon Laplace, but also Paul Erdős and Alfréd Rényi, proved the limit theorem for the distribution of T. This result is a further extension of previous bounds. A proof is found in.{{Cite book |last=Mitzenmacher |first=Michael |title=Probability and computing : randomization and probabilistic techniques in algorithms and data analysis |date=2017 |others=Eli Upfal |isbn=978-1-107-15488-9 |edition=2nd |location=Cambridge, United Kingdom |at=Theorem 5.13 |oclc=960841613}}

::\operatorname{P}(T < n\log n + cn) \to e^{-e^{-c}}, \text{ as } n \to \infty. which is a Gumbel distribution. A simple proof by martingales is in the next section.

  • Donald J. Newman and Lawrence Shepp gave a generalization of the coupon collector's problem when m copies of each coupon need to be collected. Let Tm be the first time m copies of each coupon are collected. They showed that the expectation in this case satisfies:

::\operatorname{E}(T_m) = n \log n + (m-1) n \log\log n + O(n), \text{ as } n \to \infty.

:Here m is fixed. When m = 1 we get the earlier formula for the expectation.

  • Common generalization, also due to Erdős and Rényi:

::\operatorname{P}\left(T_m < n\log n + (m-1) n \log\log n + cn\right) \to e^{-e^{-c}/(m-1)!}, \text{ as } n \to \infty.

  • In the general case of a nonuniform probability distribution, according to Philippe Flajolet et al.{{citation |first=Philippe |last=Flajolet |first2=Danièle |last2=Gardy |first3=Loÿs |last3=Thimonier |title=Birthday paradox, coupon collectors, caching algorithms and self-organizing search |journal=Discrete Applied Mathematics |volume=39 |issue=3 |year=1992 |pages=207–229 |doi=10.1016/0166-218x(92)90177-c|citeseerx=10.1.1.217.5965 }}

::\operatorname{E}(T)=\int_0^\infty \left(1 - \prod_{i=1}^m \left(1-e^{-p_it}\right)\right)dt.

:This is equal to

::\operatorname{E}(T)=\sum_{q=0}^{m-1} (-1)^{m-1-q} \sum_{|J|=q} \frac{1}{1-P_J},

:where m denotes the number of coupons to be collected and PJ denotes the probability of getting any coupon in the set of coupons J.

See also

Notes

{{notelist}}

References

=Citations=

{{Reflist|30em}}

=Bibliography=

{{refbegin}}

  • {{citation

| last1 = Blom | first1 = Gunnar

| last2 = Holst | first2 = Lars

| last3 = Sandell | first3 = Dennis

| contribution = 7.5 Coupon collecting I, 7.6 Coupon collecting II, and 15.4 Coupon collecting III

| isbn = 0-387-94161-4

| location = New York

| mr = 1265713

| pages = 85–87, 191

| publisher = Springer-Verlag

| title = Problems and Snapshots from the World of Probability

| url = https://books.google.com/books?id=KCsSWFMq2u0C&pg=PA85

| year = 1994}}.

  • {{citation

| last = Dawkins | first = Brian

| issue = 1

| journal = The American Statistician

| jstor = 2685247

| pages = 76–82

| title = Siobhan's problem: the coupon collector revisited

| volume = 45

| year = 1991

| doi=10.2307/2685247}}.

  • {{citation

| last1 = Erdős | first1 = Paul | author1-link = Paul Erdős

| last2 = Rényi | first2 = Alfréd | author2-link = Alfréd Rényi

| journal = Magyar Tudományos Akadémia Matematikai Kutató Intézetének Közleményei

| mr = 0150807

| pages = 215–220

| title = On a classical problem of probability theory

| url = http://www.renyi.hu/~p_erdos/1961-09.pdf

| volume = 6

| year = 1961}}.

  • {{citation

| last1 = Laplace | first1 = Pierre-Simon | author1-link = Pierre-Simon Laplace

| title = Théorie analytique des probabilités

| pages = 194–195

| year = 1812}}.

  • {{citation

| last1 = Newman | first1 = Donald J. | author1-link = Donald J. Newman

| last2 = Shepp | first2 = Lawrence | author2-link = Lawrence Shepp

| doi = 10.2307/2308930

| journal = American Mathematical Monthly

| mr = 0120672

| pages = 58–61

| title = The double dixie cup problem

| volume = 67

| issue = 1 | year = 1960| jstor = 2308930 }}

  • {{citation

| last1 = Flajolet | first1 = Philippe | author1-link = Philippe Flajolet

| last2 = Gardy | first2 = Danièle

| last3 = Thimonier | first3 = Loÿs

| doi = 10.1016/0166-218X(92)90177-C

| issue = 3

| journal = Discrete Applied Mathematics

| mr = 1189469

| pages = 207–229

| title = Birthday paradox, coupon collectors, caching algorithms and self-organizing search

| url = http://algo.inria.fr/flajolet/Publications/alloc2.ps.gz

| volume = 39

| year = 1992| doi-access = free

}}.

  • {{citation

| last = Isaac | first = Richard

| contribution = 8.4 The coupon collector's problem solved

| isbn = 0-387-94415-X

| location = New York

| mr = 1329545

| pages = 80–82

| publisher = Springer-Verlag

| series = Undergraduate Texts in Mathematics

| title = The Pleasures of Probability

| url = https://books.google.com/books?id=a_2vsIx4FQMC&pg=PA80

| year = 1995}}.

  • {{citation

| last1 = Motwani | first1 = Rajeev | author1-link = Rajeev Motwani

| last2 = Raghavan | first2 = Prabhakar

| contribution = 3.6. The Coupon Collector's Problem

| location = Cambridge

| mr = 1344451

| pages = 57–63

| publisher = Cambridge University Press

| title = Randomized algorithms

| url = https://books.google.com/books?id=QKVY4mDivBEC&pg=PA57

| year = 1995| isbn = 9780521474658 }}.

{{refend}}