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.
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^*)$.