Correct interpretation + implementation of Beta Binomial sampling function?

52 Views Asked by At

I understand that the Beta Binomial distribution $BB(n,\alpha,\beta)$ can be interpreted as a Binomial distribution $Binom(n,p)$ where $p \approx Beta(\alpha,\beta)$. In some contexts we can interpret $\alpha$ and $\beta$ as the number of previously observed successes/failures from prior experience.

I understand that a valid way of implementing a sampling function for $BB(n,\alpha, \beta)$ is

1) $p' = $ sample from $Beta(\alpha,\beta)$

2) $x = $ sample from $Binom(n,p')$

An interpretation of this is that a cohort of $n$ individuals all "succeeded" with the same probability $p'$, where $p'$ may differ between cohorts.

My question is whether it is valid and equivalent to implement a Beta Binomial sampling function as a collection of $n$ Bernoulli trials where $p$ is re-sampled from $Beta(\alpha,\beta)$ for each trial:

1) For $i = 1...n$

2) $ \qquad p_i=$ sample from $Beta(\alpha,\beta)$

3) $ \qquad x_i=$ sample from $Bernoulli(p_i)$

4) $x = \sum_i x_i$

The interpretation being that success probability was random across the $n$ individual, instead of being fixed for the cohort.

Which interpretation + implementation of Beta Binomial sampling function is correct?