---
tag: 0Y6QNF1J49
kind: statement
role: proposition
name: Tail sum formula for expectation
aliases: [tail-sum-formula, layer-cake-formula-for-expectation]
msc: [60A05]
uses: [0DCT0QZVQ1, 0MXMS3AE13]
sources:
  - url: https://en.wikipedia.org/wiki/Expected_value
    locator: Tail-sum formula
---

## Statement

Let $X$ be a random variable with values in $[0, \infty)$. Then
$$E[X] = \int_0^\infty P(X > t) \, dt,$$
with both sides in $[0, \infty]$.
If $X$ takes values in $\{0, 1, 2, \dots\}$, then
$$E[X] = \sum_{n=1}^{\infty} P(X \ge n).$$

## Remarks

The proof writes $X = \int_0^\infty 1_{\{X > t\}} \, dt$ and exchanges expectation and integral by Tonelli's theorem.
In terms of the [[cumulative distribution function|0MXMS3AE13]] $F$, the first formula reads $E[X] = \int_0^\infty (1 - F(t)) \, dt$.
For $X \sim \operatorname{Exp}(\lambda)$, the formula gives $E[X] = \int_0^\infty e^{-\lambda t} \, dt = 1/\lambda$.

## Explanations

### L1 human

You can compute an average by adding the chances that $X$ passes each level.
For a count $X$, each $n \le X$ adds $1$ to $X$, and it does so with probability $P(X \ge n)$.
