# Expected Value Reformulation

I have the following problem:

Show that E[X] = $\int_0^\infty [1 - F_x(x)]dx$ where x is a continuous, non-negative random variable.

The solution is as follows:

$$\int_0^\infty [1 - F_x(x)]dx = \int_0^\infty P(X \gt x)dx \qquad(1)$$ $$= \int_0^\infty \int_x^\infty f_x(y)dydx \qquad(2)$$ $$= \int_0^\infty \int_0^y dx f_x(y)dy \qquad(3)$$

$$= \int_0^\infty yf_x(y)dy = E[X] \qquad(4)$$

I get the train of thought but I don't understand how the coefficients on the inner integral go from x to infinity in step 2 to 0 to y in step 3.

$y$ ranges from $x$ to $\infty$ as $x$ ranges from $0$ to $\infty$ $\equiv$ $x$ ranges from $0$ to $y$ as $y$ ranges from $0$ to $\infty$. Thus with the interchange of integrals the boundaries of integration changed. $$\int_{0}^{\infty}\left[\int_{x}^{\infty}f_x(y)dy\right]dx=\int_{0}^{\infty}\left[\int_{0}^{y}dx\right]f_{x}(y)dy$$