toc

content

Coupon Collector's Problem

The Coupon Collector's Problem is about how many draws it is expected to take in order to collect all coupons by random draw. 1

Solution

The solution to the problem is n*Hnn * H_n, where nn is the number of coupons to collect and HnH_n is the nn-th harmonic number: 1

n*k=1n1k n * \sum_{k=1}^n \frac 1 k

In Haskell: 1

expected :: Int -> Float
expected n =
  fromIntegral n * sum [ 1.0 / (fromIntegral k) | k <- [1..n] ]

meta

tags: competitive-programming, math

created:

commit: 2fe19858