Proof of expectation value $E(g(X))= \int g(u)f(u) \,du$ Suppose we a have a real valued function $g:\mathbb{R} \rightarrow \mathbb{R}$. If $X$ is a continuous random variable with pdf $f$, then prove that:
$$E(g(X))= \int g(u)f(u) \,du$$
Where $E(g(X))$ is the expectation value of the random variable $g(X)$.
Our instructor proved the above for only a "special" case $g(X) \geq 0$ using Fubini's theorem which was pretty reasonable. But he mentioned that proving for any general $g(X)$ is involved and intricate, but I do not understand why he said so. Any explanations for the general case is appreciated.
 A: In fact, we have the following result (which probably is due to Doob):
Let $(\Omega,\mathcal{F},P)$ be a probability space. Let $X:\Omega\rightarrow\mathbb{R}$
be a random variable. Let $\mu:\mathcal{B}(\mathbb{R})\rightarrow[0,1]$
be the distribution associated with $X$, defined by $\mu(A)=P(X^{-1}(A))$.
Then for any Borel function $g:\mathbb{R}\rightarrow\mathbb{R}$,
if $g$ is $\mu$-integrable, then $E\left(g\circ X\right)=\int g(x)d\mu(x)$.
If $X$ admits a p.d.f. $f$, then $\mu$ is absolutely continuous
with respect to the Lebesgue measure. Moreover, $f$ is the Radon-Nikodym
derivative $f=\frac{d\mu}{dm}$, in the sense that for any Borel set
$A\subseteq\mathbb{R}$, $\mu(A)=\int_{A}f(x)dm(x)$, where $m$ is
the usual Lebesgue measure on $(\mathbb{R},\mathcal{B}(\mathbb{R}))$.
Then, the above can be written as $E\left(g\circ X\right)=\int g(x)f(x)dx$.
Proof: Firstly, we show that $E\left(g\circ X\right)=\int g(x)d\mu(x)$
holds if $g$ is the indicator function of a Borel set. Suppose that
$g=1_{A}$ for some $A\in\mathcal{B}(\mathbb{R}).$ Note that for
any $\omega\in\Omega$, $g(X(\omega))=1$ iff $X(\omega)\in A$ iff
$\omega\in X^{-1}(A)$. That is, $g\circ X=1_{X^{-1}(A)}$. It follows
that $E\left(g\circ X\right)=P\left(X^{-1}(A)\right)=\mu(A)=\int1_{A}(x)d\mu(x)=\int g(x)d\mu(x)$.
By linearity, the identity continues to hold for all simple function
$g$. If $g:\mathbb{R}\rightarrow[0,\infty]$ is a non-negative Borel
function, we can choose a sequence ($g_{n})$ of simple Borel functions
such that $0\leq g_{1}\leq g_{2}\leq\ldots\leq g$ and $g_{n}(x)\rightarrow g(x)$
for each $x$. Note that $E\left(g_{n}\circ X\right)=\int g_{n}(x)d\mu(x)$.
Letting $n\rightarrow\infty$, by Monotone Convergence Theorem, we
have that $E\left(g\circ X\right)=\int g(x)d\mu(x)$. (Note that $+\infty$
is allowed). Finally, if $g:\mathbb{R}\rightarrow\mathbb{R}$ is a
Borel function such that $g$ is $\mu$-integrable, we write $g=g^{+}-g^{-}$,
where $g^{+}=\max(g,0)$ and $g^{-}=\max(-g,0)$ are non-negative
Borel functions. Observe that $E\left(g^{+}\circ X\right)=\int g^{+}(x)d\mu(x)$,
$E\left(g^{-}\circ X\right)=\int g^{-}(x)d\mu(x)$ and both quantities
are finite. Since $g\circ X=g^{+}\circ X-g^{-}\circ X$, $g\circ X$
is integrable and $E\left(g\circ X\right)=E\left(g^{+}\circ X\right)-E\left(g^{-}\circ X\right)=\int g^{+}(x)d\mu(x)-\int g^{-}(x)d\mu(x)=\int g(x)d\mu(x)$.
