Premium problem111. Sampling Without Replacement

Medium Locked

A population of N items contains K positives. Draw n without replacement. Return the probability of getting exactly k positives.

P=(Kk)(N−Kn−k)(Nn)P = \frac{\binom{K}{k}\binom{N-K}{n-k}}{\binom{N}{n}}

Use this rather than the binomial whenever the population is small enough that removing an item noticeably changes the odds for the next one.

Input

N = 50
K = 5
n = 10
k = 1

Output

0.43133719722856767

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)