Computing expectations by integrating survival function I am trying to show that $\mathbb{E}(\text{max}(X-u,0))=\int_u^\infty(x-u)dF_X(x)=\int_{u}^{\infty}(1-F_X(x))dx$
for $X$ positive r.v. and $u>0$.
I already know how to prove that $\mathbb{E}(X)=\int_{0}^{\infty}(1-F_X(y))dy$
and here I show my first approach which I would like to know if it's correct, which goes in the opposite direction of the above equality:
$\mathbb{E}(\text{max}(X-u,0))=\int_{u}^{\infty}(1-F_X(x))dx=\int_{u}^{\infty}\mathbb P(X>x)dx=\int_u^\infty\int_u^\infty1_{\{z>x>u\}}\mathbb{P}(X\in dz)dx=\int_u^\infty\int_u^\infty1_{\{z>x>u\}}dx\mathbb{P}(X\in dz)=\int_u^\infty\int_u^zda\mathbb{P}(X\in dz)=\int_u^\infty(z-u)\mathbb{P}(X\in dz)=\int_u^\infty(z-u)dF_X(z)$
I tried with a second way which I report here but I am having more troubles because I am not sure of where to integrate:
$\mathbb{E}(\text{max}(X-u,0))=\int_u^\infty(x-u)f_X(x)dx=\int_u^\infty\int_0^{x-u}1f_X(x)dydx=\int_u^\infty\int_{y-u}^\infty f_X(x)dxdy=\int_u^\infty(1-F_X(y-u))dy$
edit: second try of developing the second reasoning:
$\mathbb{E}(\text{max}(X-u,0))=\int_u^\infty(x-u)f_X(x)dx=\int_u^\infty\int_u^{x}1f_X(x)dydx=\int_u^\infty\int_{y}^\infty f_X(x)dxdy=\int_u^\infty(1-F_X(y))dy$
 A: Setting $Y:=\max\left(X-u,0\right)$ it is clear that $Y$ is a nonnegative
random variable so that: $$\mathbb{E}Y=\int_{0}^{\infty}1-F_{Y}\left(x\right)dx$$
For $x>0$ we find $1-F_{Y}\left(x\right)=P\left(Y>x\right)=P\left(X>u+x\right)=1-F_{X}\left(u+x\right)$
leading to: $$\mathbb{E}Y=\int_{0}^{\infty}1-F_{Y}\left(x\right)dx=\int_{0}^{\infty}1-F_{X}\left(u+x\right)dx=\int_{u}^{\infty}1-F_{X}\left(x\right)dx$$
A: Ahh, layer loss costs, or more precisely, excess annual aggregate loss (XSAAL) not conditional on being in the layer. Let $S(x)$ represent the survival function $1 - F(x)$.
$$
\begin{align}
E(\max(X - u), 0) &= \int_{u}^\infty(X - u) f(x)\; dx\\
&=\int_{u}^\infty Xf(x)\;dx - u\int_{u}^\infty f(x)\;dx\\
&=\int_{u}^\infty Xf(x)\;dx - uS(u)\\
\end{align}
$$
Use integration by parts on the first term. Let $t = x, dt = 1, dv = f(x), v = -S(x)$.
$$
\int_{u}^\infty Xf(x)\;dx = -xS(x)\biggr\rvert_u^\infty - \int_u^\infty -S(x)\;dx\\
$$
So the original expectation is now:
$$
=uS(s) - 0 + \int_u^\infty S(x)\;dx -uS(u)
$$
Outer terms cancel leaving us with:
$$
E(\max(X - u), 0) = \int_u^\infty S(x)\;dx
$$
The upper limit can also be a finite number, so the layer loss cost given an attachment point, $AP$ and a limit $L$ can be expressed the same way. Given $X$ is the random variable representing loss:
$$
E(\max(X - AP), L) = \int_{AP}^L S(x)\;dx
$$
