# Wallenius’ Noncentral Hypergeometric Distribution

A random variable has Wallenius’ Noncentral Hypergeometric distribution with parameters

\(M \in {\mathbb N}\), \(n \in [0, M]\), \(N \in [0, M]\), \(\omega > 0\),

if its probability mass function is given by

\[p(x; N, n, M) = \binom{n}{x} \binom{M - n}{N-x}\int_0^1 \left(1-t^{\omega/D}\right)^x\left(1-t^{1/D}\right)^{N-x} dt\]

for \(x \in [x_l, x_u]\), where \(x_l = \max(0, N - (M - n))\), \(x_u = \min(N, n)\),

\[D = \omega(n - x) + ((M - n)-(N-x)),\]

and the binomial coefficients are

\[\binom{n}{k} \equiv \frac{n!}{k! (n - k)!}.\]

## References

- Agner Fog, “Biased Urn Theory”, https://cran.r-project.org/web/packages/BiasedUrn/vignettes/UrnTheory.pdf

- “Wallenius’ noncentral hypergeometric distribution”, Wikipedia, https://en.wikipedia.org/wiki/Wallenius’_noncentral_hypergeometric_distribution

Implementation: `scipy.stats.nchypergeom_wallenius`