# Nested Expected Value that Aren't Independent

I'd like to mention this is a homework problem and I am interested in the process of finding the answer, not the answer itself.

The problem is, we have:
A random variable X uniformly distributed on the interval [L-S, L+S]
A random variable Y uniformly distributed on the interval [X-S, X+S]
Where 0 < S < L

We are looking to find E[XY], My understanding is that if X and Y had been independent we could have used the property:
E[XY] = E[X]E[Y] since cov[X,Y] would have been equal to zero. (And if I am not mistaken, Y is dependent on X in this case).

Is it mathematically correct to substitute X's min and max possible values into the interval [X-S, X+S] as to say that Y is uniformly distributed on that interval: [L-2S, L+2S]?
Then, that E[XY] = L^2?

If not, how would I need to look at the problem? Is it possible to calculate cov(X,Y) directly?

Thanks for any help :)

-
"Is it mathematically correct $\ldots$ to say that $Y$ is uniformly distributed on $[L-2S,L+2S]$?" No. Your problem statement is missing the word conditionally: Given the value of $X$, the conditional distribution of $Y$ is a uniform distribution on $[X-S, X+S]$ It is not true that $Y$ is (unconditionally) uniformly distributed on $[L-2S, L+2S]$. As far the approach is concerned, see Tunococ's answer which uses the property that the conditional mean of $Y$ given $X$ is just $X$ itself to get $E[Y\mid X] = X$ and so $E[XE[Y\mid X]] = E[X\cdot X] = E[X^2]$. – Dilip Sarwate Sep 4 '12 at 20:42
Thank you very much, it is clear now. – Pi_ Sep 4 '12 at 20:55

$E[XY] = E[E[XY|X]] = E[X E[Y|X] ] = E[X X] = E[X^2]$. Now you need to compute $E[X^2]$.

-
Thanks for your answer, what property are you using here: E[XE[Y|X]] = E[XX]? – Pi_ Sep 4 '12 at 20:40
It is the law of total expectation, according to Wikipedia. It is actually pretty intuitive. Just think about when you are given $X$, what would $E[XY]$ be? Then you take the average over all $X$. – Tunococ Sep 4 '12 at 21:21

it is because Y is uniforn on [X-S, X+S] given X that E[Y|X]=X.

Since X is uniformly distributed on [L-S, L+S] to evaluate E[X$^2$] you integrate x$^2$/(2S) dx over the interval [L-S, L+S] to get your answer.

-
I think you meant to integrate over x^2/2S – Pi_ Sep 6 '12 at 21:04
Thanks @Pi_ I will correct it. 2S is right. It is suppose to be the length of the interval that the uniform density lives on. – Michael Chernick Sep 6 '12 at 22:35