$\int_X g \, d\mu =\int_0^\infty\mu(x:g(x)>t) \, dt$ I've been stuck on this prelim problem for a while. I'm not sure how to start. I tried playing around with simple functions, but I can't relate $\psi(t)$ to $g$.

Let $g:X\to[0,\infty)$ be a measurable function and $\psi(t)=\mu\{x
\in X : g(x) > t\})$. Prove that
  $$\int_X\!g\,\mathrm{d}\mu=\int_0^\infty\!\psi(t)\,\mathrm{d}t.$$

 A: First since $\psi(t)$ is monotone, thus it is measurable.
Assuming $\mu$ is $\sigma-$finite, we can use Fubini theorem,
$$\int_0^\infty \mu(\{g(x) > t\}) \, dt = \int_0^\infty \int_X \chi_{\{g(x) > t\}} \, d\mu \, dt= \int_X\int_0^\infty  \chi_{\{g(x) > t\}} \, dt \, d\mu= \\\int_X\int_0^{g(x)}  1  \, dt \, d\mu = \int_X g(x) \, d\mu$$
A: Hint: do it for step functions and then use the definition of Lebesgue integral to do it for non-negative functions.
A: Hint: Write $\phi(t) = \int I\{g(x) > t\} \; d\mu(x)$ and use Fubini's theorem.
A: HINT
Let's talk about simple functions only and assume that $\mu(X)<\infty$. So, let 
$$g(x)=\sum_1^n x_11_{A_i}$$  
where $1_{A_i}$ is the indicator function of the set $A_i$ over which $g$ takes the value $x_i$. Here $\cup_{i=1}^nA_i=X$ and these sets are pairwise disjoint. Without restricting generality, assume that $0<x_1<x_2<x_3<\cdots <x_{n-1}<x_n$.
First, nail down that
$$\int_Xg \ d\mu=\sum_{i=0}^n x_i \mu(A_i).$$
Then observe that 
$$\Psi(t)=
\begin{cases}
\mu(X)=\sum_{i=1}^n\mu(A_i),& \text{ if } t < x_1\\
\sum_{i=2}^n \mu(A_i),& \text{ if } x_1\le t< x_1\\
\sum_{i=3}^n \mu(A_i),& \text{ if } x_2\le t< x_3\\
\vdots \\
\sum_{i=n-1}^n \mu(A_i),& \text{ if } x_{n-2}\le t < x_{n-1}\\
\mu(A_n),& \text{ if } x_{n-1} \le t < x_{n}\\
0,& \text{ if } x_{n} \le t.
\end{cases}$$
Now,
$$\int_0^{\infty} \Psi(t) \ dt=$$
$$x_1\sum_{i=1}^n\mu(A_i)+(x_2-x_1)\sum_{i=2}^n\mu(A_i)+(x_3-x_2)\sum_{i=3}^n\mu(A_i)+\cdots +\mu(A_n)=$$
$$=x_1\mu(A_1)+x_2\mu(A_2)+\cdots +x_n\mu(A_n).$$
A: This is just a reformulation of Xiao's answer. Using Iverson's brackets we have 
$$\int_X g\, d\mu = \int_X\int_\mathbb{R} [0<\lambda<g(x)]\,d\lambda\,d\mu=\int_\mathbb{R}\int_X[0<\lambda<g(x)]\, d\mu\, d\lambda=\int_\mathbb{R}\mu\left\{0<\lambda <g(x)\right\}\,d\lambda.$$
