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
 A: 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)$.
A: this question deals with Compound Probability distribution.
I'll give you some hints.
If $f(x\mid\theta)$ and $\pi(\theta \mid \phi)$ are the distribution functions (with parameters $\theta$ and $\phi$ respectively and you want to find distribution of $X\mid\phi$ then use the following formula:
$$F(x\mid\phi)= \int_\Theta f(x\mid\theta) \pi(\theta\mid\phi) d\theta$$
These type of problems belong to Bayesian Statistics so you can read more if you are interested.
I suppose in your case the answer would be negative binomial as a gamma mixture of poissons gives negative binomial but I am not very sure,so verify it first.
Hope this helps.
A: $$
\int_0^\infty \frac{\lambda^n}{n!}e^{-\lambda}\frac{\beta^\alpha}{\Gamma(\alpha)}\lambda^{\alpha-1}e^{-\beta\lambda} \, d\lambda = \frac{\beta^\alpha}{n!\Gamma(\alpha)} \int_0^\infty \lambda^{n+\alpha-1} e^{-\lambda(\beta+1)} \, d\lambda.\tag{1}
$$
The second integral is
$$
\int_0^\infty \lambda^{\text{something}-1} e^{-\text{something}\cdot\lambda} \, d\lambda.
$$
Such an integral evaluates to
$$
\frac{\Gamma(\text{something})}{\text{something}^\text{something}},
$$
where, of course, you have to be careful about which "something" is which.  Hence, it is
$$
\frac{\Gamma(n+\alpha)}{(\beta+1)^{n+\alpha}}.
$$
And then of course, you have to multiply it by the fraction in front of the integral in $(1)$.  You get
$$
\frac{\beta^\alpha}{n!\Gamma(\alpha)}\cdot \frac{\Gamma(n+\alpha)}{(\beta+1)^{n+\alpha}}.
$$
Then of course $\Gamma(n+\alpha)/\Gamma(\alpha)$ reduces to
$$
(n+\alpha-1)(n+\alpha-2)\cdots(3+\alpha)(2+\alpha)(1+\alpha)\alpha.
$$
