In Chaos and the beta distribution", John Cook shows that the distribution of values generated by the logistic map fits a beta distribution. He shows that graphically by comparing the PMF of the generated values with the PDF of a beta distribution with parameters (1/2, 1/2).

Looking at that picture, it was not immediately clear whether the beta distribution fit the data at the extremes, so I wanted to compare the CDFs, which can sometimes show differences between distributions more clearly.

So here's John's code:

```
In [1]:
```import numpy as np
from scipy.stats import beta
import matplotlib.pyplot as plt
def quadratic(x):
return 4*x*(1-x)
N = 100000
x = np.empty(N)
# arbitary irrational starting point
x[0] = 1/np.sqrt(3)
for i in range(1, N):
x[i] = quadratic( x[i-1] )
plt.plot(x[0:100])
plt.xlabel("iteration index")
plt.show()
t = np.linspace(0, 1, 100)
plt.hist(x, bins=t, normed=True)
plt.xlabel("bins")
plt.ylabel("counts")
plt.plot(t, beta(0.5,0.5).pdf(t), linewidth=3)
plt.legend(["beta(1/2, 1/2)"])
plt.show()

```
```

And here's my code, using CDFs.

```
In [11]:
```from thinkstats2 import Cdf
import thinkplot

```
In [12]:
```plt.plot(t, beta(0.5,0.5).cdf(t), color='orange')
thinkplot.Cdf(Cdf(x), color='blue', linewidth=1)
plt.show()

```
```

Yup, that's a pretty good fit :)

Thanks for an interesting post, John.

```
In [ ]:
```