# Solving some Integrals using Indicators and Fubini's Theorem

My students sometimes (often?) find it hard to see why, for example, for a positive continuous rvs

\begin{align*} \E X &= \int_0^{\infty} G(x) \d x, \\ \E{X^2} &= 2 \int_{0}^\infty x G(x) \d x. \end{align*}

Here I show how to do this. We start with a discrete positive rv.

For a nonnegative discrete random variable $X$, use an indicator function to prove that

\begin{align*} \E X = \sum_{k=0}^\infty G(k), \end{align*}

where $G(k) = \P{X > k}$.

Solution \begin{align*} \sum_{k=0}^\infty G(k) &= \sum_{k=0}^\infty \P{X > k} = \sum_{k=0}^\infty \sum_{m=k+1}^\infty \P{X=m} \\ & = \sum_{k=0}^\infty \sum_{m=0}^\infty \1{m > k} \P{X=m} = \sum_{m=0}^\infty \sum_{k=0}^\infty \1{m > k} \P{X=m} \\ &= \sum_{m=0}^\infty m\P{X=m} = \E X. \end{align*}

For a nonnegative discrete $X$, use an indicator function to prove that

\begin{align*} \sum_{i=0}^\infty i G(i) = \frac{\E{X^2}}2 - \frac{\E{X}}2. \end{align*}
Solution \begin{align*} \sum_{i=0}^\infty i G(i) &= \sum_{i=0}^\infty i \sum_{n=i+1}^\infty \P{X=n} = \sum_{n=0}^\infty \P{X=n} \sum_{i=0}^\infty i \1{n\geq i+1} \\ &= \sum_{n=0}^\infty \P{X=n} \sum_{i=0}^{n-1}i = \sum_{n=0}^\infty \P{X=n} \frac{(n-1)n}{2} \\ &= \sum_{n=0}^\infty \frac{n^2}{2} \P{X=n} - \frac{\E X}{2} = \frac{\E{X^2}}{2} - \frac{\E X}{2}. \end{align*}

For general non-negative $X$, use an indicator function to prove that

\begin{align*} \E X = \int_0^\infty x \d F(x) = \int_0^\infty G(y) \d y, \end{align*}

where $G(x) = 1 - F(x)$.

Solution \begin{align*} \E{X} &= \int_0^\infty x \d F(x) = \int_0^\infty \int_0^x \d y \d F(x) \\ & = \int_0^\infty \int_0^\infty \1{y\leq x} \d y \d F(x) = \int_0^\infty \int_0^\infty \1{y\leq x} \d F(x) \d y\\ & = \int_0^\infty \int_y^\infty\d F(x) \d y = \int_0^\infty G(y) \d y. \end{align*}

Use an indicator function to prove that for a general non-negative random variable $X$

\begin{align*} \E{X^2} = 2 \int_0^\infty y G(y) \d y, \end{align*}

where $G(x) = 1 - F(x)$.

Solution \begin{align*} \int_0^\infty y G(y) \d y &= \int_0^\infty y \int_y^\infty f(x)\, \d x \d y = \int_0^\infty y \int_0^\infty \1{y\leq x}f(x)\, \d x \d y\\ &= \int_0^\infty f(x) \int_0^\infty y \1{y \leq x}\, \d y \d x = \int_0^\infty f(x) \int_0^x y\, \d y \d x\\ &= \int_0^\infty f(x) \frac{x^2}2 \d x =\frac{\E{X^2}}2. \end{align*}

Use integration by parts to see that $\E{X^2} = 2 \int_0^\infty y G(y) \d y$.

Hint

In $\int_0^\infty y G(y) \d y$ integrate first the $y$ to $y^2/2$.

Solution \begin{equation*} \int_0^\infty y G(y) \d y = \frac{y^2}2 G(y) \bigg|_0^\infty - \int_0^\infty \frac{y^2}2 g(y)\d y = \int_0^\infty \frac{y^2}2 f(y)\d y = \frac{\E{X^2}}2, \end{equation*}

since $g(y) = G'(y) = - F'(y) = - f(y)$. Note that we used $\frac{y^2}2 G(y) \bigg|_0^\infty = 0 - 0 = 0$, which follows from our assumption that $\E{X^2}$ exists, implying that $\lim_{y \to \infty} y^2G(y) = 0$.

Use substitution to see that $\E{X^2} = 2\int_0^\infty y G(y) \d y$.

Hint

Substitute $y = \sqrt x \implies \d y = \d x/ 2 \sqrt x \implies \d x = 2 y \d y$.

Solution \begin{align*} \int_{0}^{\infty} y^2 \d F(y) &=\int_{0}^{\infty} \int_{0}^{\infty}\1{x\leq y^2} \d x \d F(y) = \int_{0}^{\infty} G(\sqrt x) \d x \\ &= 2\int_{0}^{\infty} y G(y) \d y, \end{align*}