# Joint densities and gamma distribution

Let $$X$$~$$\Gamma(\alpha,\lambda)$$ and $$Y$$~ $$\Gamma(\beta,\lambda)$$, where $$\Gamma(r,\lambda)$$ denotes the Gamma distribution with density $$f_{r,\lambda}(x)=\lambda e^{-\lambda x}\frac{(\lambda x)^{r-1}}{\Gamma(r)}\mathbb{1}_{[o,\infty)}(x)$$ for $$\lambda >0, r>0$$. Denoting by $$f_X$$ the density of $$X$$ and $$f_Y$$ the density of $$Y$$, assume that the density of $$(X,Y)$$ is $$f_X\cdot f_Y$$.Define $$Z=X+Y$$ and $$U=\frac X{X+Y}$$

1. Show that the density of $$(Z,U)$$ can be written as the product of two densities.
2. Compute the density of $$U$$

What I did so far:

For 1: We have $$f_X(x)=\lambda e^{-\lambda x}\frac{(\lambda x)^{\alpha -1}}{\Gamma(\alpha)}\mathbb{1}_{[o,\infty)}(x)$$ and similarly $$f_Y(y)=\lambda e^{-\lambda y}\frac{(\lambda y)^{\beta -1}}{\Gamma(\beta)}\mathbb{1}_{[o,\infty)}(y)$$. Hence $$f_{(X,Y)}=\lambda^2e^{-\lambda(x+y)}\frac{(\lambda x)^{\alpha -1}(\lambda y)^{\beta -1}}{\Gamma(\alpha)\Gamma(\beta)}\mathbb{1}_{[o,\infty)}(x)\mathbb{1}_{[o,\infty)}(y)=\lambda^{\alpha+\beta}e^{-\lambda(x+y)}\frac{x^{\alpha-1}y^{\beta-1}}{\Gamma(\alpha)\Gamma(\beta)}\mathbb{1}_{[o,\infty)}(x)\mathbb{1}_{[o,\infty)}(y)$$

Then form the application $$g(x,y)=(x+y,\frac x{x+y})=(z,u)$$ we find its inverse to be $$g^{-1}(z,u)=(zu,z(1-u))$$ such that the Jacobian matrix is $$J_{g^{-1}}(z,u)= \begin{pmatrix}u&1-u \\z&-z \end{pmatrix} \Rightarrow |\det(J_{g^{-1}}(z,u))|=|-z|=z$$

So we have $$f_{(Z,U)}(z,u)=f_{(X,Y)}(zu,z(1-u))|\det(J_{g^{-1}}(z,u))|=\frac{\lambda^{\alpha+\beta}}{\Gamma(\alpha)\Gamma(\beta)}e^{-\lambda z}z^{\alpha+\beta-1}u^{\alpha-1}(1-u)^{\beta-1}\mathbb{1}_{[o,\infty)}(z)\mathbb{1}_{[o,\infty)}(u)$$

How can I say that this is a product of two densities? I don't know if the request is ambiguos or maybe do I miss something?

For 2: $$f_U(u)=\frac{\lambda^{\alpha+\beta}}{\Gamma(\alpha)\Gamma(\beta)}u^{\alpha-1}(1-u)^{\beta-1}\int_0^\infty e^{-\lambda z}z^{\alpha+\beta-1} dz$$

Since the integral using just partial integration seems to be infinite to compute, I used a calculator which returned that$$\int_0^\infty e^{-\lambda z}z^{\alpha+\beta-1} dz=-\lambda^{-\alpha-\beta}\Gamma(\alpha+\beta,\lambda z)$$.

Now this can be true, but we've never seen this "incomplete gamma function", so I was a litlle concerned about this result, is there a "smoother" way to compute it?

Divide and multiply by the term $$\Gamma(\alpha+\beta)$$ in your completed density $$f(Z, U)$$ to get

$$f(Z, U)=\frac{\lambda^{\alpha+\beta}}{\Gamma(\alpha+\beta)}z^{\alpha+\beta-1}e^{-\lambda z}\frac{\Gamma(\alpha+\beta)}{\Gamma(\alpha)\Gamma(\beta)}u^{\alpha-1}(1-u)^{\beta-1}, z>0, 0

As you can see this has been factored into the product of a $$\text{Gamma}(\alpha+\beta,\lambda)$$ density and a $$\text{Beta}(\alpha,\beta)$$ density.

Thus $$U\sim\text{Beta}(\alpha,\beta)$$ with density shown.

At this point we have answered both problems.

You could also integrate out the $$Z$$ to find the density of $$U$$ (not necessary as they are independent), in which case notice that $$\int_0^\infty z^{\alpha+\beta-1}e^{-\lambda z}=\frac{\Gamma(\alpha+\beta)}{\lambda^{\alpha+\beta}}$$

and we would end up with the density of the beta distribution (but again, was not necessary here as the joint density is factorizable into a function of $$U$$ and a function of $$Z$$)