Skip to content
DeepForgeby svx
All problems
HardProbabilitypr-139

Coupon Collector Variance

Problem

Variance of the number of draws needed to collect all n coupon types:

Var = sum from j = 0 to n - 1 of j * n / (n - j)^2.

This follows from writing the total time as a sum of independent geometric waiting times. Return 0.0 for n <= 0.

Hint

With j coupons collected, the waiting time is geometric with success probability (n - j) / n.

Test cases

case 1
in: [1]
expected: 0
case 2
in: [2]
expected: 2
case 3
in: [3]
expected: 6.75
case 4
in: [5]
expected: 25.17361111111111
Starter codePython
def coupon_collector_variance(n):
    # Your code here
    pass

4 test cases · run your code against them in the editor