# (c) Rory Clune 2/23/2011 # Random Walker with order 34 LFSR random number generator. Taps at 1, 2, 27, 34 # Error bars derived analytically using solution of the diffusion equation by Fourier transforms from numpy import* from pylab import* order = 34 rand = ones([order+1]) points = 1000 walkers = 10 x = zeros([1000]) for i in range (0,walkers): for j in range (1,points): rand[0]=(rand[1]+rand[2]+rand[27]+rand[34])%2 rand[1:order+1] = rand[0:order] if rand[0] == 0: x[j]=x[j-1]+1 else: x[j]=x[j-1]-1 plot(x) t = arange(0,points,(points/5)) error = 1.5*sqrt(t) errorbar(t, zeros([size(t)]), yerr=error, fmt=None, ecolor = 'k') axis([0,points,-150,150]) show()