Expected value of random variable ($X$) that takes non-negative integer values.

We have to proof:
$$E[X] = \sum_{k=1}^{\infty} P(X \geq k).$$

We knew that: $$P(X \geq k)= \sum_{i=k}^{\infty} p_X(i)$$
$$\sum_{k=1}^{\infty} P(X \geq k)= \sum_{k=1}^{\infty} \sum_{i=k}^{\infty} p_X(i).$$

I am confused in this step:
$$\sum_{k=1}^{\infty} \sum_{i=k}^{\infty} p_X(i) = \sum_{i=1}^{\infty} \sum_{k=1}^{i} p_X(i).$$

The next step is just:
$$\sum_{i=1}^{\infty} \sum_{k=1}^{i}p_X(i) = \sum_{i=1}^{\infty}ip_X(i) = E[X].$$

Complete Solution is here Problem 3(a).

Split the tacitly ignored space $$\Omega$$ where the computation is done in the pieces $$\Omega_0$$, $$\Omega_1$$, ... , $$\Omega_k=\{X=k\}$$, and let $$p_k=\Bbb P(\Omega_k)$$. Now let us look at the diagram: $$\begin{array}{r|llll} \Omega_0 &&&&\\ \Omega_1 &p_1&&&\\ \Omega_2 &p_2&p_2&&\\ \Omega_3 &p_3&p_3&p_3&\\ \Omega_4 &p_4&p_4&p_4&p_4 \end{array}$$ and continue the triangle pattern to infinity.
The sum on row $$k$$ is then $$kp_k$$, ($$X$$ is conditioned to live in $$\Omega_k$$), and summing this row values we get $$\Bbb E[X]$$.
The sum on the first column is $$\Bbb P[X\ge 1]$$, on the second is $$\Bbb P[X\ge 2]$$, on the third is $$\Bbb P[X\ge 3]$$, and so on, and the exchange of the order of summation is (sum first on rows, than on columns versus sum first on columns, then on rows) gives the needed formula.
• The theme is "Fubini" (on the space / lattice $\Bbb N\times \Bbb N$ with the above placement of values in the lattice points). – dan_fulea May 1 at 12:34
You sum on $$\{(i,j)\mid 0\leq i\leq j<\infty \}$$ So, if you fix $$j$$, then $$i$$ goes from $$i\to \infty$$. If now you fix $$j$$, then $$i$$ goes from $$0\to j$$.