# Apparent contradiction between expectation of the product of random variables and law of total expectation

Suppose we have two random variables $$X, Y$$. Then, in general, if they are dependent $$E[XY] \ne E[X]E[Y]$$

However, according to the law of total expectation, $$E[XY] = E_Y[E_X[XY|Y]] = E_Y[YE[X]]=E[Y]E[X].$$ Furthermore, this law doesn't stipulate that $$X$$ and $$Y$$ are independent.

How can we reconcile this?

• Ah that makes sense, if you make it an answer I can accept it Mar 8, 2021 at 18:19

The law of total expectation states that $$\mathbb E_X[X]=\mathbb E_Y[\mathbb E_{X|Y}[X|Y]]$$ Introducing $$Y$$ leads to $$\mathbb E_{(X,Y)}[YX]=\mathbb E_Y[\mathbb E_{X|Y}[XY|Y]] = \mathbb E_Y[Y\mathbb E_{X|Y}[X|Y]]$$ which differs from $$\mathbb E_Y[Y]\mathbb E_{X}[X]$$ when $$\mathbb E_{X|Y}[X|Y]$$ depends on $$Y$$.
• Why is the first expectation $\mathbb{E}_X[YX]$ only over $X$?
• @Kuku: a typo, it is. And there was another one, with the $XY$ in the subscript rather than the integrand. Thank you. Jun 9, 2023 at 14:58
• Thank you for correcting. I am confused though still, shouldn't the second term have $XY|Y$ as subscript instead of $X|Y$?