Poisson conditional on Gamma $Y\mid X\sim \textrm{Poisson}(X)$ and $X\sim\textrm{Gamma}(k,\theta)$
Find the marginal distribution, mean and variance of $Y$. Show that the marginal distribution is a negative binomial if $k$ is an integer.
 A: Sometimes "$\mathrm{Gamma}(k,\theta)$" means the density is
$$
\text{constant}\cdot x^{k-1} e^{-\theta x}
$$
and sometimes it means the density is
$$
\text{constant}\cdot x^{k-1} e^{-x/\theta}.
$$
For now I'll assume the second meaning, and if you want to go with the first one, then just make the relevant changes.
\begin{align}
\Pr(Y=y) & = \operatorname{E}(\Pr( Y=y \mid X)) = \operatorname{E}\left( \frac{ X^y e^{-X}}{y!} \right) = \frac{1}{\theta^k\Gamma(k)}\int_0^\infty \frac{ x^y e^{-x}}{y!}  x^{k-1} e^{-x/\theta} \, dx \\[8pt]
& = \frac{1}{y!\theta^k\Gamma(k)}\int_0^\infty x^{y+k-1} e^{-x(\theta+1)/\theta} \, dx \\[8pt]
& = \frac{1}{y!\theta^k\Gamma(k)}\cdot\left(\frac{\theta}{1+\theta}\right)^{y+k}\int_0^\infty \left(\frac{1+\theta}{\theta} x\right)^{y+k-1} e^{-x(1+\theta)/\theta} \, \left( \frac{1+\theta}{\theta} dx\right) \\[8pt]
& = \frac{1}{y!\theta^k\Gamma(k)}\cdot\left(\frac{\theta}{1+\theta}\right)^{y+k}\int_0^\infty u^{y+k-1} e^{-u} \, du \\[8pt]
& = \frac{\Gamma(y+k)}{y!\theta^k\Gamma(k)}\cdot\left(\frac{\theta}{1+\theta}\right)^{y+k} \\[8pt]
& = \frac{(y+k-1)!}{y! (k-1)!}\cdot \frac{\theta^y}{(1+\theta)^{y+k}} \\[8pt] &  = \frac{(y+k-1)!}{y! (k-1)!}\cdot \left(\frac{\theta}{1+\theta}\right)^y \left(1 - \frac{\theta}{1+\theta}\right)^k
\end{align}
