# Central Limit Theorem and Weak Law of Large Numbers

### 8 minutes read

Hello!

After a (*really*) long hiatus, I have resolved to start writing these posts more freqently. The first actual post I attempted (which is still incomplete) turned out to be a lot more effort than I initially fathomed. Thus, in this post, I decided to set more realistic goals. At the outset, I do not claim any of the below material to be my own, but rather the culmination of effort to *restart* the habit of reading and writing more frequently. Secondly, although the title of this post is a comprehensive topic (indeed, there is a mind-boggling number of books written on the subject, also feel free to check out the excellent post by Terence Tao) I will focus on two specific aspects. (i) I will introduce the Central Limit Theorem (CLT) and the Weak Law of Large Numbers (WLLN), and prove these results using the idea of Characteristic Functions; and (ii) I will provide a numerical experiment that shows the CLT in action.

**Central Limit Theorem and Weak Law of Large Numbers**

Many of you might have noticed that most Machine Learning theoreticians (definitely in most engineering fields) often assume that the underlying probability distribution for *any* problem make the assumption of Gaussianity, i.e., they assume that the true/natural data obeys a Gaussian distribution. This may seem contrived at the first glance because: why does nature have to obey Gaussian distribution? Well, a part of the justification might arise from the implications of the Central Limit Theorem. Said simply, it states that if you draw independent, and identically distributed (i.i.d.) samples, from *any* probability distribtion with mean and variance , then CLT states the following:
\begin{equation}
\sqrt{n}\left(\frac{X_1 + X_2 + \cdots + X_n}{n} - \mu\right) \overset{d}{\to} \mathcal{N}(0, \sigma^2)
\end{equation}
where the symbol denotes that the random variable on the left “converges in distribution” to the distribution on the right as . Qualitatively, what that means is that if one were to draw multiple copies of the r.v. on the left and “plot their histrogram”, it would look more and more like a Gaussian density as you increase the value of .

The next result is the Weak Law of Large numbers. Consider, the same set of i.i.d. samples from the same distribution as before. WLLS states that
\begin{equation}
\frac{1}{n}(X_1 + X_2 + \cdots + X_n) \overset{p}{\to} \mu
\end{equation}
where the symbol means that the r.v. on the left “converges in probability” to the value on the right as . Qualitatively, this means that if you give my *any* deviation, (from the mean) I can give you a large enough value of such that with probability the r.v. belongs to the interval . The more precise statment for the above is
\begin{equation}
\lim_{n \to \infty} \mathbb{P}\left( \left|\frac{1}{n}(X_1 + X_2 + \cdots + X_n) - \mu \right| > \epsilon\right) = 0
\end{equation}

**Proof of Central Limit Theorem:**
There are multiple ways in which one can prove the CLT but I will focus on using the Characteristic Function (CF) (since I major in Signal Processing) approach. Recall that the CFof a r.v. is the expectation of the Fourier Transform, i.e., . We will use these important properties of the CF (i) for independent r.v.’s , ; (ii) for a positive scalar ; and (ii) the CF completely defines a r.v., and that the CF of a Gaussian r.v. is the density itself.
Now, we expand the l.h.s. of the CLT equation and define the following r.v.’s to make the ideas easy to follow.
\begin{equation}
\sqrt{n}\left(\frac{X_1 + X_2 + \cdots + X_n}{n} - \mu\right) = \sqrt{n} \cdot \frac{\sum_{i=1}^n (X_i - \mu)}{n} = \frac{\sum_{i=1}^n (X_i - \mu)}{\sqrt{n}}
\end{equation}
Also, notice that if we let , the r.v.’s are zero-mean, unit variance and still i.i.d. Next define and consider its CF. Since are i.i.d., we will drop the subscript and use to mean any of the identical copies
\begin{align}
\psi_{Y_n}(t) &= \psi_{Z_1}\left(\frac{t}{\sqrt{n}}\right) \cdot \psi_{Z_2}\left(\frac{t}{\sqrt{n}}\right) \cdots \psi_{Z_n}\left(\frac{t}{\sqrt{n}}\right) \\
&= \left(\psi_Z\left(\frac{t}{\sqrt{n}}\right)\right)^n = \left(\mathbb{E}\left[e^{\frac{itZ}{\sqrt{n}}} \right]\right)^n
\end{align}
now, from the Taylor series expansion of , it is easy to see that
\begin{align}
\mathbb{E}\left[e^{\frac{itZ}{\sqrt{n}}} \right] &= \mathbb{E}\left[1 + \frac{itZ}{\sqrt{n}} - \frac{t^2 Z^2}{2n} - \frac{it^3 Z^3}{3! n^{3/2}} + \cdots \right] \\
&= 1 + 0 - \frac{t^2}{2n} - \frac{it^3 \mathbb{E}[Z^3]}{3! n^{3/2}} + \cdots
\end{align}
the important point to observe here is that all higher powers () become infinitesimally small as and thus
\begin{equation}
\psi_Z(t) = 1 - \frac{t^2}{2n} + r\left(\frac{t}{\sqrt{n}}\right)
\end{equation}
where is the “infinitesimal residual”. Now, pluggin that value into the CF of , we obtain
\begin{align}
\psi_{Y_n}(t) = \left(1 -\frac{t^2}{2n} + r\left(\frac{t}{\sqrt{n}}\right) \right)^n = \left(\left(1 -\frac{t^2}{2n} + r\left(\frac{t}{\sqrt{n}}\right) \right)^{-2n/t^2}\right) ^{\frac{-t^2}{2}} \to e^{\frac{-t^2}{2}}
\end{align}
as . This proves that the distribution of tends to become closer the the standard Gaussian distribution with increasing values of . Finally, applying a rescaling of , we obtain the simplification of the l.h.s. of the main theorem. This proves CLT.

**Proof of Weak Law of Large Numbers:**
Again, here there are multiple methods to prove the WLLN but I will focus on using CF. Again, since the r.v.’s are i.i.d., we will often drop the subscript and use to denote any of the identical copies. First, we define and now consider the CF of . Recalling the two basic properties of CF from the previous section we obtain

\begin{align}
\psi_{Y_n}(t) &= \psi_{X_1/n}(t) \cdot \psi_{X_2/n}(t) \cdots \psi_{X_n/n}(t) \\
&= (\psi_{X/n}(t))^n = \left(\psi_X \left(\frac{t}{n}\right) \right)^n
\end{align}
now, using the same ideas as before: defintion of CF, linearity of expectation, and the Taylor series expansion of , it follows that
\begin{align}
\psi_{Y_n}(t) &= \left( 1 + \frac{it\mu}{n} - \frac{t^2 \mathbb{E}[X^2]}{2! n^2} - \frac{it^3 \mathbb{E}[X^3]}{3! n^3} + \cdots \right)^n \\
&= \left( 1 + \frac{it\mu}{n} + r\left(\frac{t}{n}\right) \right)^n \\
&= \left( \left( 1 + \frac{it\mu}{n} + r\left(\frac{t}{n}\right) \right)^{\frac{n}{it \mu}}\right)^{i t \mu} \to e^{it\mu} \ \ \text{as} \ \ n \to \infty
\end{align}
and the “residual”, as . Finally, recall that due to the fact that the CF is the Fourier Transform of the density function, the Delta dirac, at has the CF which means that and since is a constant, it implies that which proves WLLN.

**Numerical Verification of Central Limit Theorem:**
Here, I show using a simple numerical example to show CLT in practice. The exercise I performed here is the following. I generated samples () from the uniform random distribution, which denotes that all entries are between and . The mean is and the variance is for this particular distribution. Next, for varying values of , I computed the “empirical density” of . I also plotted the “true density”, . It is very interesting to see that as (since we cannot really use the upper bound of ) the histogram converges very closely to match the Gaussian density, thus confirming claim of CLT. Furthermore, notice that here I show the figures at a logarithmic scale in and in some sense, the empirical histogram converges “linearly” to the true density. I might make a another post detailing the convergence rates of CLT in the near future.

Here is the code snippet used to create the above animation.

```
#!/usr/bin/env/ python
#import libraries
import numpy as np
import matplotlib.pyplot as plt
#generate samples using uniform random distribution
nrange = range(0, 50000);
S = np.zeros([50000,1]);
for n in nrange:
Y = np.random.uniform(0, 1, n+1);
S[n] = (np.mean(Y) - 0.5) * np.sqrt(n+1);
fig = plt.figure();
ax = plt.subplot(111);
Nrange = np.logspace(np.log10(10), np.log10(50000), 100);
for N in Nrange:
plt.hist(S[0 : int(N) : 1], bins = 50, range=[-1.5, 1.5], normed=True, color="skyblue");
t = np.linspace(np.min(S), np.max(S), 10000);
mu = np.mean(S)
sig = float(1)/np.sqrt(12);
gaussian = 1 / np.sqrt(2 * np.pi * sig **2 )* np.exp(-(t ** 2)/(2 * sig **2));
plt.plot(t, gaussian, linewidth=2, color='r')
plt.ylim([0,2.5])
plt.title('N = {}'.format(int(N)))
plt.pause(.1);
plt.clf();
```

And, that’s all folks!!