# Why does this integral rearrangement hold?

A solution to one of my practice problems involves this:

$\int^\infty_0 \{\int^x_0 dy\}f(x)dx = \int^\infty_0 \{\int^\infty_y f(x) dx\}dy$

Where f() is a PDF function of a continuous random variable(if that makes any difference).

Why does this work? And what should I know in order to be able to apply this kind of step to problems in the future?

-

It's an application of Fubini's theorem and the observation that the domain of integration is $\{(x,y) \mid 0 \le y \le x < \infty\}$ which can be written in two ways. You can apply Fubini here as your function is non-negative and for seeing the two ways it sometimes helps mwe to write the bounded integral as in integral over a characteristic function as follows ($\chi_A(x) = 1$ if $x \in A$, $0$ else): \begin{align*} \int_0^\infty \int_0^x f(x)\,dy\,dx &= \int_0^\infty \int_0^\infty \chi_{[0,x]}(y)f(x)\, dy\,dx\\\ &= \int_0^\infty \int_0^\infty \chi_{[0,x]}(y)f(x)\,dx\,dy\\\ &= \int_0^\infty \int_0^\infty \chi_{[y,\infty)}(x)f(x)\,dx \,dy\\\ &= \int_0^\infty \int_y^\infty f(x)\,dx\,dy \end{align*}
So why does $\chi_{[0,x]}$ become $\chi_{[y,\infty]}$ ? – user1066113 May 15 '12 at 10:05
$\chi_{[0,x]}(y) = 1$ iff $y \in [0,x]$ iff $x \in [y,\infty)$ iff $\chi_{[y,\infty)}(x) = 1$. – martini May 15 '12 at 10:15