TITLE: Convergence of random variables in probability but not almost surely.
QUESTION [32 upvotes]: Can somebody provide me with a sequence of (real-valued) functions, say on $[0,1]$ with the Lebesgue measure, such that the sequence converges in probability, or maybe in $\Vert \cdot \Vert _{L^2}$, but does not converge almost surely?

REPLY [40 votes]: Consider a sequence $\{X_n\}$ of independent random variables such that $P(X_n=1)=\frac 1n$ and $P(X_n=0)=1-\frac 1n$. For $0<\varepsilon<1/2$ we have $P(|X_n|\geq \varepsilon)=\frac 1n$ which converges to $0$ hence $X_n\to 0$ in probability. Since $\sum_{n\geq 1}P(X_n=1)=+\infty$ and the events $\{X_n=1\}$ are independent, second Borel-Cantelli lemma ensures that $P(\limsup_n \{X_n=1\})=1$ hence the sequence $\{X_n\}$ does not converge to $0$ almost everywhere (in fact the set on which this sequence does not converge to $0$ has probability $1$). 
Counter-example for convergence in $L^p$ have already be provided, but I think the example I gave is also useful.