All problems
Hypergeometric PMF Value
Problem
Drawing n items without replacement from a population of N with K successes, P(k successes) = C(K, k) C(N - K, n - k) / C(N, n).
Given N, K, n, and k, return the probability.
Hint
Choose successes and failures separately, then divide by all draws.
Test cases
case 1
in: [10,4,3,2]
expected: 0.3
case 2
in: [20,10,5,2]
expected: 0.34829721362229105
case 3
in: [5,1,2,1]
expected: 0.4
Starter codePython
def hypergeometric_pmf_value(n_population, k_successes, n_draws, k_observed):
# Your code here
pass3 test cases · run your code against them in the editor