Created
May 27, 2012 19:46
-
-
Save automata/2815638 to your computer and use it in GitHub Desktop.
painting with random walks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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