Expected value of a function, is this true? why?

46 Views Asked by At

I have learnt that: $E(g(X)Y|X)=g(X)E(Y|X)$, which basically means that $g(X)$ is just like a constant whenever I add a conditional expectation as $E(\cdot|X)$.

I am now experiencing this type of problem in a question I'm solving: $E(YE(Y|X=x)|X=x)$. And I really think I can write it as $E(Y|X=x)E(Y|X=x)$, because if $E(Y|X=x)=g(x)$, I can just take it outside like a constant, but I'm getting confused, since $g(x)$ is not a random variable, it's just a function of $x$, so couldn't I take it also even if it was $E(Yg(x))$?
I know that the expected value is a number, but if it's $E(Y|X=x)$, it's just a function of $x$, can I treat this function as a constant and take it outside the expected value?

Thanks in advance!

1

There are 1 best solutions below

0
On

You are correct to treat $\mathbb E(Y|X=x)$ as $g(x)$ as it is indeed a function of $x$. Now the expression becomes $\mathbb E(Yg(x)|X=x)=g(x)\mathbb E(Y|X=x)$, as $g(x)$ is a constant given that $X=x$, and can be moved outside the expected value.