Skip to content

Instantly share code, notes, and snippets.

@automata
Created May 27, 2012 19:46
Show Gist options
  • Save automata/2815638 to your computer and use it in GitHub Desktop.
Save automata/2815638 to your computer and use it in GitHub Desktop.
painting with random walks
import numpy as n
import pylab as p
import matplotlib.cm as cm
n_colors = 100
n_steps = 5000
colors = cm.hot(i/float(n_colors), 1) for i in range(n_colors)]
for color in colors:
thetas = n.random.uniform(0, 2*p.pi, n_steps)
real = [n.cos(t) for t in thetas]
imag = [n.sin(t) for t in thetas]
xs = p.cumsum(real)
ys = p.cumsum(imag)
p.plot(xs, ys, '-', c=color)
p.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment