Q:

Compute expectation using tower property

Imagine I want to compute $E[f(X,Y)]$ where $f$ is a suitable function and $X,Y$ random variables.
If $X$ and $Y$ are correlated, let us say $X=g(Y)$ or even in my case $X_t$ and $Y_t$ are stochastic processes and $Y_t=g(X_{\cdot})$. My question is: am I allowed to do
$$E[f(X,Y)]= E[E[f(X,y)|y=Y]]?$$
in my case, now the law of $X$ is known and it is easy to compute $E[f(X,y)|y=Y]$ and then insert $y=Y$ and compute the rest.
The point is, I know the law of $X$ if $Y$ is fixed given, and I fully know the law of $Y$, but I am not 100% sure that this method is correct, I feel I don't use the correlation part. The fact that they are (or not) correlated, does it affect the method of computing it?
Thanks for the support!

A:

Yes, it is correct. It follows from the tower property that
$$\mathbb{E}(f(X,Y))=\mathbb{E}\big( \mathbb{E}(f(X,Y) \mid \mathcal{F}) \big)$$
for any $\sigma$-algebra $\mathcal{F}$. In particular, we can choose $\mathcal{F} := \sigma(Y)$ the $\sigma$-algebra generated by $Y$. Moreover, we know from the factorization lemma that there exists a function $h$ (depending on $f$) such that
$$\mathbb{E}(f(X,Y) \mid Y)  := \mathbb{E}(f(X,Y) \mid \sigma(Y)) = h(Y).$$
Usually, this is denoted by
$$h(y) = \mathbb{E}(f(X,Y) \mid Y=y).$$
Combining the equalities yields
$$\mathbb{E}(f(X,Y)) = \mathbb{E}\big( \mathbb{E}(f(X,Y) \mid Y=y) \big|_{y=Y} \big).$$

