Ok, according to some notes I have, the following is true for a random variable $X$ that can only take on positive values, i.e $P(X<0=0)$
$\int_0^{\infty}(1-F_X(x))dx=\int_0^{\infty}P(X>x)dx$
$=\int_0^{\infty}\int_x^{\infty}f_X(y)dydx$
$=\int_0^{\infty}\int_0^{y}dxf_X(y)dy$
$=\int_0^{\infty}yf_X(y)dy=E(X)$
I'm not seeing the steps here clearly. The first line is obvious and the second makes sense to me, as we are using the fact that the probability of a random variable being greater than a given value is just the density evaluated from that value to infinity.
Where I'm lost is why: $=\int_x^{\infty}f_X(y)dy=\int_0^{y}f_X(y)dy$
Also, doesn't the last line equal E(Y) and not E(X)?
How would we extend this to the discrete case, where the pmf is defined only for values of X in the non-negative integers?
Thank you
$$ \int_x^\infty f_X(y),dy = \int_0^y f_X(y),dy.$$
The order of integration is changed (allowed per Fubini's theorem), you have
$$\int_0^\infty \left(\int_x^\infty f_X(y),dy \right), dx = \int_0^\infty \left(\int_0^ydx \right),f_X(y) dy.$$
– Daniel Fischer Sep 07 '13 at 21:03