Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import random
- import matplotlib.pyplot as plt
- plt.style.use('ggplot')
- stake = base_stake = 10
- balance = 2000
- balance_history = []
- tries = 10000
- for _ in range(tries):
- if random() < (0.5 + 2/38): # 2/38 represents zero plus double zero
- balance -= stake
- stake *= 2
- else:
- balance += stake
- stake = base_stake
- balance_history.append(balance)
- plt.figure(figsize=(15, 4))
- plt.plot(balance_history)
- plt.ylabel('Balance'); plt.xlabel('# of roll');
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment