The beta-binomial model is a Bayesian model used to analyze rates. For a great derivation and explanation of this model, I highly recommend watching the second lecture from Richard McElreath’s course Statistical Rethinking. In this model, the data, , is assumed to be binomially distributed with a fixed number of trail
but an unknown rate
. The rate
is given a
prior. That is the prior distribution of
has a density
where is a normalizing constant. The model can thus be written as
This is a conjugate model, meaning that the posterior distribution of is again a beta distribution. This can be seen by using Bayes rule
The last expression is proportional to a beta density., specifically .
The marginal distribution of 
In the above model we are given the distribution of and the conditional distribution of
. To calculate the distribution of
, we thus need to marginalize over
. Specifically,
The term inside the above integral is
Thus,
This distribution is called the beta-binomial distribution. Below is an image from Wikipedia showing a graph of for
and a number of different values of
and
. You can see that, especially for small value of
and
the distribution is a lot more spread out than the binomial distribution. This is because there is randomness coming from both
and the binomial conditional distribution.
