Question from P1 exam book - joint continuous gamma distribution. This is a question from the actuary P1 book If X and Y are independent gamma random variables with parameters (α, λ)
and (β, λ) respectively, compute the joint density of U = X + Y and $$ V =
\frac{X}{X+Y} $$
I was stuck on how to find $$ f_U $$ and $$ f_V $$
for a while but was able to figure it out. I had seen some questions pertaining to parts of this problem or slightly different problems with people struggling and thought I should post it. The answer with my work is below. I hope it helps!
 A: $$ f_{U,V}(u,v) = \frac {{ \begin{vmatrix} 1 & 1 \\ {\frac{y}{(x+y)^2}} & {\frac{-x}{(x+y)^2}} \end{vmatrix}}^{-1} \cdot (uv)^{(\alpha -1)} \cdot \lambda^\alpha \cdot e^{-\lambda uv} \cdot (u-uv)^{\beta - 1} \cdot \lambda^\beta \cdot e^{-\lambda(u-uv)}} {\Gamma(\alpha) \cdot \Gamma(\beta)} $$
$$ = \frac { u \cdot (uv)^{(\alpha -1)} \cdot \lambda^\alpha \cdot e^{-\lambda uv} \cdot (u-uv)^{\beta - 1} \cdot \lambda^\beta \cdot e^{-\lambda(u-uv)}} {{\Gamma(\alpha) \cdot \Gamma(\beta)}}  $$
$$ = \frac {e^{-\lambda u} \cdot {u^{\alpha + \beta -1} \cdot \lambda ^{\alpha + \beta} \cdot v^{\alpha-1} \cdot (1-v)^{\beta -1}}} {\Gamma(\alpha) \cdot \Gamma(\beta)} $$
$$ f_U = \int_0^1   \frac {e^{-\lambda u} \cdot {u^{\alpha + \beta -1} \cdot \lambda ^{\alpha + \beta}  \cdot v^{\alpha-1} \cdot (1-v)^{\beta -1}}} {\Gamma(\alpha) \cdot \Gamma(\beta)} dv = \frac {e^{-\lambda u} \cdot u^{\alpha + \beta -1}\cdot \lambda ^ {\alpha + \beta}} {\Gamma(\alpha +\beta)} $$
Because $$ \int_0^1 v^{\alpha-1} \cdot (1-v)^{\beta -1} dv = \frac {\Gamma(\alpha) \cdot \Gamma(\beta)} {\Gamma(\alpha + \beta)} $$
$$ f_V = \int_0^\infty   \frac {e^{-\lambda u} \cdot {u^{\alpha + \beta -1} \cdot \lambda ^{\alpha + \beta} \cdot v^{\alpha-1} \cdot (1-v)^{\beta -1}}} {\Gamma(\alpha) \cdot \Gamma(\beta)} du = \frac{ v^{\alpha-1} \cdot (1-v)^{\beta-1} \cdot \Gamma(\alpha + \beta)}{\Gamma (\alpha) \cdot \Gamma(\beta)}$$
Because we know $$  \int_0^\infty   \frac {e^{-\lambda u} \cdot {u^{\alpha + \beta -1} \cdot \lambda ^{\alpha + \beta}}} {\Gamma(\alpha + \beta)} du = 1 $$
And
$$ \frac{ v^{\alpha-1} \cdot (1-v)^{\beta-1} \cdot \Gamma(\alpha + \beta)}{\Gamma (\alpha) \cdot \Gamma(\beta)} \cdot  \frac {e^{-\lambda u} \cdot u^{\alpha + \beta -1} \cdot \lambda ^ {\alpha + \beta}} {\Gamma(\alpha +\beta)} = f_{U,V}(u,v) $$
Hence U and V are independent.
A: Solution using Jacobian Transformation theorem's method.

*

*If $X\sim {\rm Gamma}(\alpha,\lambda)$, with $\alpha>0$ and $\lambda>0$, then the density function for $X$ is given by
$$f_{X}(x)=\frac{\lambda^{\alpha}}{\Gamma(\alpha)}x^{\alpha-1}e^{-\lambda x},\quad x\in {\rm supp}(X).$$


*Suppose that  $X\sim {\rm Gamma}(\alpha,\lambda), Y\sim {\rm Gamma}(\beta,\lambda)$ and $X$ and $Y$ independent random variables.


*Define the random variables  $$U:=X+Y,\quad V:=\frac{X}{X+Y}$$


*Notice that we can re-write $(x,y)\mapsto u(x,y)$ and $(x,y)\mapsto v(x,y)$ as $(u,v)\mapsto x(u,v)$ and $(u,v)\mapsto y(u,v)$ as follows
$$\begin{cases}x=uv,\\y=u(1-v) \end{cases},\quad (u,v)\in U\times V$$


*The Jacobian of the change of variables is given by
$$J(u,v)=\det \begin{pmatrix}x_{u}&x_{v}\\ y_{u}&y_{v} \end{pmatrix}=-u;\quad |J(u,v)|=u$$


*An important result says that if $U$ and $V$ continuous random variables, then $$U\quad \text{independent to}\quad  V\quad \text{iff}\quad  f_{U,V}(u,v)=f_{U}(u) f_{V}(v),\quad (u,v)\in {\rm supp}(U\times V)$$


*The Jacobian transformation theorem, says that under certain hypotheses we have
$$f_{U,V}(u,v)=f(x(u,v),y(u,v))|J(u,v)|$$


*It is your task to check that all the hypotheses of the theorems used here are satisfied.


*By hypothesis $X$ and $Y$ are independent random variables, then
\begin{align} 
f_{X,Y}(x,y)&=f_{X}(x)f_{Y}(y),\\
&=\left[\frac{1}{\Gamma(\alpha)\Gamma(\beta)}e^{-\frac{1}{\lambda}\left(x+y\right)}\cdot x^{\alpha-1}\cdot y^{\beta-1}\right],\quad (x,y)\in {\rm supp}(X\times Y)
\end{align}
and then by the Jacobian transformation theorem
\begin{align}
f_{U,V}(u,v)&=\left[\frac{1}{\Gamma(\alpha)\Gamma(\beta)}e^{-\frac{1}{\lambda}\left(uv+u-uv \right)}\cdot (uv)^{\alpha-1}\cdot (u-uv)^{\beta-1} \right]\cdot u,\\
&=\left(\frac{u^{\alpha+\beta-1}e^{-\frac{1}{\lambda}u}}{\Gamma(\alpha+\beta)} \right)\cdot \left(\frac{v^{\alpha-1}(1-v)^{\beta-1}}{{\rm Beta} (\alpha,\beta)}\right),\quad (u,v)\in {\rm supp}(U\times V),\\
&=f_{U}(u)f_{V}(v),\quad \text{because}\quad {\rm Beta}(\alpha,\beta)=\frac{\Gamma(\alpha)\Gamma(\beta)}{\Gamma(\alpha+\beta)}
\end{align}


*Hence $U$ and $V$ are independent random variables.


*Moreover $$U\sim {\rm Gamma}(\alpha+\beta,\lambda)\quad \text{and}\quad V\sim {\rm Beta}(\alpha,\beta)$$
