Suppose that $X$ is a discrete random variable taking values in $\{0,1,2,...\}$. Show that $E[X]=\sum^{\infty}_{k=0}{P(X>k)}$ Suppose that $X$ is a discrete random variable taking values in $\{0,1,2,...\}$. Show that $E[X]=\sum^{\infty}_{k=0}{P(X>k)}$

Absolutely lost. From my notes, we define $E[X]$ as follows
$E[X]=\sum^{\infty}_{k=1}{xP(X=k)}$
I am also unsure how to explictly write $\sum^{\infty}_{k=0}{P(X>k)}$. My intuitive understanding of $P(X>k)=\{$ probability of the event not occuring consequetively until $X=k\}$, i.e.
$P(X>k)=(1-P(0))(1-P(1))(1-P(2)) \dots (1-P(k-1))$
Or is it
$P(X>k)=1-[P(X=0)P(X=1) \dots P(X=k-1)$
 A: Write 
$$\begin{align}
\mathbb{E} X &= \sum_{k=0}^\infty k \mathbb{P}\{ X = k\}
= \sum_{k=1}^\infty k \mathbb{P}\{ X = k\}
= \sum_{k=1}^\infty \sum_{j=1}^k \mathbb{P}\{ X = k\} \\
&= \sum_{j=1}^\infty \sum_{k=j}^\infty  \mathbb{P}\{ X = k\}
= \sum_{j=1}^\infty \sum_{k=j}^\infty  \mathbb{P}\{ X = k\}
= \sum_{j=1}^\infty  \mathbb{P}\big\{ \bigcup_{k=j}^\infty X = k\big\} \\
&= \sum_{j=1}^\infty \mathbb{P}\{ X > j- 1\}
= \sum_{i=0}^\infty \mathbb{P}\{ X > i\}.
\end{align}$$
For the record, the third equality may look like a magic "trick", and hard to figure out; the whole thing is more intuitive and easier to figure out starting from $\sum_{i=0}^\infty \mathbb{P}\{ X > i\}$ and trying to get back to $\sum_{k=0}^\infty k \mathbb{P}\{ X = k\}$.
A: To generalize, we have for an arbitrary random variable $X$ with $\mathbb P(X\geqslant 0)=1$,
$$ \mathbb E[X] = \int_0^\infty \mathbb P(X>t)\mathsf dt.$$
This follows from Fubini's theorem:
$$
\begin{align*}
\int_0^\infty \mathbb P(X>t)\mathsf dt &= 
\int_0^\infty \mathbb P(\omega\in\Omega: X(\omega)>t)\mathsf dt\\
&= \int_0^\infty \mathbb E[\mathbb I_{\{\omega\in\Omega :X(\omega)>t\}}]\mathsf dt\\
&= \int_0^\infty \int_\Omega \mathbb I_{\{\omega\in\Omega: X(\omega)>t\}}]\mathsf d\mathbb P\;\mathsf dt\\
&= \int_\Omega \int_0^{X(\omega)}\mathsf dt \mathsf\; d\mathbb P\\
&= \int_\Omega X\mathsf d\mathbb P\\
&= \mathbb E[X].
\end{align*}
$$
A: $$\begin{array}{cccccccccc}
P\{X>0\} & = & P\{X=1\} & + &P\{X=2\} & + & P\{X=3\} & +& \cdots\\
P\{X > 1\} &= &&&P\{X=2\} & + & P\{X=3\} & +\ &\cdots\\
P\{X > 2\}&= &&&&& P\{X = 3\} & + & \cdots\\
\vdots & \vdots &&&&&&& \ddots
\end{array}$$
Now sum by columns to get
\begin{align}
\sum_{k = 0}^\infty P\{X > k\} &= P\{X=1\}+2P\{X=2\}+3P\{X=3\}+\cdots\\
&= \sum_{n=1}^\infty n P\{X = n\}\\
&= \sum_{n=0}^\infty n P\{X = n\}&\scriptstyle{\text{added term}~ 0P\{X=0\}~\text{equals}~ 0}\\
&= E[X] & \scriptstyle{\text{by definition}}
\end{align}
A: This is essentially a change of order of summation.
Let $p_k = P(X=k)$.
$\sum_{k=0}^\infty P(X >k) =\sum_{k=0}^\infty \sum_{i=k+1}^\infty p_i  = \sum_{i=1}^\infty \sum_{k=0}^{i-1} p_i = \sum_{i=1}^\infty i p_i = E[X]$.
