# A Poissonâ€“Gamma Mixture Is Negative-Binomially Distributed

#### We can view the negative binomial distribution as a Poisson distribution with a gamma prior on the rate parameter. I work through this derivation in detail.

Consider a Poisson model for count data,

The parameter $\theta$ can be interpreted as the *rate of arrivals*, and importantly, $\mathbb{E}[y] = \text{Var}(y) = \theta$. An unfortunate property of this Poisson model is that it cannot model *overdispersed* data or data in which the variance is greater than the mean. This is because Poisson regression has one free parameter. However, if we place a gamma prior on $\theta$,

and then marginalize out $\theta$, we get a negative binomial (NB) distribution, which has the useful property that its variance can be greater than its mean. The derivation is

Step $\star$ holds because of the following equality,

Wikipedia claims that this is part of the usefulness of the gamma function: integrals of expressions of the form $f(x) e^{-g(x)}$, which model exponential decay, can be sometimes solved in closed form using the above equation.

Step $\dagger$ uses the fact that $\Gamma(x) = (x - 1)!$.