# Thread: Find E[X] and E[E[X|Y]]

1. ## Find E[X] and E[E[X|Y]]

Let X and Y be random variables with $p(x,y)=e^ {-y}$ for $0

Find $E[X]$ and $E[E[X|Y]]$

My solution:

a) First of all, $p(x) = e^{-x}$, so I have $E[X] = \int ^ y _0 xe^{-x}dx = -ye^{-y}-e^{-y}+1$

b) Here, $E[X|Y] = \frac {Y}{2}$ and $p(y)=ye^{-y}$, so I have $E[E[X|Y]] = \int E[X|Y=y]p(y)dy = \int ^ \infty _x \frac {y}{2}(ye^{-y})dy= \frac {1}{2} e^{-x}(x^2+2x+2)$

But according to the law of total expectation, they should be the same thing, so what am I doing wrong? Thank you!

2. ## Re: Find E[X] and E[E[X|Y]]

part of this was asked in another question here

(a) Yes, $f_X(x)=e^{-x}$
BUT that is the marginal, hence the range is x>0
you no longer want x<y.
Plus the E(X) is a constant, which cannot have Y's in it.
E(X)=1, this is an exponential

(b) Yes, $E(X|Y)=y/2$

and $f_Y(y)=ye^{-y}$, y>0 a Gamma RV

So $E_Y(E(X|Y)) =\int_0^{\infty}(y/2)ye^{-y}dy=(1/2)\int_0^{\infty}y^2e^{-y}dy=(1/2)\Gamma(3)=1.$