# Binomial-beta conjugate model¶

## Posterior predictive distribution¶

If $$X|p \sim \mathcal{BI}(m, p)$$ with $$p \sim \mathcal{B}(\alpha, \beta)$$, then the posterior predictive probability density function, the expected value and variance of $$X$$ are

$f(x; m, \alpha, \beta) = \binom{m}{x}\frac{B(\alpha + x, m - x + \beta)} {B(\alpha, \beta)}, \quad x = 0, 1, 2, \ldots.$
$\mathrm{E}[X] = m\frac{\alpha}{\alpha + \beta}, \quad \mathrm{Var}[X] = \frac{m \alpha \beta (m + \alpha + \beta)}{(\alpha + \beta)^2 (\alpha + \beta + 1)}.$

## Proofs¶

Posterior predictive probability density function

$\begin{split}f(x; m, \alpha, \beta) &= \int_0^1 \binom{m}{x}p^x (1-p)^{m - x} \frac{p^{\alpha - 1} (1-p)^{\beta - 1}}{B(\alpha, \beta)} \mathop{dp}\\ &= \binom{m}{x}\frac{1}{B(\alpha, \beta)} \int_0^1 p^{\alpha + x - 1} (1-p)^{\beta + m - x - 1} \mathop{dp} = \binom{m}{x}\frac{B(\alpha + x, m - x + \beta)} {B(\alpha, \beta)},\end{split}$

Note that this is the probability density function of the beta-binomial distribution, thus

$X \sim \mathcal{BB}(m, \alpha, \beta),$

Posterior predictive expected value

$\mathrm{E}[X] = \mathrm{E}[\mathrm{E}[X | p]] = \mathrm{E}[mp] = m\frac{\alpha}{\alpha + \beta}.$

Posterior predictive variance

Applying properties of the beta-binomial distribution, we obtain

$\mathrm{Var}[X] = \frac{m \alpha \beta (m + \alpha + \beta)}{(\alpha + \beta)^2 (\alpha + \beta + 1)}.$