Alternatives to find the expectancy of a random variable For actuarial mathematics there is an important identity to calculate the life expectancy for X defined on $[0,\infty)$:
identity
$$
E[X]=\int_0^\infty S_X[x]\,\mathrm{d}x
$$
where $S_{x}(x)$(survival function) is equal to $1-F_{x}(x)$, where $F_{x}$ is the CDF, which theorem or lemma exists so i can understand this identity?
 A: 
I will elaborate a little on the general measure-theoretical context here, which does not rely on the existence of a density $f_X$ (which would simply be the Radon-Nikodym derivative of the pushforward $X_\ast \mathbb{P}$ with respect to the Lebesgue measure $\lambda$).
I will use the following notation: $(\Omega, \mathcal{B}, \mathbb{P})$ for the probability space on which $X \in L^0(\Omega)$ is defined. Then by definition we have that $\mathbb{E}[X] = \int_\Omega X d\mathbb{P} = \int_{[0, \infty)} x \, dX_\ast\mathbb{P},$ where I used the fact that your variable takes values in $[0, \infty)$ and applied the change of variables formula in the measure-theoretical context at play here. Note that the pushforward $X_\ast\mathbb{P} = \mathbb{P} \circ X^{-1}$ is just the cummulative distribution function of $X.$ But we also have that $x = \int_0^x d\lambda(y),$ so $\mathbb{E}[X] = \int_0^\infty \int_0^x d\lambda(y) \, d X_\ast \mathbb{P}(x).$ Note that we may indeed apply Fubini's Theorem here, finally yielding $\mathbb{E}[X] = \int_0^\infty \int_y^\infty dX_\ast\mathbb{P}(x) \, d\lambda(y) = \int_0^\infty (1 - F_X(y)) \, d \lambda(y) = \int_0^\infty S_X(y) d\lambda(y),$ which is the desired equality.
I hope this is clear, but if not do let me know!
