Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import random
  2. import numpy as np
  3. import matplotlib.pyplot as plt
  4.  
  5. prob = [0.333333333333333333,0.666666666666666666]
  6.  
  7. start = 0
  8. positions = [start]
  9.  
  10. rr = np.random.random(1000)
  11. downp = rr < prob[0]
  12. upp = rr > prob[1]
  13.  
  14. for idownp, iupp in zip(downp, upp):
  15. down = idownp and positions[-1] > -100
  16. up = iupp and positions[-1] < 100
  17. positions.append(positions[-1] - down + up)
  18.  
  19. plt.plot(positions)
  20. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement