All problems
Expected Distinct Coupons
Problem
Expected number of distinct coupons collected after draws independent uniform draws from n coupon types.
E[distinct] = n * (1 - (1 - 1/n)^draws), using linearity of expectation over indicators. Return 0.0 for n <= 0 or draws < 0.
Hint
Each coupon type is missing with probability (1 - 1/n)^draws.
Test cases
case 1
in: [365,365]
expected: 230.90815395794158
case 2
in: [6,1]
expected: 0.9999999999999998
case 3
in: [6,0]
expected: 0
case 4
in: [10,100]
expected: 9.999734386011124
Starter codePython
def expected_distinct_coupons(n, draws):
# Your code here
pass4 test cases · run your code against them in the editor