Central Limit Theorem

  1. Take $m$ random number from a uniform distribution.
  2. Calculate the mean.
  3. Repeat $N$ times.
  4. Plot the histogram.

In [1]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt

In [2]:
M = 100
N = 10000

X = np.random.random((N,M))

plt.hist(X.mean(axis=1), normed=True, bins=17);



In [3]:
M = list(range(2,10))

X_ = []
X_dev = []
for m in M:
    X = np.random.random((N,m))
    X_m = X.mean(axis=1)
    X_.append(X_m.mean())
    X_dev.append(X_m.std())

In [4]:
plt.plot(1/np.sqrt(M), X_dev)


Out[4]:
[<matplotlib.lines.Line2D at 0x7f53701a8c50>]