Iteration of the quadratic function *f*(*x*) = 4*x*(1-*x*) is a famous example in **chaos theory**. Here’s what the first few iterations look like, starting with 1/√3. (There’s nothing special about that starting point; any point that doesn’t iterate to exactly zero will do.)

The values appear to bounce all over the place. Let’s look at a histogram of the sequence.

Indeed the points do bounce all over the unit interval, though they more often bounce near one of the ends.

Does that distribution look familiar? You might recognize it from Bayesian statistics. It’s a beta distribution. It’s symmetric, so the two beta distribution parameters are equal. There’s a vertical asymptote on each end, so the parameters are less than 1. In fact, it’s a beta(1/2, 1/2) distribution. It comes up, for example, as the **Jeffreys prior** for Bernoulli trials.

The graph below adds the beta(1/2, 1/2) density to the histogram to show how well it fits.

We have to be careful in describing the relation between the iterations and the beta distribution. The iterates are **ergodic**, not random. The **sequence** of points does not simulate independent draws from any distribution: points near 0.5 are always sent to points near 1, points near 1 are always sent to points near 0, etc. But **in aggregate**, the points do fill out the unit interval like samples from a beta distribution. In the limit, the proportion of points in a region equals the probability of that region under a beta(1/2, 1/2) distribution.

Here’s the Python code that produced the graphs above.

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()

** Related posts**: