The chaos game is played as follows. Pick a starting point at random. Then at each subsequent step, pick a triangle vertex at random and move half way from the current position to that vertex.
The result looks like a fractal called the Sierpinski triangle or Sierpinski gasket.
Here’s an example:
If the random number generation is biased, the resulting triangle will show it. In the image below, the lower left corner was chosen with probability 1/2, the top with probability 1/3, and the right corner with probability 1/6.
Here’s Python code to play the chaos game yourself.
from scipy import sqrt, zeros import matplotlib.pyplot as plt from random import random, randint def midpoint(p, q): return (0.5*(p[0] + q[0]), 0.5*(p[1] + q[1])) # Three corners of an equilateral triangle corner = [(0, 0), (0.5, sqrt(3)/2), (1, 0)] N = 1000 x = zeros(N) y = zeros(N) x[0] = random() y[0] = random() for i in range(1, N): k = randint(0, 2) # random triangle vertex x[i], y[i] = midpoint( corner[k], (x[i-1], y[i-1]) ) plt.scatter(x, y) plt.show()
Source: Chaos and Fractals
from The Endeavour http://ift.tt/2jetMlG
via IFTTT