# 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|X}(y|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|X}(y|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.

• $$f_Y(y)=E(X^{-1}\mathbf 1_{X>y})=\int_y^\infty x^{-1}f_X(x)dx=\ldots$$ – Did Nov 8 '15 at 18:10

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^*)$.
• Thank you! So $f_Y(y)$ is $\beta\over{\alpha-1}$ multiplied by the cumulative distribution function of $\Gamma(\alpha-1,\beta)$. – Keith Nov 9 '15 at 18:05
• It is actually the survival function: $$\Pr[X^* > y] = 1 - \Pr[X^* \le y] = 1 - F_{X^*}(y).$$ – heropup Nov 9 '15 at 20:09