How to rewrite $\mathbb{E}(XY) = \sum_x \sum_y f(x\mid y) f(y) x y$ using $\mathbb{E}(XY) = \mathbb{E}(\mathbb{E}(XY\mid Z))$

269 Views Asked by At

So, an elementary property in probability theory is the tower property so that one can write $\mathbb{E}(X)=\mathbb{E}(\mathbb{E}(X\mid Y))$. I want to work out an expected value that is slightly more complicated, but not much more complicated. Say I have three random non-negative discrete variables, $X, Y, Z$ and I want to compute $\mathbb{E}(XY)$, but it is difficult to do this using $$\mathbb{E}(XY) = \sum_x \sum_y f(x\mid y) f(y) x y \ \tag{1}$$ and instead I want to also condition on $Z$, i.e. initially we have $$\mathbb{E}(XY) = \mathbb{E}(\mathbb{E}(XY\mid Z)) \ \tag{2}.$$ My question is how to rewrite the sum in (1) using (2)? I have $$\mathbb{E}(XY) = \sum_z \sum_x \sum_y f(x\mid y, z) f(y\mid z) f(z) x y z$$ Is this right?