# Typewriter sequence of a U(0,1) random variable

This problem is a standard counterexample in measure theory in disguise:

Let ${Z\sim\mathrm U(0,1)}$ and define

$\displaystyle X_n = \mathsf 1_{[m2^{-k},\ (m+1)2^{-k})}(Z)$

for ${n=2^k+m}$, ${k\geqslant 1}$, and ${0\leqslant m<2^k}$. In what sense does ${X_n}$ converge to zero?

If ${\varepsilon\in(0,1)}$ then

$\displaystyle \mathbb P(X_n>\varepsilon) = \mathbb P(X_n=1)=2^{-k}.$

Now, as ${n=2^k+m}$, we have ${k=\lg(n-m)}$ and so ${2^{-k}=\frac1{n-m}\leqslant\frac1n}$. Hence

$\displaystyle \mathbb P(X_n=1)\leqslant\frac1n\stackrel{n\rightarrow\infty}\longrightarrow0,$

so that ${X_n}$ converges to zero in probability.

It follows immediately that ${X_n\stackrel{L^1}\longrightarrow 0}$, as

$\displaystyle \mathbb E[X_n] = \mathbb P(X_n=1)\leqslant\frac1n\stackrel{n\rightarrow\infty}\longrightarrow0,$

and similarly ${X_n\stackrel{L^p}\longrightarrow 0}$, for ${1\leqslant p<\infty}$ as

$\displaystyle \mathbb E[X_n^p] = \mathbb P(X_n=1)\leqslant\frac1n\stackrel{n\rightarrow\infty}\longrightarrow0,$

However, ${X_n}$ does not converge almost surely to zero, as for ${\varepsilon\in(0,1)}$ we have

\displaystyle \begin{aligned} \mathbb P\left(\liminf_{n\rightarrow\infty} X_n<\varepsilon\right) &= \mathbb P\left(\bigcup_{n=2}^\infty\bigcap_{l=n}^\infty \{X_l=0\} \right)\\ &= \lim_{n\rightarrow\infty}\mathbb P\left(\bigcap_{l=n}^\infty \{X_l=0\} \right)\\ &= \lim_{n\rightarrow\infty}\mathbb P(Z

The “disguise” is that ${X_n}$ is really just the “typewriter sequence” from e.g. Terry Tao’s blog, with some minor tweaks that do not affect convergence.