Untitled
unknown
plain_text
2 years ago
475 B
11
Indexable
import random
ntrials = 100000
for N in range(10, 100):
nsurvive, ndead = 0, 0
for t in range(ntrials):
pop = 1 # selected per round
limit = N # if N rounds, stop - everyone lives
while (random.random() > (1.0/36.0)):
limit -= 1
nsurvive += pop
# everyone lives, stop doubling pop
if limit == 0:
break
pop *= 2
if limit > 0:
ndead += pop
if (nsurvive + ndead) > 0:
print(N, ndead / (nsurvive + ndead))Editor is loading...