[Math] Expectation of non-negative random variable

expected valueintegrationprobabilityproof-verification

Let $X$ be a non-negative random variable. In a proof for $E[X]=\int_0^\infty P(X>t)dt$ from the answer of this question, we use Fubini for the middle quality. Why do we need $X$ to be non-negative? We basically have a double integral over a function $f(X,t)$ which is $1$ if $X>t$ and else 0. So this function is non-negative for any $X$ not just for non-negative random variables $X$, thus we could use Fubini regardless. Where is the flaw in my reasoning?

Best Answer

If $x \ge 0$, we can write $x = \int_0^\infty 1_{(t,\infty)}(x) dt$.

Then $E X = \int X d p = \int \int_0^\infty 1_{(t,\infty)}(X) dt d p = \int_0^\infty \int 1_{(t,\infty)}(X) dp dt = \int_0^\infty p \{ \omega|X(\omega)>t\} dt$.