import numpy as np import matplotlib.pyplot as plt def randMap(a, b, c): x = 1 while True: x = (a*x + b) % c yield x #xn1 = (a*xn + b) % c #return xn1 N=1000 #number of iterations #x = np.ones(N) #Values from text book a = 8121 b = 28411 c = 134456 # randNum = randMap(a, b, c) #Random ish points between 0-1 example # x = np.ones(N) # for i in range(1,N): # x[i] = next(randNum) # x = x/c # plt.plot(x[:(N-1)],x[1:N], 'o') # plt.show() #Random walkers W = 10 #walker amount t = range(N) #random walks for i in range(W): traj = np.zeros(N) pos = 0 for j in range(1,N): if ((next(randNum)/c)>=0.5): pos +=1 else: pos -=1 #print('no') traj[j]=pos plt.plot(t, traj) D = 0.5 sigma = np.sqrt(t) plt.fill_between(t, 1.5*sigma, -1.5*sigma, facecolor = 'lavender') #plt.style.use('dark_background') plt.show()