Prove $\mathbb{E}[g(X)|X=x]=g(x)$

53 Views Asked by At

Let $X$ be a discrete random variable and let $g$ be a function from $\mathbb{R}$ to $\mathbb{R}$. If $x$ is a real number such that $\mathbb{P}(X=x)>0$, show formally that

$$\mathbb{E}(g(X)|X=x)=g(x).$$

Attempt:

$$\mathbb{E}[g(X)|X=x]=\sum_{g(x)\in\text{Im}(g(X))}g(x)\mathbb{P}(g(X)=g(x)|X=x)=g(x)\sum_{g(x)\in\text{Im}(g(X))}\mathbb{P}(g(X)=g(x)|X=x).$$

Now I feel like $(g(X)=g(x)|X=x)=(g(X)=g(x))$ so

$$g(x)\sum_{g(x)\in\text{Im}(g(X))}\mathbb{P}(g(X)=g(x))=g(x),$$

but I am not sure this is correct.