# Computing conditional expectation of independent uniform rv

Suppose $$X$$ and $$Y$$ are two independent uniform random variables on $$[0,1]$$. Compute

$$E[X^2 \mid X+Y = a ]$$

where $$a\in (0,2)$$.

## Try.

First, we can find density of $$Z=X^2$$. We have

$$P(X^2 \leq z ) = P( - \sqrt{z} \leq X \leq \sqrt{z}) = \int_{- \sqrt{z}}^{\sqrt{z}} dx =2 \sqrt{z}$$

Therefore,

$$f_Z(z) = \frac{1}{\sqrt{z}}.$$

Now, here is where the trouble starts since I always get confused when computing the conditional expectation. Do they mean that I need to compute

$$\int \int_{\sqrt{z}+y=a} z \frac{1}{\sqrt{z} } dy dz$$?

• @gd1035 That's wrong. Actually it should be $E([a-Y]^2 | X+Y=a)$ .. which of course is not easier than the original :-) – leonbloy Dec 16 '18 at 3:43

Find joint density function of $$U=X$$ and $$V=X+Y$$ via transformation rule. Then we have $$f_{U,V}(u,v) = 1_{\{0 We can compute conditional pdf $$f_{U|V}(u|v)$$ as follows. $$f_{U|V}(u|v)=\frac{f_{U,V}(u,v)}{f_V(v)} = \begin{cases}\frac{1}{v}1_{\{0What is left is to actually calculate $$E[U^2|V=v]$$ as follows. $$E[U^2|V=v] = \int u^2f_{U|V}(u|v)du = \frac{1}{v}\int_{\{0 for $$v\in (0,1)$$ and $$\frac{1}{2-v}\int_{\{0
• but, question, why do you condition on $V=v$? Isnt it a constant $a$? – Jimmy Sabater Dec 16 '18 at 18:59
• Oh, it's my mistake. Maybe it was for notational consistency. But it may not cause problem because one can read $v$ appearing in all the expressions as $a$. – Song Dec 16 '18 at 19:09