Guest User

Untitled

a guest
Sep 10th, 2023
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. from random import random
  2.  
  3. import matplotlib.pyplot as plt
  4. plt.style.use('ggplot')
  5.  
  6. stake = base_stake = 10
  7. balance = 2000
  8. balance_history = []
  9. tries = 10000
  10.  
  11. for _ in range(tries):
  12.     if random() < (0.5 + 2/38):  # 2/38 represents zero plus double zero
  13.         balance -= stake
  14.         stake *= 2
  15.     else:
  16.         balance += stake
  17.         stake = base_stake
  18.        
  19.     balance_history.append(balance)
  20.  
  21. plt.figure(figsize=(15, 4))
  22. plt.plot(balance_history)
  23. plt.ylabel('Balance'); plt.xlabel('# of roll');
  24. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment