In [203]:

```
import scipy.stats
from IPython.zmq.pylab import backend_inline
cfg = backend_inline.InlineBackendConfig.instance()
cfg.figure_format = 'svg' # 'png' to switch back
```

In [204]:

```
phases = (np.random.vonmises(np.pi, 1, size=1000)/(2*np.pi)) % 1
```

In [215]:

```
ns, bin_edges = np.histogram(phases, range=(0,1), bins=10)
plt.plot(bin_edges, np.concatenate((ns,[ns[0]])), drawstyle='steps-post')
plt.errorbar((bin_edges[:-1]+bin_edges[1:])/2., ns, np.sqrt(ns), linestyle="none")
```

Out[215]:

In [206]:

```
lam = 100.
ni = np.random.poisson(lam, size=1000000)
zi = (lam-ni)/np.sqrt(ni)
ui = scipy.stats.norm.cdf(zi)
```

In [207]:

```
ui.sort()
plt.plot(np.arange(len(ui))/float(len(ui)), ui)
plt.plot((0,1),(0,1))
```

Out[207]:

In [208]:

```
lam = 1000.
ni = np.random.poisson(lam, size=10000)
mu = np.exp(0.5)
wi = [np.exp(np.random.normal(size=n)) for n in ni]
ti = np.array([np.sum(w) for w in wi])
```

In [209]:

```
np.mean([np.mean(w) for w in wi])/mu
```

Out[209]:

In [210]:

```
vi = np.array([np.sum(w**2)-np.mean(w)**2 for w in wi])
si = np.sqrt(vi)
zi = (lam*mu - ti)/si
ui = scipy.stats.norm.cdf(zi)
```

In [211]:

```
plt.hist(zi, bins=np.ceil(np.sqrt(len(zi))), normed=True)
xs = np.linspace(np.amin(zi),np.amax(zi),1000)
plt.plot(xs,scipy.stats.norm.pdf(xs))
```

Out[211]:

In [212]:

```
ui.sort()
plt.plot(np.arange(len(ui))/float(len(ui)), ui)
plt.plot((0,1),(0,1))
```

Out[212]:

In [213]:

```
scipy.stats.kstest(ui, lambda x:x)
```

Out[213]: