Compound of uniform and gamma probability distributions I am trying to compute the distribution of a uniform distribution whose upper limit is drawn from a gamma distribution.
That is,
$X \sim \Gamma(\alpha,\beta)$
$Y \sim U(0,X)$
We know:
$$f_X(x)={\beta^\alpha \over \Gamma(\alpha)} x^{\alpha-1} e^{-\beta x}$$
and  
$$f_{Y\mid X}(y\mid x) = 
\begin{cases}
 {1\over X} & 0 \le y \le X, \\
 0 & \text{otherwise},
\end{cases}
$$
but I get lost at the integral
$$f_Y(y) = \int_{x=0}^\infty f_{Y\mid X}(y\mid x) f_X(x)\,dx$$
I'm embarrassed to ask because I think the answer must be simple.  But it's been too long since I've done this.  I get:
$$f_Y(y)=\int_{x=0}^{x=\Gamma^{-1}(y)} 1\, dx = \Gamma^{-1}(y)$$
but I don't think that's right.  Please help! I'm a neuroscientist and I'm trying to understand a distribution I've measured.
 A: Write out the integrand:  $$f_{Y \mid X}(y \mid x) f_X(x) = \frac{1}{x} \frac{\beta^\alpha x^{\alpha-1} e^{-\beta x}}{\Gamma(\alpha)}, \quad 0 \le y \le x.$$  So the marginal density of $Y$ is $$f_Y(y) = \int_{x = y}^\infty \frac{\beta^\alpha x^{\alpha-2} e^{-\beta x}}{\Gamma(\alpha)} \, dx.$$  Note two things:  first, that the lower limit of the integral must be $x = y$, because if $x < y$, the conditional density of $Y \mid X$ is zero.  Second, we simplified the integrand by writing $x^{\alpha-1}/x = x^{\alpha-2}$.  Now we write $$f_Y(y) = \frac{\Gamma(\alpha-1)}{\Gamma(\alpha)} \beta \int_{x=y}^\infty \frac{\beta^{\alpha-1} x^{\alpha-2} e^{-\beta x}}{\Gamma(\alpha-1)} \, dx,$$ and recognize that $$\frac{\Gamma(\alpha-1)}{\Gamma(\alpha)} = \frac{1}{\alpha-1},$$ and the integrand is now a gamma density for shape parameter $\alpha^* = \alpha - 1$ and rate parameter $\beta^* = \beta$.  Thus, $$f_Y(y) = \frac{\beta}{\alpha-1} \Pr[X^* > y],$$ where $X^* \sim \operatorname{Gamma}(\alpha^*, \beta^*)$.
A: The answer by @heropup needs adjustments when $0 < \alpha < 1$, as $\alpha^*$ then falls outside the domain for the Gamma's distribution shape parameter. Thankfully the recursive properties of both the incomplete gamma function, and the gamma function itself, allow us to circumvent this limitation. Using $\bar{\text{F}}_X(x)$ to denote a survival function :
$$\begin{align}f_Y(y) &= \frac{\beta}{\alpha-1}\bar{\text{F}}_{X^*}(y)\\
&= \frac{\beta}{\alpha-1}\frac{\Gamma(\alpha-1,\beta y)}{\Gamma(\alpha-1)}\frac{(\alpha-1)}{(\alpha-1)}\\
&= \frac{\beta}{\alpha-1}\frac{(\alpha-1)\Gamma(\alpha-1,\beta y)}{\Gamma(\alpha)}\\
&= \frac{\beta}{\alpha-1}\frac{(\alpha-1)\Gamma(\alpha-1,\beta y)}{\Gamma(\alpha)}+\frac{\beta}{\alpha-1}\frac{(\beta y)^{\alpha-1}e^{-\beta y}}{\Gamma(\alpha)}-\frac{\beta}{\alpha-1}\frac{(\beta y)^{\alpha-1}e^{-\beta y}}{\Gamma(\alpha)}\\
&= \frac{\beta}{\alpha-1}\frac{(\alpha-1)\Gamma(\alpha-1,\beta y)+(\beta y)^{\alpha-1}e^{-\beta y}}{\Gamma(\alpha)}-\frac{\beta}{\alpha-1}\frac{(\beta y)^{\alpha-1}e^{-\beta y}}{\Gamma(\alpha)}\\
&= \frac{\beta}{\alpha-1}\frac{\Gamma(\alpha,\beta y)}{\Gamma(\alpha)}-\frac{\beta}{\alpha-1}\frac{(\beta y)^{\alpha-1}e^{-\beta y}}{\Gamma(\alpha)}\\
&= \frac{\beta}{\alpha-1}\bar{\text{F}}_{X}(y)-\frac{f_X(y)}{\alpha-1}\\
&= \frac{\beta\bar{\text{F}}_{X}(y)-f_X(y)}{\alpha-1}
\end{align}$$
Which is perfectly equivalent to @heropup's answer, and now extends to the full domain of $\alpha$.
