Coupon collector's problem explained

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 different types of coupons, what is the probability that more than boxes need to be bought to collect all coupons? An alternative statement is: given 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(nlog(n))

. For example, when it takes about 225[1] trials on average to collect all 50 coupons. Sometimes the problem is instead expressed in terms of an -sided die.

Solution

Calculating the expectation

Let time be the number of draws needed to collect all coupons, and let be the time to collect the -th coupon after coupons have been collected. Then

T=t1+ … +tn

. Think of and as random variables. Observe that the probability of collecting the -th coupon is

pi=

n-(i-1)
n

=

n-i+1
n
. Therefore,

ti

has geometric distribution with expectation
1
pi

=

n{n
-

i+1}

. By the linearity of expectations we have:

\begin{align} \operatorname{E}(T)&{}=\operatorname{E}(t1+t2+ … +tn)\\ &{}=\operatorname{E}(t1)+\operatorname{E}(t2)+ … +\operatorname{E}(tn)\\ &{}=

1
p1

+

1
p2

+ … +

1
pn

\\ &{}=

n
n

+

n
n-1

+ … +

n
1

\\ &{}=n ⋅ \left(

1
1

+

1
2

+ … +

1
n

\right)\\ &{}=n ⋅ Hn. \end{align}

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

\operatorname{E}(T)=n ⋅ Hn=nlogn+\gamman+

1
2

+O(1/n),

where

\gamma ≈ 0.5772156649

is the Euler–Mascheroni constant.

Using the Markov inequality to bound the desired probability:

\operatorname{P}(T\geqcnHn)\le

1
c

.

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

\begin{align} \operatorname{E}(Tk)&{}=\operatorname{E}(tk+1+tk+2+ … +tn)\\ &{}=n ⋅ \left(

1
1

+

1
2

+ … +

1
n-k

\right)\\ &{}=n ⋅ Hn-k\end{align}

And when

k=0

then we get the original result.

Calculating the variance

Using the independence of random variables, we obtain:

\begin{align} \operatorname{Var}(T)&{}=\operatorname{Var}(t1+ … +tn)\\ &{}=\operatorname{Var}(t1)+\operatorname{Var}(t2)+ … +\operatorname{Var}(tn)\\ &{}=

1-p1
2
p
1

+

1-p2
2
p
2

+ … +

1-pn
2
p
n

\\ &{}=\left(

n2
n2

+

n2
(n-1)2

+ … +

n2
12

\right)-\left(

n
n

+

n
n-1

+ … +

n
1

\right)\\ &{}=n2 ⋅ \left(

1
12

+

1
22

+ … +

1
n2

\right)-n ⋅ \left(

1
1

+

1
2

+ … +

1
n

\right)\\ &{}<

\pi2
6

n2 \end{align}

since

\pi2+
6=1
12
1+ … +
22
1
n2

+ …

(see Basel problem).

Bound the desired probability using the Chebyshev inequality:

\operatorname{P}\left(|T-nHn|\geqcn\right)\le

\pi2
6c2

.

Stirling numbers

Let the random variable be the number of dice rolls performed before all faces have occurred.

The subpower is defined

a\{b\

}=a!\left\, where

\left\{{b\atopa}\right\}

is a Stirling number of the second kind.[2]

Sequences of

k

die rolls are functions

k → n

counted by

nk

, while surjections (that land on each face at least once) are counted by

n\{k\

}, so the probability that all faces were landed on within the -th throw is

P(X\lek)=

n\{k\
}. By the recurrence relation of the Stirling numbers, the probability that exactly rolls are needed is
P(X=k)=n\{k\
}-\frac=\frac

Generating functions

Replacing

z

with

1+z

in the probability generating function produces the o.g.f. for

E\left[{X\choosek}\right]

. Using the partial fraction decomposition
{1x-1\choose
n}

-1

n{n\choose
=\sumk}
k=0
(-1)n-k
1-kx
, we can take the expansion
\begin{aligned}&{n{x+1}\choose
n}

-1

n{n\choose
\\ =&\sumi}
i=0
(-1)n-i
1-i(1-n{x+1+n
n{n\choose
)}\\ =&\sum
i=0

i}(-1)n-i\left(

1+n
1+n-i
infty(i-1)k-1
(n+1-i)k+1
+in\sum
k=1

xk\right)\end{aligned}

revealing that for

k>0

,

E\left[{X\choose

n{n\choose
k}\right]=n\sum
i=0

i}(-1)n-ii

(i-1)k-1
(n+1-i)k+1
Given an o.g.f., since
\left(x{1-x}\right)
i=\sum
infty{k-1\choose
n=0

i-1}xk

, a variation of the binomial transform is
k]f\left(x{1+x}\right)=\sum
i=0
[x

k{k-1\choosei-1}(-1)k-i[xi]f(x)

. (Specifically, if
{n{x+1}\choose
n}

-1=f\left(

x{1+x}\right)
,

f(x)={n-nx\choosen}-1

.)

Rewriting the binomial coefficient via the gamma function and expanding as the

\exp

of the polygamma series (in terms of generalised harmonic numbers), we find
\left[xi
i!

\right]{n-x\choosen}-1=\sumP\inperms(i)\prodc\in

(|c|)
H
n
, so

E\left[{X\choose

k{k-1\choose
k}\right]=\sum
i=0

i-1}(-1)k-i

ni
i!

\sumP\inperms(i)\prodc\in

(|c|)
H
n
which can also be written with the falling factorial and Lah numbers as

E[x\underline

kL(k,i)(-1)
k]=\sum
i=0

k-i

i\sum
n
P\inperms(i)

\prodc\in

(|c|)
H
n
The raw moments of the distribution can be obtained from the falling moments via a Stirling transform; due to the identity

\left\{{K\atop

K\left\{{K\atop
i}\right\}(-1)
k=0

k}\right\}L(k,i)(-1)k

, this provides
k\left\{{k\atop
E[x
i=0

i}\right\}(-1)k-i

i\sum
n
P\inperms(i)

\prodc\in

(|c|)
H
n

Tail estimates

A stronger tail estimate for the upper tail can be obtained as follows. Let

r
{Z}
i
denote the event that the

i

-th coupon was not picked in the first

r

trials. Then

\begin{align} P\left[

r
{Z}
i

\right]=\left(1-

1
n

\right)r\lee-r. \end{align}

Thus, for

r=\betanlogn

, we have

P\left[

r
{Z}
i

\right]\lee(-\beta=n-\beta

. Via a union bound over the

n

coupons, we obtain

\begin{align} P\left[T>\betanlogn\right]=P\left[cupi

\betanlogn
{Z}
i

\right]\len ⋅ P[

\betanlogn
{Z}
1

]\len-\beta. \end{align}

Extensions and generalizations

\operatorname{P}(T<nlogn+cn)\to

-e-c
e

,asn\toinfty.

which is a Gumbel distribution. A simple proof by martingales is in .[4] .

\operatorname{E}(Tm)=nlogn+(m-1)nloglogn+O(n),asn\toinfty.

Here is fixed. When we get the earlier formula for the expectation.

\operatorname{P}\left(Tm<nlogn+(m-1)nloglogn+cn\right)\to

-e-c/(m-1)!
e

,asn\toinfty.

infty
\operatorname{E}(T)=\int
0

\left(1-

m
\prod
i=1
-pit
\left(1-e

\right)\right)dt.

This is equal to

m-1
\operatorname{E}(T)=\sum
q=0

(-1)m-1-q\sum|J|=q

1
1-PJ

,

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

See also

References

Bibliography

External links

Notes and References

  1. E(50) = 50(1 + 1/2 + 1/3 + ... + 1/50) = 224.9603, the expected number of trials to collect all 50 coupons. The approximation

    nlogn+\gamman+1/2

    for this expected number gives in this case

    50log50+50\gamma+1/2 ≈ 195.6011+28.8608+0.5 ≈ 224.9619

    .
  2. Rus. Mircea Dan. Mircea Dan Rus. 15 January 2025. Yet another note on notation. 2501.08762. math.NT.
  3. Book: Mitzenmacher, Michael . Probability and computing : randomization and probabilistic techniques in algorithms and data analysis . 2017 . Eli Upfal . 978-1-107-15488-9 . 2nd . Cambridge, United Kingdom . Theorem 5.13 . 960841613.
  4. Kan . N. D. . 2005-05-01 . Martingale approach to the coupon collection problem . Journal of Mathematical Sciences . en . 127 . 1 . 1737–1744 . 10.1007/s10958-005-0134-y . 1573-8795. subscription .