Let $X$ a r.v. I have to prove that $$\mathbb E[g(X)]=\int_{\mathbb R}g(x)f_X(x)dx$$ if $X$ is continuous and $$\mathbb E[g(X)]=\sum_{k\in \mathcal D}g(k)f_X(k),$$ if $X$ is discrete.
Attempts
- If $X$ is continuous, then $F(x):=\mathbb P\{X\leq x\}$ is derivable and incresing. Therefore, $$\mathbb E[g(X)]\underset{(*)}{=}\int_{\mathbb R}g(X)d\mathbb P=\int_{\mathbb R}g(x)dF(x)=\int_{\mathbb R}g(x)\frac{dF(x)}{dx}dx\int_{\mathbb R}g(x)f_X(x)dx.$$
Q1) Does it work ? I'm not sure that I can do $(*)$. It looks intuitive, but I can't justify it properly.
- Let $\mathcal D$ countable such that $\mathbb P\{X\in \mathcal D\}=1$. Then $$\mathbb E[g(X)]=\sum_{\omega \in\Omega }X(\omega )\mathbb P\{g(X(\omega ))=k\}=\sum_{k\in \mathcal D}g(k)f_X(k),$$ where I proved the last equality brut force.
Q2) But is there a straightforward argument using measure theory ?
If the measure $\mathbb{P}$ induced by $X$ on $\mathbb{R}$ is absolutely continuous with respect to the Lebesgue measure $\lambda$ on $\mathbb{R}$ then then Radon-Nikodym theorem asserts that exists $f_X$ such that for every $E$ measurable: $$ \mathbb{P}(E) = \int _E f_X \mathrm{d}x $$ Since $X$ is continuous it induced a non negative measure on $\mathbb{R}$ that's absolutely continuous with respect to $\lambda$, so the Radon-Nikodym derivative exists and you use it on the equality $(*)$.