# Expectation of a continuous random variable explained in terms of the CDF

Problem:

Let $F_X(x)$ be the CDF of a continuous random variable $X$. Show that:

$$E[X]= \int_0^\infty(1-F_X(x)) \, dx -\int_{-\infty}^0F_X(x) \, dx.$$

Attempt:

A comprehensible explanation of the intuition regarding the expectation $E[X]$ and CDF for a non-negative random is found here: Intuition behind using complementary CDF to compute expectation for nonnegative random variables.

However, I am still at a loss about how to show the general case when $-\infty < x < \infty$.

I am again solving this as an exercise in my probability course and any help is greatly appreciated!

• This is the integrated (with respect to $P$) version of the pointwise identity $$X= \int_0^\infty\mathbf 1_{X>x} \, dx -\int_{-\infty}^0\mathbf 1_{X<x} \, dx$$
– Did
Sep 11 '16 at 20:05
• This comment is to link this post as one of the (abstract) duplicates to the current choice of mother post. Nov 13 '18 at 12:33
• math.stackexchange.com/a/2137144/321264 Sep 27 '20 at 7:44

You can also see it by interchanging the order of integrals. We have

\begin{eqnarray*} \int_{0}^{\infty}(1-F_{X}(x))dx=\int_{0}^{\infty}P(X>x)dx & = & \int_{0}^{\infty}\int_{x}^{\infty}dF_{X}(t)dx\\ & = & \int_{0}^{\infty}\int_{0}^{t}dF_{X}(t)dx\\ & = & \int_{0}^{\infty}t\;dF_{X}(t) \end{eqnarray*} and, \begin{eqnarray*} \int_{-\infty}^{0}F_{X}(x)dx=\int_{-\infty}^{0}P(X\leq x)dx & = & \int_{-\infty}^{0}\int_{-\infty}^{x}dF_{X}(t)dx\\ & = & \int_{-\infty}^{0}\int_{t}^{0}dF_{X}(t)dx\\ & = & \int_{-\infty}^{0}-t\;dF_{X}(t) \end{eqnarray*} Since, $$E[X]=\int_{-\infty}^{0}t\;dF_{X}(t)+\int_{0}^{\infty}t\;dF_{X}(t)$$ the result follows.

• The density $f_X$ may not exist and is not needed to solve this.
– Did
Sep 11 '16 at 19:53
• But the question assumes that $X$ is a continuous random variable and hence the density does exist. Sep 11 '16 at 19:56
• No. Continuous random variables may have no PDF.
– Did
Sep 11 '16 at 19:58
• Right, sorry. The same approach works with Stieltjes integrals though I believe. Sep 11 '16 at 20:03

By integrating by parts $$\int_0^\infty(1-F_X(x))dx -\int_{-\infty}^0F_X(x)dx= [x(1-F_X(x))]_0^{+\infty}-\int_0^{+\infty} xd(1-F_X(x)) \\ -[xF_X(x)]_{-\infty}^0+\int_{-\infty}^0xdF_X(x) =0+\int_0^{+\infty} xdF_X(x)-0+\int_{-\infty}^0 xdF_X\\=\int_{-\infty}^{+\infty} xdF_X(x)=E[X].$$

P.S. Note that by Markov's inequality, if $E[X]$ is finite then $F_X(x)=o(1/x)$ for $x\to-\infty$ and $1-F_X(x)=o(1/x)$ for $x\to+\infty$.

• The density $f_X$ may not exist and is not needed to solve this.
– Did
Sep 11 '16 at 19:53
• @Did Is it better now? Sep 11 '16 at 20:05
• Yes, modulo some $dF_X$ which should read $dF_X(x)$.
– Did
Sep 11 '16 at 20:07
• @RobertZ But markov inequality can be used only for non-negative random variable. Can you please elaborate on your last statement. Thanks Jan 20 '17 at 11:46

As far as I understand you can take like this.

$$E(X) = \int_{-\infty}^{\infty}xdF_{X}(x) = \int_{-\infty}^{0}xdF_{X}(x)+ (-\int_{0}^{\infty}xd(1-F_{X}(x))$$

Using integration by part (and having $F(x)$ is always faster than $x$ at the infinities(otherwise the expectation would not exist.) We will have the result.