Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- prob = 0.249
- sample = 10000
- samples = []
- for _ in range(sample):
- pieces = 0
- tries = 0
- while pieces < 5:
- tries += 1
- if random.random() < prob:
- pieces += 1
- samples.append(tries)
- print(list(sorted(samples))[len(samples)//2])
Advertisement
Add Comment
Please, Sign In to add comment