If assume X, Y are discrete random variables and develop the left hand side get that $\begin{align} E(E(X|Y)f(Y))&=\sum_y E(E(X|Y)f(Y))P(Y=y)\\ &=\sum_y \sum_x xP(X=x|Y=y)f(Y=y)P(Y=y)\\ &=\sum_y \sum_x x\frac{P(X=x,Y=y)}{P(Y=y)}f(Y=y)P(Y=y)\\ &=\sum_y \sum_x xP(X=x,Y=y)f(Y=y)\\ &=\sum_x x\sum_y P(X=x,Y=y)f(Y=y)\\ \end{align}$

I don't know how to remove the f(y). i tried to develop that to continuos random variables but i have the same problem.

  • $\begingroup$ It is easy to prove that $E[X]=E[E[X|Y]]$ for discrete (and continuous) random variables. I'd say: $E[Xf(Y)]=E[E[Xf(Y)|Y]]=E[f(Y)E[X|Y]]$ where you can pull out $f(Y)$ because you are conditioning over a value of $Y$, so $f(Y)$ becomes a constant. Not sure tho... $\endgroup$
    – Usmur
    Commented May 21, 2022 at 18:36
  • $\begingroup$ @Usmur That is true. $\endgroup$
    – Mason
    Commented May 21, 2022 at 19:05
  • $\begingroup$ @Mason Thank you for checking it, gonna write an answer for that $\endgroup$
    – Usmur
    Commented May 21, 2022 at 19:10
  • $\begingroup$ You should write $f(y)$ instead of $f(Y=y)$. $\endgroup$
    – user140541
    Commented May 21, 2022 at 19:12

1 Answer 1


Let $X, Y$ random variables with distribution $f_X$, $f_Y$ (and $f_{X|Y}$ distribution of $X|Y$), then $E[X]=E[E[X|Y]]$.


$\begin{align}E[E[X|Y]] &= \int E[X|Y]f_Y(y)dy \\ &=\int \left[\int xf_{X|Y}(x,y)dx \right]f_Y(y)dy\\ &=\int \int xf_{X|Y}(x,y)f_Y(y) dxdy\\ &=\int\int x f_{X,Y}(x,y)dydx \\ &=\int x\left[\int f_{X,Y}(x,y)dy \right]dx \\ &=\int xf_X(x)dx\\ &=E[X] \end{align}$

From this we can write:

$E[Xf(Y)]=E[E[Xf(Y)|Y]]=E[f(Y)E[X|Y]]$ where you can take $f(Y)$ out because it is in the expected value conditioned over a value of $Y$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .