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 * Hn, where n is the number of coupons to collect and Hn is the n-th harmonic number: 1

$$ 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