# Conditional expectation of a function of two random variables given one of them

Given two random variables $$X_1,X_2$$ how does one prove $$E[g_1(X_1)g_2(X_2)|X_2] = E[g_1(X_1)|X_2]g_2(X_2)$$

I can see the intuition that since $$X_2$$ is given, the piece depending on it should come out of the expectation but I'm not being able to write it down mathematically. An answer involving pdfs and cdfs would be more appreciated than an answer from a measure theoretic point of view.

• You do something like this? You first find the expectation given $X_2=x$?$$E[g_1(X_1)g_2(X_2)\mid X_2=x]$$ That is then $$E[g_1(X_1)g_2(x)\mid X_2=x]=g_2(x)E[g_1(X_1)\mid X_2=x]$$ What you want can be found by substituting $x=X_2$ – Shashi Oct 14 '18 at 10:42
• How is $E[g_1(X_1)g_2(X_2)∣X_2=x] = E[g_1(X_1)g_2(x)∣X_2=x]$ using the definition $E[Y|X=x] = \int_{\mathbb{R}}^{} y f_{Y|X}(y|x) dy$? I'm unable to see this, and I think it's trivial to see this, but I'm missing some small step somewhere. – Anant Joshi Oct 14 '18 at 10:51
• I guess that you then need the conditional density of $g_1(X_1)g_2(X_2)$ given $X_2=x$, so the first step is to find that. – Shashi Oct 14 '18 at 10:57
• This will follow from the 'law of unconscious statistician' right? – Anant Joshi Oct 17 '18 at 7:40
• if you have the conditional distribution of $(X_1,X_2)$ given $X_2=x$, then yeah you can apply that – Shashi Oct 17 '18 at 11:23