Distribution of Poisson variable conditional on a Gamma variable I dont' really know how to realize the following: Let $\lambda \sim \Gamma(\alpha,\beta)$ and let $X$ conditional on $\lambda$ be Poisson$(\lambda)$. Argue that for $n=0,1,2,\ldots,$ $$P(X=n)=\int_0^\infty \frac{\lambda^n}{n!}e^{-\lambda}\frac{\beta^\alpha}{\Gamma(\alpha)}\lambda^{\alpha-1}e^{-\beta\lambda} \, d\lambda.$$ I don't know how to deal with this type of conditional probability. I'd appreciate some help.
Fuente

Use the tower rule:
$$
   \mathbb{P}\left(X=n\right) = \mathbb{E}_\lambda\left(\underbrace{\mathbb{P}\left(X=n | \lambda\right)}_{X|\lambda \sim \operatorname{Poi}\left(\lambda\right)}\right)
$$
Write out the probability for the Poisson random variable, and then write the definition of the expectation.
The final expectation can also be computed easily:
$$
  \mathbb{P}\left(X=n\right) =  \int_0^\infty \frac{\lambda^n}{n!} \mathrm{e}^{-\lambda} \frac{\beta^\alpha}{\Gamma(\alpha)} \lambda^{\alpha-1} \mathrm{e}^{-\beta \lambda} \mathrm{d} \lambda = \binom{n+\alpha-1}{n} \left(\frac{\beta}{\beta+1} \right)^\alpha \frac{1}{(\beta+1)^n}
$$
This shows that $X$ is a negative binomial random variable, $X \sim \operatorname{NB}\left(\alpha, \frac{\beta}{\beta+1}\right)$.
