Advertisement
Guest User

Untitled

a guest
May 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. import random
  2. import tqdm
  3. import numpy as np
  4. import pylab as plt
  5. def trial():
  6. coins = []
  7. for _ in range(10000):
  8. coin = random.randint(0, 1)
  9. # Monday
  10. coins.append(coin)
  11.  
  12. # Tuesday
  13. if coin == 1: # Tails
  14. coins.append(coin)
  15.  
  16. return np.bincount(coins)[0] / len(coins)
  17. plt.hist([trial() for _ in tqdm.trange(int(1e4))], histtype='step'); plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement