Stochastic domination and expected value Given $X$ is stochastically smaller than $Y$ (both random variables of course). In addition let $X,Y\geq0$ and $g$ a smooth function with g(0)=0. Why is
$$
Eg(X)=\int_0^\infty g'(z)P(X>z)dz \leq \int_0^\infty g'(z)P(Y>z)dz=Eg(Y)
$$
I understand the inequality in the middle but is it normal to use the notation $g'(z)$ here, shouldn't it be $g(z)$?
 A: It seems the OP's real question is how to get $Eg(X) = \int_0^\infty g'(z)P(X > z)$ (and analogously for $Y$).

Using elementary properties of integrals, one can write
$$
\begin{split}
\int_{0}^\infty g'(z) P(X > z)dz &= \int_0^\infty g'(z)\left(\int_{z}^\infty f_X(x)dx\right)dz = \int_0^\infty\int_{z}^\infty g'(z)f_X(x)dx dz\\
&= \int_{0}^\infty \int_{0}^xg'(z)f_X(x)dzdx = \int_{0}^\infty \left(\int_{0}^xg'(z)dz\right)f_X(x)dx\\
&= \int_{0}^\infty (g(x)-g(0))f_X(x)dx = \int_{0}^\infty g(x)f_X(x) =Eg(X),
\end{split}
$$
since $f_X$ is supported on $[0,\infty)$.

Edit: More general solution not assuming that $X$ has a density function!
For any $x \in \mathbb R$, one may rewrite
$$
g(x) = \int_{0}^x g'(z)dz = \int_0^\infty1_{\{x > z\}}g'(z)dz,
$$
where the 2nd equality is integration by parts, and the second is because the fucntion $z \mapsto 1_{\{x > z\}}$ is identically equal to $1$ on the interval $[0,x]$ (which might be empty!), and $0$ outside.
Thus, by the Law of the unconscious statistician, we may compute
$$
\begin{split}
Eg(X) &= \int_{-\infty}^\infty g(x)dP_X = \int_{-\infty}^\infty \left(\int_{0}^\infty 1_{\{x > z\}}g'(z)dz\right)dP_X \\
&= \int_{0}^\infty g'(z)\underbrace{\left(\int_{-\infty}^\infty 1_{\{x > z\}}dP_X\right)}_{P(X > z)}dz = \int_0^\infty g'(z)P(X > z)dz,
\end{split}
$$
where the second equality is an application of Fubini's theorem.
