# Calculating an explicit conditional expectation

Suppose that $X$ and $Y$ are independent and $X\sim E(1)=\Gamma(1,1)$ and $Y\sim\Gamma(2,1)$. Then I am asked to find $E[X\mid X+Y]$ by using the following result:

Let $(U,V)$ be an $n+m$ dimensional random vector with density $(u,v)\mapsto f(u,v)$ with respect to $\lambda_{n+m}$. Put for $u\in\mathbb{R}^n$ and $v\in\mathbb{R}^m$ $$f_V(v)=\int_{\mathbb{R}^n} f(u,v)\lambda_n (du)\quad \text{and} \quad f_{U\mid V}(u\mid v)=\frac{f(u,v)}{f_V(v)}1_{\{0<f_V(v)<\infty\}}.$$ Then for every Borel function $\psi: \mathbb{R}^{n+m}\to\mathbb{R}$ with $E[|\psi(U,Y)|]<\infty$ we have that $$E[\psi(U,V)\mid V]=\varphi(V) \quad\text{a.s.},$$ where $$\varphi(v)=\int_{\mathbb{R}^n} \psi(u,v) f_{U\mid V}(u\mid v)\lambda_n (d v).$$

So I was thinking that I would use this result with $U=X$ and $V=X+Y$ and $\psi(x,y)=x$. Then we are clearly in the scope of this result. Since $X$ and $Y$ are independent we also have that $X+Y\sim\Gamma(3,1)$, and hence $f_V$ is just a Gamma-density.

Now my question is, how do I go by finding the joint density $f$ in the easiest way? I have tried looking at probabilities $P(X\leq a,X+Y\leq b)$ but without any luck (it got very messy). An additional question is: Is it possible to obtain the conditional expectation in other ways than using this result?

To answer your specific question, use jacobians, however I would not do it like that. Since $Y = Y_1 + Y_2, Y_i$ independent $\Gamma[1,1]$ you are asked for $E(X \vert X + Y_1 + Y_2), X, Y_i$ i.i.d.. In general, by symmetry, when $Z_i$ are i.i.d. $E(Z_i \vert Z_1 + .... + Z_n) = \frac {Z_1 + .... + Z_n} n$ –  mike Apr 25 '12 at 14:02
I actually solved this awhile ago, so here's the answer that uses the result stated in the original question. The density of $(X,Y)$ is given by $$f_{(X,Y)}(x,y)=ye^{-x}e^{-y},\quad x,y>0$$ due to independence. Let $T:\mathbb{R}^2 \to\mathbb{R}^2$ be the mapping given by $T(x,y)=(x,x+y)$. Then $T^{-1}(x,y)=(x,y-x)$ and the determinant of the Jacobian is $\det(T'(x,y))=1$ for all $x,y$. By a transformation theorem we have that $(X,Y+X)=T(X,Y)$ has density $$f_{(X,X+Y)}(x,y)=f_{(X,Y)}(T^{-1}(x,y))=f_{(X,Y)}(x,y-x)=e^{-x}(y-x)e^{-(y-x)},\quad x>0,\; y-x>0,$$ and hence $$f_{(X,X+Y)}(x,y)=(y-x)e^{-y},\quad y>x>0.$$ Using the fact that $X+Y\sim \Gamma(3,1)$ we get that $$f_{X\mid X+Y}(x\mid y)=\frac{f_{(X,X+Y)}(x,y)}{f_{X+Y}(y)}=\frac{(y-x)e^{-y}}{y^2 e^{-y}/\Gamma(3)}1_{\{0<f_{X+Y}(y)<\infty\}},\quad 0<x<y,$$ and hence $$f_{X\mid X+Y}(x\mid y)=2\frac{y-x}{y^2},\quad 0<x<y.$$ Let $\psi(x,y)=x$, then $E[|\psi(X,X+Y)|]=E[|X|]<\infty$, so we are in scope of the result above. Now $$E[X\mid X+Y]=E[\psi(X,X+Y)\mid X+Y]=\tilde{\psi}(X+Y)\quad a.s.,$$ where $$\tilde{\psi}(y)=\int_{\mathbb{R}} \psi(x,y)f_{X\mid X+Y}(x\mid y)\,\lambda(\mathrm dx)=\int_0^y 2x\frac{y-x}{y^2}\,\lambda(\mathrm dx)=\frac{1}{3}y.$$ Thus $$E[X\mid X+Y]=\tilde{\psi}(X+Y)=\frac{X+Y}{3},$$ which, fortunately, is the same result we get by using mike's method in the comment.