# Conditional + Marginal Probabilities

If $$X \sim Gamma (\alpha, \beta)$$ and $$Y|X \sim Gamma(c, X)$$, how can I derive the marginal probability density function of $$Y$$ and the conditional probability density function of $$X|Y$$?

I know that for $$Y|X = x$$, $$f(x,y) = f(y|x) f(x)= \frac{\beta^\alpha}{\Gamma(\alpha)}x^{\alpha - 1}e^{-\beta x}\frac{x^c}{\Gamma(c)}y^{c-1}e^{-xy}$$ and that $$f_{Y}(y) = \int_0^\infty f(x,y)dx$$. I'm getting to the point where I see that $$f_{Y}(y) = \frac{y^{c-1}}{\Gamma(c)}\int_0^\infty x^c e^{-xy}dx$$.

Am I on the right track? Can this be further simplified?

You are on the right track.

So starting from

$$f_Y(y)=\int_0^{\infty} f(x,y)dx = \int_0^{\infty}\frac{\beta^\alpha}{\Gamma(\alpha)\Gamma(c)}y^{c-1} x^{\alpha+c - 1}e^{-(\beta+y) x} dx$$

$$= \frac{\beta^\alpha}{\Gamma(\alpha)\Gamma(c)}y^{c-1} \int_0^{\infty}x^{\alpha+c - 1}e^{-(\beta+y) x} dx$$

Now, this seems a known pdf, hence

$$= \frac{\beta^\alpha}{\Gamma(\alpha)\Gamma(c)}y^{c-1} \frac{\Gamma(\alpha+c)}{(\beta+y)^{\alpha+c}}\underbrace{\int_0^{\infty}\frac{(\beta+y)^{\alpha+c}}{\Gamma(\alpha+c)} x^{\alpha+c - 1}e^{-(\beta+y) x} dx}_{=1}$$

$$=\frac{\Gamma(\alpha+c)}{\Gamma(\alpha)\Gamma(c)}\frac{\beta^{\alpha}}{(\beta+y)^{\alpha+c}}y^{c-1}$$

I don't know if you can simplify it any further.

You can find $$f(x|y)$$ in a similar way.