Tail-sum formula (source code)

= Tail-sum formula
{title2=$\mathbb E[Y]=\int_0^\infty\mathbb P(Y>t)\,dt$}

The <tail-sum formula> expresses an <expected value> as the <area> under a <survival function>. For every nonnegative <random variable> $Y$,
$$
\boxed{\mathbb E[Y]=\int_0^\infty\mathbb P(Y>t)\,dt.}
$$
This <Lebesgue integral> and the <expected value> may both be $+\infty$; a <probability density function> is unnecessary. For a <random variable> $N$ taking values in the <nonnegative integers>, the corresponding <sum> is
$$
\boxed{\mathbb E[N]=\sum_{k=1}^\infty\mathbb P(N\geq k)=\sum_{k=0}^\infty\mathbb P(N>k).}
$$
The <events> $\{N>k\}$ and $\{N\geq k+1\}$ coincide because $N$ takes <integer> values. Thus the strict <sum> starts at zero, while the inclusive <sum> starts at one.<Random: Probability, Mathematical Statistics, Stochastic Processes by Kyle Siegrist>[Expected Value, §2 Additional Properties, Right Distribution Function: nonnegative tail integral and integer-valued tail sums]{ref}

For an original example, let the <probability mass function> of $N$ be
$$
\mathbb P(N=0)=\frac15,\qquad\mathbb P(N=1)=\frac3{10},\qquad\mathbb P(N=3)=\frac12.
$$
Its <expected value> computed directly is $0(1/5)+1(3/10)+3(1/2)=9/5=1.8$. The strict <tail probabilities> at thresholds $0,1,2,3$ are $4/5,1/2,1/2,0$: their <sum> is again $1.8$. There is no <probability mass> at two, yet the <event> $\{N>2\}$ still has <probability> $1/2$. The <survival function> has heights $4/5,1/2,1/2$ on the successive <intervals> $[0,1),[1,2),[2,3)$; each <interval> has length one, so its <integral> is the same <sum>.

\Image[/tail-sum-mass-and-survival.png]
{title=The same expected value from probability masses and survival columns}
{description=The exact constructed <probability mass function> assigns $1/5,3/10,1/2$ to $0,1,3$. The $3/10$ contribution appears in one survival column, while the $1/2$ contribution appears in three. Filled endpoints give the strict <survival function> at its jumps; open endpoints show the preceding height. The shaded <area> is $3/10+3(1/2)=1.8$.}

The indexing matters numerically. Starting the inclusive <sum> at zero adds $\mathbb P(N\geq0)=1$, giving $2.8$ for this example. Starting the strict <sum> at one omits $\mathbb P(N>0)=4/5$, giving $1$. For a general nonnegative <random variable>, replacing $>$ with $\geq$ inside the <integral> is harmless: the difference is $\mathbb P(Y=t)$, nonzero at only a <countable set> of thresholds. For each positive <integer> $m$, at most $m$ thresholds can have <probability mass> at least $1/m$; their <countable union> contains all thresholds with positive <probability mass> and has <Lebesgue measure> zero. This reasoning concerns an <integral>, not equality of the two <survival function> conventions at every <point>.

For a continuous original example, take the <uniform distribution> on the <interval> $[0,4]$. Its <survival function> is $S(t)=1-t/4$ for $0\leq t\leq4$ and zero for $t>4$. The <area> is a <triangle> of base four and height one:
$$
\mathbb E[Y]=\int_0^4\left(1-\frac t4\right)dt=2.
$$
Directly integrating against the <probability density function> gives the same <expected value>, $\int_0^4 y(1/4)\,dy=2$. The <integral> of the <probability density function> alone is one; it is the <survival function> whose <area> is the <expected value>.

\Image[/tail-sum-uniform-survival-area.png]
{title=A uniform density has total probability one and survival area two}
{description=Exact curves for the <uniform distribution> on $[0,4]$. The <probability density function> has <integral> one, while the <survival function> has <integral> two. Splitting the survival <area> at $t=2$ gives $1.5$ before the cap and $0.5$ beyond it, the <expected values> of $\min(Y,2)$ and the <positive part> $(Y-2)_+$, respectively.}

The proof counts layers of each outcome. For a realized value $y\geq0$, the <indicator function> $\mathbf1_{\{y>t\}}$ equals one over an <interval> of length $y$, so
$$
Y=\int_0^\infty\mathbf1_{\{Y>t\}}\,dt,\qquad
\mathbb E[Y]=\int_0^\infty\mathbb E[\mathbf1_{\{Y>t\}}]dt=\int_0^\infty\mathbb P(Y>t)dt.
$$
<Tonelli theorem> permits the interchange because the <indicator function> is nonnegative; no finite <expected value> is assumed. Similarly, an outcome $N=n$ contributes one <indicator random variable> for each of the $n$ <events> $\{N\geq k\}$ that occur:
$$
N=\sum_{k=1}^\infty\mathbf1_{\{N\geq k\}},\qquad
\mathbb E[N]=\sum_{k=1}^\infty\mathbb E[\mathbf1_{\{N\geq k\}}]=\sum_{k=1}^\infty\mathbb P(N\geq k).
$$
Again <Tonelli theorem> applies to the nonnegative <sum>, or equivalently the <monotone convergence theorem> applies to its <partial sums>. This exchanges counting layers within each outcome with averaging across outcomes. The existing <integer-valued hypothesis in the tail-sum formula> explains what changes when the values are not <integers>; the <tail integral formula for moments> weights the layers to obtain higher <moments>.

For an <integrable random variable> $X$ that can have either sign, apply the nonnegative formula separately to its <positive part> $X_+=\max(X,0)$ and <negative part> $X_-=\max(-X,0)$:
$$
\mathbb E[X]=\int_0^\infty\mathbb P(X>t)dt-\int_0^\infty\mathbb P(X<-t)dt.
$$
<Integrability> makes both <integrals> finite. More generally the difference defines an extended <expected value> when at least one is finite; if both are infinite, subtraction does not define an <expected value>.<Random: Probability, Mathematical Statistics, Stochastic Processes by Kyle Siegrist>[Expected Value, §2 Additional Properties, A General Definition: positive and negative parts and the condition on their expectations]{ref}

<Tail probabilities> are often easier to measure or bound than a whole <probability density function>. For a device's <survival time>, the <survival function> records the <probability> of still operating at each threshold; its <integral> gives the mean operating time. A finite observation window naturally gives the <expected value of a capped nonnegative random variable>. For a mathematical bound, $\mathbb P(Y>t)\leq e^{-t/2}$ for all $t\geq0$ implies $\mathbb E[Y]\leq\int_0^\infty e^{-t/2}dt=2$. The <tail-sum formula> turns control of a whole family of <events> into control of an average.