Let $X$ be a random variable that takes non-negative integer values. Show that, $$E[X] = \sum^{\infty}_{k=1}P(X \geq k)$$
I'm having trouble following the solution. Could someone help clarify some steps? Thanks.
By definition, $$P(X \geq k) = \sum^{\infty}_{i=k}p_{X}(i)$$
Therefore, we substitute to get $$\sum^{\infty}_{k=1}P(X \geq k) = \sum_{k=1}^{\infty}\sum_{i=k}^{\infty}p_{X}(i)$$
Now here is where I'm confused. $$\sum_{k=1}^{\infty}\sum_{i=k}^{\infty}p_{X}(i) = \sum_{i=1}^{\infty}\sum_{k=1}^{i}p_{X}(i) = \sum^{\infty}_{i=1}ip_{X}(i)$$
I don't understand how we are manipulating the summations in the first equality and how we derive $ip_{X}(i)$ in the second equality.