I have $X$ and $Y$ independent $\Gamma(2,a)$-distributed random variables. I am trying to find conditional distribution of $X$ given that $X+Y=2$.
My solution: set $U = X+Y, V = X.$ Inversion yields $ X=V, Y=U-V.$
$$f_{X,Y}(x,y)=f_X(x)\cdot f_Y(y) = \frac{1}{a^4}\cdot xy\cdot e^{-(x+y)/a} $$
$J = -1$, so $|J| = 1$, thus
$$f_{U,V}(u,v) = f_{X,Y}(v, u-v)\cdot 1 = \frac{1}{a^4} \cdot v(u-v)\cdot e^{-u/a},$$
from which I got the $f_U(u) = \frac{1}{a^4}\cdot e^{-u/a}\cdot \left( u-\frac{v^3} 3 \right)$, then
$$f_{V\mid U=2}(v) = \frac{f_{U,V}(2,v)}{f_U(2)} = \frac{e^{-2/a} \cdot(2v-v^2)}{a^4} \cdot \frac{a^4}{e^{-2/a}\cdot(2-v^3/3)} = \frac{3v(2-v)}{6-v^3},$$
but the book gives $\frac{3x}{2}\cdot(1-\frac{x}{2})$
Since $V=X$, the above $2$ should match, but not sure where I made the mistake.Checked multiple times, but no luck.
Please help. Thank you.
Your calculation of the marginal distribution $f_U(u)$ appears to be incorrect. I get $$f_U(u) = \int_{v=0}^u f_{U,V}(u,v) \, dv = \frac{u^3 e^{-u/a}}{6a^4}.$$ Note that the interval of integration is on $v \in [0,u]$, since $Y \ge 0$ implies $U - V \ge 0$ or $V \le U$. Furthermore, the marginal distribution cannot be a function of $v$. From this, we get $$f_{V \mid U = 2}(v) = \frac{f_{U,V}(2,v)}{f_U(2)} = \frac{v(2-v)e^{-2/a}}{a^4} \cdot \frac{3a^4}{4e^{-2/a}} = \frac{3}{2} v(1-v/2),$$ as claimed.