Guest User

Rogues den probabilities

a guest
Feb 16th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.29 KB | None | 0 0
  1. import random
  2.  
  3. prob = 0.249
  4. sample = 10000
  5. samples = []
  6. for _ in range(sample):
  7.     pieces = 0
  8.     tries = 0
  9.     while pieces < 5:
  10.         tries += 1
  11.         if random.random() < prob:
  12.             pieces += 1
  13.     samples.append(tries)
  14.  
  15. print(list(sorted(samples))[len(samples)//2])
Advertisement
Add Comment
Please, Sign In to add comment