Prove that $E(X) = \int_{0}^{a} (1-F_X(x))\,dx$ Let $X$ be a continuous non-negative random variable on $(0,a)$. Prove that $$E(X) = \int_{0}^{a} (1-F_X(x))\,dx$$ where $F_X(x)$ is the CDF for $X$.
I know that by definition:
$$F_X(x) = P(X \leq x) => 1 - F_X(x) = P(X>x)$$
So i can easily go to the next step.
But what should I do in this case?
$$
\mathbb{P}(0 < X < a) = \int_0^a f_X(x)dx
$$
Thank you
 A: \begin{align}
E(X) & = \int_0^\infty x f(x) \ dx \\
& = \int_0^\infty \int_0^x f(x) \ dy dx \\
& = \int_0^\infty \int_y^\infty f(x) \ dx dy \\
& = \int_0^\infty [1-F(y)] \ dy.
\end{align}
A: To prove $\mathbb{E}(X) = \int_0^\infty \mathbb{P}(X\geq x)\,\mathrm{d}x$, we proceed as follows: $$\mathbb{E}(X) = \mathbb{E}\left(\int_0^\infty \mathbf{1}_{X>x}\, \mathrm{d}x \right) = \int_0^\infty \mathbb{E}\left(\mathbf{1}_{X>x}\right) \, \mathrm{d}x = \int_0^\infty \mathbb{P}(X\geq x)\,\mathrm{d}x.$$
A: By definition,
$$
\begin{aligned}
\text{E}\left(X\right) &= \int_{-\infty}^{+\infty} x f_X(x)dx = \int_{0}^{a} x f_X(x)dx =  \int_{0}^{a} x F'_X(x)dx = \\
&= (\text{applying integration by parts}) = \\
&= \int_{0}^{a} \underbrace{x}_{u} \underbrace{dF_X(x)}_{dv} = \left.\underbrace{x}_{u}\underbrace{F_X(x)}_{v}\right|_0^a - \int_{0}^{a} \underbrace{F_X(x)}_v\underbrace{dx}_{du} = \\ 
&= a\cdot \underbrace{F_X(a)}_{= 1} - 0\cdot \underbrace{F_X(0)}_{= 0} - \int_{0}^{a} F_X(x)dx = a\cdot 1 - \int_{0}^{a} F_X(x)dx = \\
&= \left(\text{now, notice that }\int_0^adx = a\right) = \\
&= \int_0^adx - \int_{0}^{a} F_X(x)dx = \\
&= \int_{0}^{a}\left(1- F_X(x)\right)dx
\end{aligned}
$$
