Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import sys
- def flip(players):
- success = 0
- for p in range(players):
- outcome = random.randint(0,1)
- if outcome == 1:
- success += 1
- return success
- def trial():
- players = 1000
- for t in range(10):
- players = flip(players)
- return players
- outcomes = {}
- n = 1000000
- update = 10000
- for i in range(n):
- result = trial()
- if result in outcomes:
- outcomes[result] +=1
- else:
- outcomes[result] = 1
- if i%update == 0:
- progress = str(round(100*(i+1)/n))
- sys.stdout.write(""\r"" + progress + ""% "")
- sys.stdout.flush()
- print(outcomes)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement