Problem in probability theory
Coupon collector's problem Parameters
n
∈
N
{\displaystyle n\in \mathbb {N} }
– number of faces on die Support
k
∈
N
{\displaystyle k\in \mathbb {N} }
– rolls taken for all faces to appear PMF
(
n
−
1
)
{
x
−
1
}
n
x
−
1
{\displaystyle {\frac {(n-1)^{\{x-1\}}}{n^{x-1}}}}
CDF
n
{
x
}
n
x
{\displaystyle {\frac {n^{\{x\}}}{n^{x}}}}
Mean
n
H
n
{\displaystyle nH_{n}}
Variance
n
2
H
n
(
2
)
−
n
H
n
{\displaystyle n^{2}H_{n}^{(2)}-nH_{n}}
Skewness
2
n
3
H
n
(
3
)
−
3
n
2
H
n
(
2
)
+
n
H
n
(
n
2
H
n
(
2
)
−
n
H
n
)
3
/
2
∼
n
6
3
/
2
2
ζ
(
3
)
π
3
{\displaystyle {\frac {2n^{3}H_{n}^{(3)}-3n^{2}H_{n}^{(2)}+nH_{n}}{\left(n^{2}H_{n}^{(2)}-nH_{n}\right)^{3/2}}}\ {\underset {n}{\sim }}\ 6^{3/2}2{\frac {\zeta (3)}{\pi ^{3}}}}
Excess kurtosis
6
n
4
H
n
(
4
)
−
12
n
3
H
n
(
3
)
+
7
n
2
H
n
(
2
)
−
n
H
n
(
n
2
H
n
(
2
)
−
n
H
n
)
2
∼
6
5
{\displaystyle {\frac {6n^{4}H_{n}^{(4)}-12n^{3}H_{n}^{(3)}+7n^{2}H_{n}^{(2)}-nH_{n}}{(n^{2}H_{n}^{(2)}-nH_{n})^{2}}}\sim {\frac {6}{5}}}
MGF
(
n
e
t
n
)
−
1
{\displaystyle {{\frac {n}{e^{t}}} \choose n}^{-1}}
CF
(
n
e
i
t
n
)
−
1
{\displaystyle {{\frac {n}{e^{it}}} \choose n}^{-1}}
PGF
G
(
z
)
=
(
n
z
n
)
−
1
{\displaystyle G(z)={{\frac {n}{z}} \choose n}^{-1}}
Graph of number of coupons, n vs the expected number of trials (i.e., time) needed to collect them all E (T )
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
Θ
(
n
log
(
n
)
)
{\displaystyle \Theta (n\log(n))}
.[ a] For example, when n = 50 it takes about 225[ b] trials on average to collect all 50 coupons. Sometimes the problem is instead expressed in terms of an n -sided die.
Calculating the expectation [ edit ]
Let time T be the number of draws needed to collect all n coupons, and let t i be the time to collect the i -th coupon after i − 1 coupons have been collected. Then
T
=
t
1
+
⋯
+
t
n
{\displaystyle T=t_{1}+\cdots +t_{n}}
. Think of T and t i as random variables . Observe that the probability of collecting a new coupon is
p
i
=
n
−
(
i
−
1
)
n
=
n
−
i
+
1
n
{\displaystyle p_{i}={\frac {n-(i-1)}{n}}={\frac {n-i+1}{n}}}
. Therefore,
t
i
{\displaystyle t_{i}}
has geometric distribution with expectation
1
p
i
=
n
n
−
i
+
1
{\displaystyle {\frac {1}{p_{i}}}={\frac {n}{n-i+1}}}
. By the linearity of expectations we have:
E
(
T
)
=
E
(
t
1
+
t
2
+
⋯
+
t
n
)
=
E
(
t
1
)
+
E
(
t
2
)
+
⋯
+
E
(
t
n
)
=
1
p
1
+
1
p
2
+
⋯
+
1
p
n
=
n
n
+
n
n
−
1
+
⋯
+
n
1
=
n
⋅
(
1
1
+
1
2
+
⋯
+
1
n
)
=
n
⋅
H
n
.
{\displaystyle {\begin{aligned}\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{aligned}}}
Here H n is the n -th harmonic number . Using the asymptotics of the harmonic numbers, we obtain:
E
(
T
)
=
n
⋅
H
n
=
n
log
n
+
γ
n
+
1
2
+
O
(
1
/
n
)
,
{\displaystyle \operatorname {E} (T)=n\cdot H_{n}=n\log n+\gamma n+{\frac {1}{2}}+O(1/n),}
where
γ
≈
0.5772156649
{\displaystyle \gamma \approx 0.5772156649}
is the Euler–Mascheroni constant .
Using the Markov inequality to bound the desired probability:
P
(
T
≥
c
n
H
n
)
≤
1
c
.
{\displaystyle \operatorname {P} (T\geq cnH_{n})\leq {\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:
E
(
T
k
)
=
E
(
t
k
+
1
+
t
k
+
2
+
⋯
+
t
n
)
=
n
⋅
(
1
1
+
1
2
+
⋯
+
1
n
−
k
)
=
n
⋅
H
n
−
k
{\displaystyle {\begin{aligned}\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{aligned}}}
And when
k
=
0
{\displaystyle k=0}
then we get the original result.
Calculating the variance [ edit ]
Using the independence of random variables t i , we obtain:
Var
(
T
)
=
Var
(
t
1
+
⋯
+
t
n
)
=
Var
(
t
1
)
+
Var
(
t
2
)
+
⋯
+
Var
(
t
n
)
=
1
−
p
1
p
1
2
+
1
−
p
2
p
2
2
+
⋯
+
1
−
p
n
p
n
2
=
(
n
2
n
2
+
n
2
(
n
−
1
)
2
+
⋯
+
n
2
1
2
)
−
(
n
n
+
n
n
−
1
+
⋯
+
n
1
)
=
n
2
⋅
(
1
1
2
+
1
2
2
+
⋯
+
1
n
2
)
−
n
⋅
(
1
1
+
1
2
+
⋯
+
1
n
)
<
π
2
6
n
2
{\displaystyle {\begin{aligned}\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{aligned}}}
since
π
2
6
=
1
1
2
+
1
2
2
+
⋯
+
1
n
2
+
⋯
{\displaystyle {\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 :
P
(
|
T
−
n
H
n
|
≥
c
n
)
≤
π
2
6
c
2
.
{\displaystyle \operatorname {P} \left(|T-nH_{n}|\geq cn\right)\leq {\frac {\pi ^{2}}{6c^{2}}}.}
Let the random variable X be the number of dice rolls performed before all faces have occurred.
The subpower is defined
k
{
n
}
=
k
!
{
n
k
}
{\displaystyle k^{\{n\}}=k!\left\{{n \atop k}\right\}}
, where
{
n
k
}
{\displaystyle \left\{{n \atop k}\right\}}
is a Stirling number of the second kind .[ 1]
Sequences of
x
{\displaystyle x}
die rolls are functions
x
→
n
{\displaystyle x\rightarrow n}
counted by
n
x
{\displaystyle n^{x}}
, while surjections (that land on each face at least once) are counted by
n
{
x
}
{\displaystyle n^{\{x\}}}
, so the probability that all faces were landed on within the x -th throw is
P
(
X
≤
x
)
=
n
{
x
}
n
x
{\displaystyle P(X\leq x)={\frac {n^{\{x\}}}{n^{x}}}}
. By the recurrence relation of the Stirling numbers, the probability that exactly x rolls are needed is
P
(
X
=
x
)
=
n
{
x
}
n
x
−
n
{
x
−
1
}
n
x
−
1
=
(
n
−
1
)
{
x
−
1
}
n
x
−
1
{\displaystyle P(X=x)={\frac {n^{\{x\}}}{n^{x}}}-{\frac {n^{\{x-1\}}}{n^{x-1}}}={\frac {(n-1)^{\{x-1\}}}{n^{x-1}}}}
Generating functions [ edit ]
Replacing
z
{\displaystyle z}
with
1
+
z
{\displaystyle 1+z}
in the probability generating function produces the o.g.f. for
E
[
(
X
k
)
]
{\displaystyle E\left[{X \choose k}\right]}
. Using the partial fraction decomposition
(
1
x
−
1
n
)
−
1
=
∑
k
=
0
n
(
n
k
)
(
−
1
)
n
−
k
1
−
k
x
{\displaystyle {{\frac {1}{x}}-1 \choose n}^{-1}=\sum _{k=0}^{n}{n \choose k}{\frac {(-1)^{n-k}}{1-kx}}}
, we can take the expansion
(
n
x
+
1
n
)
−
1
=
∑
i
=
0
n
(
n
i
)
(
−
1
)
n
−
i
1
−
i
(
1
−
n
x
+
1
+
n
)
=
∑
i
=
0
n
(
n
i
)
(
−
1
)
n
−
i
(
1
+
n
1
+
n
−
i
+
i
n
∑
k
=
1
∞
(
i
−
1
)
k
−
1
(
n
+
1
−
i
)
k
+
1
x
k
)
{\displaystyle {\begin{aligned}&{{\frac {n}{x+1}} \choose n}^{-1}\\=&\sum _{i=0}^{n}{n \choose i}{\frac {(-1)^{n-i}}{1-i(1-{\frac {n}{x+1+n}})}}\\=&\sum _{i=0}^{n}{n \choose i}(-1)^{n-i}\left({\frac {1+n}{1+n-i}}+in\sum _{k=1}^{\infty }{\frac {(i-1)^{k-1}}{(n+1-i)^{k+1}}}x^{k}\right)\end{aligned}}}
revealing that for
k
>
0
{\displaystyle k>0}
,
E
[
(
X
k
)
]
=
n
∑
i
=
0
n
(
n
i
)
(
−
1
)
n
−
i
i
(
i
−
1
)
k
−
1
(
n
+
1
−
i
)
k
+
1
{\displaystyle E\left[{X \choose k}\right]=n\sum _{i=0}^{n}{n \choose i}(-1)^{n-i}i{\frac {(i-1)^{k-1}}{(n+1-i)^{k+1}}}}
Given an o.g.f. f , since
(
x
1
−
x
)
i
=
∑
n
=
0
∞
(
k
−
1
i
−
1
)
x
k
{\displaystyle \left({\frac {x}{1-x}}\right)^{i}=\sum _{n=0}^{\infty }{k-1 \choose i-1}x^{k}}
, a variation of the binomial transform is
[
x
k
]
f
(
x
1
+
x
)
=
∑
i
=
0
k
(
k
−
1
i
−
1
)
(
−
1
)
k
−
i
[
x
i
]
f
(
x
)
{\displaystyle [x^{k}]f\left({\frac {x}{1+x}}\right)=\sum _{i=0}^{k}{k-1 \choose i-1}(-1)^{k-i}[x^{i}]f(x)}
. (Specifically, if
(
n
x
+
1
n
)
−
1
=
f
(
x
1
+
x
)
{\displaystyle {{\frac {n}{x+1}} \choose n}^{-1}=f\left({\frac {x}{1+x}}\right)}
,
f
(
x
)
=
(
n
−
n
x
n
)
−
1
{\displaystyle f(x)={n-nx \choose n}^{-1}}
.)
Rewriting the binomial coefficient via the gamma function and expanding as the
exp
{\displaystyle \exp }
of the polygamma series (in terms of generalised harmonic numbers ), we find
[
x
i
i
!
]
(
n
−
x
n
)
−
1
=
∑
P
∈
p
e
r
m
s
(
i
)
∏
c
∈
P
H
n
(
|
c
|
)
{\displaystyle \left[{\frac {x^{i}}{i!}}\right]{n-x \choose n}^{-1}=\sum _{P\in \mathrm {perms} (i)}\prod _{c\in P}H_{n}^{(|c|)}}
, so
E
[
(
X
k
)
]
=
∑
i
=
0
k
(
k
−
1
i
−
1
)
(
−
1
)
k
−
i
n
i
i
!
∑
P
∈
p
e
r
m
s
(
i
)
∏
c
∈
P
H
n
(
|
c
|
)
{\displaystyle E\left[{X \choose k}\right]=\sum _{i=0}^{k}{k-1 \choose i-1}(-1)^{k-i}{\frac {n^{i}}{i!}}\sum _{P\in \mathrm {perms} (i)}\prod _{c\in P}H_{n}^{(|c|)}}
which can also be written with the falling factorial and Lah numbers as
E
[
x
k
_
]
=
∑
i
=
0
k
L
(
k
,
i
)
(
−
1
)
k
−
i
n
i
∑
P
∈
p
e
r
m
s
(
i
)
∏
c
∈
P
H
n
(
|
c
|
)
{\displaystyle E[x^{\underline {k}}]=\sum _{i=0}^{k}L(k,i)(-1)^{k-i}n^{i}\sum _{P\in \mathrm {perms} (i)}\prod _{c\in P}H_{n}^{(|c|)}}
The raw moments of the distribution can be obtained from the falling moments via a Stirling transform; due to the identity
{
K
i
}
(
−
1
)
K
=
∑
k
=
0
K
{
K
k
}
L
(
k
,
i
)
(
−
1
)
k
{\displaystyle \left\{{K \atop i}\right\}(-1)^{K}=\sum _{k=0}^{K}\left\{{K \atop k}\right\}L(k,i)(-1)^{k}}
, this provides
E
[
x
k
]
=
∑
i
=
0
k
{
k
i
}
(
−
1
)
k
−
i
n
i
∑
P
∈
p
e
r
m
s
(
i
)
∏
c
∈
P
H
n
(
|
c
|
)
{\displaystyle E[x^{k}]=\sum _{i=0}^{k}\left\{{k \atop i}\right\}(-1)^{k-i}n^{i}\!\!\sum _{P\in \mathrm {perms} (i)}\prod _{c\in P}H_{n}^{(|c|)}}
A stronger tail estimate for the upper tail be obtained as follows. Let
Z
i
r
{\displaystyle {Z}_{i}^{r}}
denote the event that the
i
{\displaystyle i}
-th coupon was not picked in the first
r
{\displaystyle r}
trials. Then
P
[
Z
i
r
]
=
(
1
−
1
n
)
r
≤
e
−
r
/
n
.
{\displaystyle {\begin{aligned}P\left[{Z}_{i}^{r}\right]=\left(1-{\frac {1}{n}}\right)^{r}\leq e^{-r/n}.\end{aligned}}}
Thus, for
r
=
β
n
log
n
{\displaystyle r=\beta n\log n}
, we have
P
[
Z
i
r
]
≤
e
(
−
β
n
log
n
)
/
n
=
n
−
β
{\displaystyle P\left[{Z}_{i}^{r}\right]\leq e^{(-\beta n\log n)/n}=n^{-\beta }}
. Via a union bound over the
n
{\displaystyle n}
coupons, we obtain
P
[
T
>
β
n
log
n
]
=
P
[
⋃
i
Z
i
β
n
log
n
]
≤
n
⋅
P
[
Z
1
β
n
log
n
]
≤
n
−
β
+
1
.
{\displaystyle {\begin{aligned}P\left[T>\beta n\log n\right]=P\left[\bigcup _{i}{Z}_{i}^{\beta n\log n}\right]\leq n\cdot P[{Z}_{1}^{\beta n\log n}]\leq n^{-\beta +1}.\end{aligned}}}
Extensions and generalizations [ edit ]
P
(
T
<
n
log
n
+
c
n
)
→
e
−
e
−
c
,
as
n
→
∞
.
{\displaystyle \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 T m be the first time m copies of each coupon are collected. They showed that the expectation in this case satisfies:
E
(
T
m
)
=
n
log
n
+
(
m
−
1
)
n
log
log
n
+
O
(
n
)
,
as
n
→
∞
.
{\displaystyle \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:
P
(
T
m
<
n
log
n
+
(
m
−
1
)
n
log
log
n
+
c
n
)
→
e
−
e
−
c
/
(
m
−
1
)
!
,
as
n
→
∞
.
{\displaystyle \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.[ 3]
E
(
T
)
=
∫
0
∞
(
1
−
∏
i
=
1
m
(
1
−
e
−
p
i
t
)
)
d
t
.
{\displaystyle \operatorname {E} (T)=\int _{0}^{\infty }\left(1-\prod _{i=1}^{m}\left(1-e^{-p_{i}t}\right)\right)dt.}
This is equal to
E
(
T
)
=
∑
q
=
0
m
−
1
(
−
1
)
m
−
1
−
q
∑
|
J
|
=
q
1
1
−
P
J
,
{\displaystyle \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 P J denotes the probability of getting any coupon in the set of coupons J .
^ 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 .
^ E(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
+
γ
n
+
1
/
2
{\displaystyle n\log n+\gamma n+1/2}
for this expected number gives in this case
50
log
50
+
50
γ
+
1
/
2
≈
195.6011
+
28.8608
+
0.5
≈
224.9619
{\displaystyle 50\log 50+50\gamma +1/2\approx 195.6011+28.8608+0.5\approx 224.9619}
.
^ Rus, Mircea Dan (15 January 2025). "Yet another note on notation". arXiv :2501.08762 [math.NT ].
^ Mitzenmacher, Michael (2017). Probability and computing : randomization and probabilistic techniques in algorithms and data analysis . Eli Upfal (2nd ed.). Cambridge, United Kingdom. Theorem 5.13. ISBN 978-1-107-15488-9 . OCLC 960841613 . {{cite book }}
: CS1 maint: location missing publisher (link )
^ Flajolet, Philippe; Gardy, Danièle; Thimonier, Loÿs (1992), "Birthday paradox, coupon collectors, caching algorithms and self-organizing search", Discrete Applied Mathematics , 39 (3): 207– 229, CiteSeerX 10.1.1.217.5965 , doi :10.1016/0166-218x(92)90177-c
Blom, Gunnar; Holst, Lars; Sandell, Dennis (1994), "7.5 Coupon collecting I, 7.6 Coupon collecting II, and 15.4 Coupon collecting III", Problems and Snapshots from the World of Probability , New York: Springer-Verlag, pp. 85– 87, 191, ISBN 0-387-94161-4 , MR 1265713 .
Dawkins, Brian (1991), "Siobhan's problem: the coupon collector revisited", The American Statistician , 45 (1): 76– 82, doi :10.2307/2685247 , JSTOR 2685247 .
Erdős, Paul ; Rényi, Alfréd (1961), "On a classical problem of probability theory" (PDF) , Magyar Tudományos Akadémia Matematikai Kutató Intézetének Közleményei , 6 : 215– 220, MR 0150807 .
Laplace, Pierre-Simon (1812), Théorie analytique des probabilités , pp. 194– 195 .
Newman, Donald J. ; Shepp, Lawrence (1960), "The double dixie cup problem", American Mathematical Monthly , 67 (1): 58– 61, doi :10.2307/2308930 , JSTOR 2308930 , MR 0120672
Flajolet, Philippe ; Gardy, Danièle; Thimonier, Loÿs (1992), "Birthday paradox, coupon collectors, caching algorithms and self-organizing search" , Discrete Applied Mathematics , 39 (3): 207– 229, doi :10.1016/0166-218X(92)90177-C , MR 1189469 .
Isaac, Richard (1995), "8.4 The coupon collector's problem solved", The Pleasures of Probability , Undergraduate Texts in Mathematics , New York: Springer-Verlag, pp. 80– 82, ISBN 0-387-94415-X , MR 1329545 .
Motwani, Rajeev ; Raghavan, Prabhakar (1995), "3.6. The Coupon Collector's Problem", Randomized algorithms , Cambridge: Cambridge University Press, pp. 57– 63, ISBN 9780521474658 , MR 1344451 .