Almost sure convergence implying mean square convergence

convergence-divergence

A sequence $(X_n)_{n\in\mathbb{N}}$ is said to converge to $X$ in the almost sure convergence sense if
$\lim_{n\rightarrow\infty} X_n \rightarrow X$ on a set with probability $1$.

Then I proceed like below

\begin{align}\lim_{n\rightarrow\infty} X_n &\rightarrow X \hspace{4mm} \text{a.s.} \\
\lim_{n\rightarrow\infty} X_n – X &\rightarrow 0 \hspace{5mm} \text{a.s.} \\
\lim_{n\rightarrow\infty} \mathbb{E}[(X_n-X)^2] &\rightarrow 0 \hspace{5mm} \text{a.s.} \end{align}

However this is not true as almost sure convergence $\;\not\!\!\!\implies$ mean squared convergence. Where is the flaw in these steps?
Please excuse me if this doubt is silly.

Best Answer

It's not, in general, true that $\lim_{n\to\infty} \mathbb{E}(X_n-X)^2=\mathbb{E}\lim_{n\to \infty}(X_n-X)^2$, and the left-hand side need not even exist, even if the right-hand side does.

To see this, let $X_0\sim Unif([0,1])$ and define $$ X_n=\begin{cases} 0 & X_0\geq \frac{1}{n} \\ n & else\end{cases} $$ Then, $X_n\to 0$ almost surely, since almost surely, $X_0>0$. However, $$ \mathbb{E} X_n^2= n^2 \mathbb{P}\left(X_0< \frac{1}{n}\right)=n\to \infty, $$ in particular, we don't have

$$ \lim_{n\to\infty}\mathbb{E}(X_n-0)^2=\mathbb{E}\lim_{n\to\infty} (X_n-0)^2=\mathbb{E} 0=0 $$ since the left-hand side limit doesn't even exist in $\mathbb{R}$.

Related Question