13.3 Beta-binomial distribution
13.3.1 Probability mass function
If \(N \in \mathbb{N}\), \(\alpha \in \mathbb{R}^+\), and \(\beta \in \mathbb{R}^+\), then for \(n \in {0,\ldots,N}\), \[ \text{BetaBinomial}(n~|~N,\alpha,\beta) = \binom{N}{n} \frac{\mathrm{B}(n+\alpha, N -n + \beta)}{\mathrm{B}(\alpha,\beta)}, \] where the beta function \(\mathrm{B}(u,v)\) is defined for \(u \in \mathbb{R}^+\) and \(v \in \mathbb{R}^+\) by \[ \mathrm{B}(u,v) = \frac{\Gamma(u) \ \Gamma(v)}{\Gamma(u + v)}. \]
13.3.2 Sampling statement
n ~
beta_binomial
(N, alpha, beta)
Increment target log probability density with beta_binomial_lupmf(n | N, alpha, beta)
.
13.3.3 Stan functions
real
beta_binomial_lpmf
(ints n | ints N, reals alpha, reals beta)
The log beta-binomial probability mass of n successes in N trials
given prior success count (plus one) of alpha and prior failure count
(plus one) of beta
real
beta_binomial_lupmf
(ints n | ints N, reals alpha, reals beta)
The log beta-binomial probability mass of n successes in N trials
given prior success count (plus one) of alpha and prior failure count
(plus one) of beta dropping constant additive terms
real
beta_binomial_cdf
(ints n, ints N, reals alpha, reals beta)
The beta-binomial cumulative distribution function of n successes in N
trials given prior success count (plus one) of alpha and prior failure
count (plus one) of beta
real
beta_binomial_lcdf
(ints n | ints N, reals alpha, reals beta)
The log of the beta-binomial cumulative distribution function of n
successes in N trials given prior success count (plus one) of alpha
and prior failure count (plus one) of beta
real
beta_binomial_lccdf
(ints n | ints N, reals alpha, reals beta)
The log of the beta-binomial complementary cumulative distribution
function of n successes in N trials given prior success count (plus
one) of alpha and prior failure count (plus one) of beta
R
beta_binomial_rng
(ints N, reals alpha, reals beta)
Generate a beta-binomial variate with N trials, prior success count
(plus one) of alpha, and prior failure count (plus one) of beta; may
only be used in transformed data and generated quantities blocks.
For a description of argument and return types, see section
vectorized PRNG functions.