# Rigorous proof that $\int_{\Omega}X\;dP=\int_{-\infty}^{\infty}xf(x)\;dx$

I'm trying to prove rigorously that $\int_{\Omega}X\;dP=\int_{-\infty}^{\infty}xf(x)\;dx$. Where $f$ is the pdf of the random variable $X$.

I can't find a proof on the wikipedia article, or if it's there then it's disguised enough that I can't recognize it. Basically what I've got is a sort of semi-rigorous (and probably incorrect) proof of the equality, but maybe somebody could help me flesh out the details.

Proof:

Beginning from the definition that $E[X]:=\int_{\Omega}X\;dP$.

Given a random variable $X:\Omega\rightarrow\mathbb{R}$, we have the induced measure on $(\mathbb{R}, \mathscr{B}(\mathbb{R}))$ given by $P(\{X\in A\})$. Then by the Radon-Nikodym theorem there exists a measurable function $f:\mathbb{R}\rightarrow [0,\infty)$ such that $$P(\{X\in A\}) = \int_Afd\mu,$$

where $d\mu$ is the Lebesgue measure. From here it gets a bit hand-wavy. Basically since this measure was induced by the random variable $X$, then on $\mathbb{R}$ this random variable is simply given by the identity function $g(x)=x$. And thus by definition we write the expected value of $g$ with respect to our Radon-Nikodym produced measure in the form $$\int_{-\infty}^{\infty}x\;d\Big(\int_Afd\mu\Big).$$

Now by the Fundamental Theorem of Calculus, this becomes $$\int_{-\infty}^{\infty}xf(x)\;dx.$$

I'll try to provide a little more general result. Let $(\Omega,\ \mathcal{E},\ P)$ be a probability space and let $X\colon \Omega\longrightarrow \mathbb{R}$ be a random variable, i.e for each $I\in \mathcal{B}$, $X^{-1}(I)\in\mathcal{E}$, where $\mathcal{B}$ is the usual Borel $\sigma-$algebra on $\mathbb{R}$. Let us write $\mu:=\mu_{X}$ for the probability distribution of $X$, i.e for the measure defined on $\mathcal{B}$ by $\mu(I):=P(X^{-1}(I))$ for each $I\in\mathcal{B}$. Then the following holds.

Theorem (Abstract-Concrete Formula): Let $\phi\colon\mathbb{R}\longrightarrow \mathbb{R}$ be a borelian function, i.e $\phi^{-1}(I)\in\mathcal{B}$ for every $I\in\mathcal{B}$, and write $\phi(X)$ for the composition $\phi\circ X$. Suppose at least one between the integrals $$\int_{\Omega} \phi(X)\ dP\quad\text{and}\quad \int_{\mathbb{R}}\phi (x) \ d\mu$$ exists (resp. exists and it is finite). Then also the other one exists (resp. exists and it is finite) and it holds that $$\int_{\Omega} \phi(X)\ dP=\int_{\mathbb{R}}\phi (x) \ d\mu\ .$$ In particular, $\phi(X)$ is summable with respect to $P$ if and only if $\phi$ is summable with respect to $\mu$.

(When I say that a Lebesgue integral for a measurable function exists, I allow that it is not finite). The proof of this fact is quite straightforward but it requires some measure theory results such as the approximation theorem with simple functions and the Lebesgue's monotone convergence theorem. Indeed, suppose first that $\phi$ is a (finitely) simple and positive function. Then also $\phi(X)$ is simple (and positive) and (therefore) both mentioned integrals always exist. Writing $\phi=\sum_{i=1}^{n} c_{i}1_{E_{i}}$, where $n=\vert \phi(\mathbb{R})\vert$, $\phi (\mathbb{R})=\{c_{1},\cdots,c_{n}\}$ and $E_{i}:=\phi^{-1}(\{c_{i}\})$, we get $$\int_{\mathbb{R}}\phi (x) \ d\mu=\sum_{i=1}^{n}c_{i}\mu (E_{i})=\sum_{i} c_{i}P(X^{-1}(E_{i}))=\sum_{i} c_{i}P(X^{-1}(\phi^{-1}(\{c_{i}\})))=\int_{\Omega} \phi(X)\ dP.$$ Assume now $\phi$ is a non-negative borelian function. Then there exists a non-decreasing sequence $(\phi_{n})_{n\in \mathbb{N}}$ of simple, positive functions such that $\lim\limits_{n\to \infty}\phi_{n}(x)=\phi (x)$ for every $x\in\mathbb{R}$. By monotone convergence theorem we get immediately that $$\int_{\mathbb{R}}\phi (x) \ d\mu=\int_{\mathbb{R}}(\lim_{n\to\infty}\phi_{n} (x)) \ d\mu =\lim_{n\to\infty} \int_{\mathbb{R}}\phi_{n} (x) \ d\mu=\lim_{n\to\infty} \int_{\Omega}\phi_{n} (X) \ dP=\int_{\Omega} \phi(X)\ dP.$$ Finally, suppose only $\phi\colon \mathbb{R}\longrightarrow\mathbb{R}$ is a borelian function, with no further restrictions. Then one can write $\phi=\phi^{+}-\phi^{-}$ (here for notation). Suppose $\int_{\mathbb{R}}\phi (x) \ d\mu$ exists: then at least one between $\int_{\mathbb{R}}\phi^{+} (x) \ d\mu$ and $\int_{\mathbb{R}}\phi^{-}(x) \ d\mu$ (say, the first one) must be finite and hence also $\int_{\Omega}(\phi(X))^{+} \ dP$ is finite, i.e $\int_{\Omega}\phi(X)\ dP$ exists. It is now clear that we can conclude with our thesis.

Corollary: In the previous situation, if $E[X]<+\infty$, then $$E[X]:=\int_{\Omega} X\ dP=\int_{\mathbb{R}} x\ d\mu.$$ In particular, if $\mu$ is absolutely continuous with respect to Lebesgue's Measure (on $\mathbb{R}$) and has density $f$, then we get $E[X]=\int_{\mathbb{R}} xf(x)\ dx$ (by (a straightforward consequence of) Radon-Nikodym theorem).

• It took me a while to fully digest this but I now see that it is exactly the answer I was looking for, thanks. – Thoth May 29 '13 at 19:54
• You're welcome! – Marco Vergura May 29 '13 at 21:20
• "Let $\phi: \mathbb R\to \mathbb R$ be a borelian function […]" Doesn't "borelian" mean Arctic? As in aurora borealis? – kahen May 30 '13 at 8:45
• @kahen Quite a deep comment, I'd say...However, one talks about borelian sets, so I don't see why you can't just use the same attribute for a function: borelian $\leftrightarrow$ Borel measurable. Besides this, I might also call it ice-cream function if I define what such a function is: in mathematics, at least, it is not so true that nomina nuda tenemus. – Marco Vergura May 30 '13 at 9:07
• @MarcoVergura in English mathematical parlance one speaks of "Borel functions" and "Borel sets". Names of mathematicians are very commonly used as adjectives. – kahen May 30 '13 at 9:15

If $X\geqslant0$ almost surely, Fubini yields $$E[X]=\int_\Omega X\mathrm dP=\int_\Omega\int_0^\infty\mathbf 1_{t\leqslant X}\mathrm dt\mathrm dP=\int_0^\infty\int_\Omega\mathbf 1_{t\leqslant X}\mathrm dP\mathrm dt=\int_0^\infty P[X\geqslant t]\mathrm dt.$$ Now, for each $t$, $$P[X\geqslant t]=\int_0^\infty \mathbf 1_{x\geqslant t}f(x)\mathrm dx,$$ hence Fubini again yields $$E[X]=\int_0^\infty\int_0^\infty \mathbf 1_{x\geqslant t}f(x)\mathrm dx\mathrm dt=\int_0^\infty\int_0^\infty \mathbf 1_{x\geqslant t}\mathrm dtf(x)\mathrm dx=\int_0^\infty xf(x)\mathrm dx.$$ If $X$ is real valued with $P[X\gt0]\cdot P[X\lt0]\ne0$, use the identity $E[X]=aE[Y]-bE[Z]$ where $a=P[X\gt0]$, $b=P[X\lt0]$, $Y$ has the distribution of $X$ conditioned on $X\gt0$ and $Z$ has the distribution of $-X$ conditioned on $X\lt0$, that is, $a=1-F(0)$, $b=F(0)$, $$f_Y(y)=\frac{f(y)}{a}\mathbf 1_{y\gt0},\qquad f_Z(z)=\frac{f(-z)}{b}\mathbf 1_{z\gt0}.$$ This yields $$E[X]=a\int_0^\infty y\frac{f(y)}{a}\mathrm dy-b\int_0^\infty z\frac{f(-z)}{b}\mathrm dz=\int_{-\infty}^{+\infty}xf(x)\mathrm dx.$$

• could you explain what $\int_0^{\infty}1_{t\leq X}dt$ means? – Thoth May 26 '13 at 7:30
• The random variable $U=\mathbf 1_{t\leqslant X}$ is defined by $U(\omega)=1$ if $t\leqslant X(\omega)$ and $U(\omega)=0$ otherwise. – Did May 26 '13 at 7:33
• but what does it mean when you're integrating with respect to $t$? I can't figure out how that equals $X$ – Thoth May 26 '13 at 7:36
• For every $s\geqslant0$, $\int\limits_0^\infty\mathbf 1_{t\leqslant s}\mathrm dt=\int\limits_0^s\mathrm dt=s$. This applies to $s$ a real number and, pointwisely, to $s$ random. – Did May 26 '13 at 7:41
• oh ok I see, thanks – Thoth May 26 '13 at 7:43

For non-negative $$X$$, argue as in @Did's proof the well-known result $$E[X]=\int_0^\infty P[X\ge t]\,dt$$. For general integrable $$X$$ we have by definition $$E[X]=E[X^+]-E[X^-]$$. Since $$X^+$$ is non-negative, its expectation equals \begin{align} \int_0^\infty P[X^+\ge t]\,dt&=\int_0^\infty P[X\ge t]\,dt\\ &=\int_{t=0}^\infty\int_{x=0}^\infty I[x\ge t]f(x)\,dx\,dt\stackrel{\rm Fubini}=\int_{x=0}^\infty\underbrace{\int_{t=0}^\infty I[t\le x]dt}_x\, f(x)dx \end{align} and similarly the expectation of $$X^-$$ equals \begin{align} \int_0^\infty P[X^-\ge t]\,dt&=\int_0^\infty P[X\le -t]\,dt\\ &=\int_{t=0}^\infty\int_{x=-\infty}^0 I[x\le -t]f(x)\,dx\,dt \stackrel{\rm Fubini}=\int_{x=-\infty}^0\underbrace{\int_{t=0}^\infty I[t\le -x]dt}_{-x}\, f(x)dx. \end{align} Adding these together gives $$E[X]=\int_{-\infty}^0 xf(x)dx +\int_0^\infty xf(x)dx$$.