Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import numpy as np
- import matplotlib.pyplot as plt
- prob = [0.333333333333333333,0.666666666666666666]
- start = 0
- positions = [start]
- rr = np.random.random(1000)
- downp = rr < prob[0]
- upp = rr > prob[1]
- for idownp, iupp in zip(downp, upp):
- down = idownp and positions[-1] > -100
- up = iupp and positions[-1] < 100
- positions.append(positions[-1] - down + up)
- plt.plot(positions)
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement