13.4 Hypergeometric Distribution
13.4.1 Probability Mass Function
If \(a \in \mathbb{N}\), \(b \in \mathbb{N}\), and \(N \in \{0,\ldots,a+b\}\), then for \(n \in \{\max(0,N-b),\ldots,\min(a,N)\}\), \[ \text{Hypergeometric}(n~|~N,a,b) = \frac{\normalsize{\binom{a}{n} \binom{b}{N - n}}} {\normalsize{\binom{a + b}{N}}}. \]
13.4.2 Sampling Statement
n ~
hypergeometric
(N, a, b)
Increment target log probability density with hypergeometric_lupmf(n | N, a, b)
.
13.4.3 Stan Functions
real
hypergeometric_lpmf
(int n | int N, int a, int b)
The log hypergeometric probability mass of n successes in N trials
given total success count of a and total failure count of b
real
hypergeometric_lupmf
(int n | int N, int a, int b)
The log hypergeometric probability mass of n successes in N trials
given total success count of a and total failure count of b dropping constant
additive terms
int
hypergeometric_rng
(int N, int a, int b)
Generate a hypergeometric variate with N trials, total success count
of a, and total failure count of b; may only be used in transformed data and
generated quantities blocks