15.4 Hypergeometric distribution
15.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}}}. \]
15.4.2 Sampling statement
n ~
hypergeometric
(N, a, b)
Increment target log probability density with hypergeometric_lupmf(n | N, a, b)
.
Available since 2.0
15.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
Available since 2.12
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
Available since 2.25
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
Available since 2.18