Tail integral formula for moments (source code)

= Tail integral formula for moments
{title2=$\mathbb E|X|^q=q\int_0^\infty t^{q-1}\mathbb P(|X|>t)dt$}

For $q>0$ and a real <random variable> $X$, the <tail integral formula for moments> is
$$
\mathbb E|X|^q=q\int_0^\infty t^{q-1}\mathbb P(|X|>t)\,dt,
$$
valid even if both sides are infinite. Pointwise, $|X|^q=\int_0^{|X|}qt^{q-1}\,dt$; <Tonelli theorem> interchanges this nonnegative <integral> with <expectation>. Replacing $>$ by $\geq$ does not change the <integral>, since their difference is confined to the at most countably many atoms of the distribution. For an <exponential random variable> of rate $\lambda$, the formula at $q=2$ gives $\mathbb EX^2=2\int_0^\infty te^{-\lambda t}dt=2/\lambda^2$.