All problems
Expected Trials Two Coupons
Problem
If each trial independently yields coupon A with probability p1, coupon B with probability p2, or neither, the expected number of trials until both have appeared is 1/p1 + 1/p2 - 1/(p1 + p2).
Given p1 and p2 with p1 + p2 <= 1, return the expectation.
Hint
Inclusion-exclusion over the two waiting times.
Test cases
case 1
in: [0.1,0.2]
expected: 11.666666666666668
case 2
in: [0.5,0.5]
expected: 3
case 3
in: [0.25,0.25]
expected: 6
Starter codePython
def expected_trials_two_coupons(p1, p2):
# Your code here
pass3 test cases · run your code against them in the editor