Free Throws That Reinforce Themselves
Tom makes his first free throw and misses his second. From the third attempt on, the probability that he makes attempt equals the fraction of his first attempts that were makes.
import random
def practice(attempts=100):
made, taken = 1, 2 # attempt 1 made, attempt 2 missed
for _ in range(attempts - 2):
if random.random() < made / taken:
made += 1
taken += 1
return made
print(sum(practice() for _ in range(10**6)) / 10**6)
What number does this print, up to simulation noise?
Answer format: enter an integer.
Sign in to answer questions and track your progress
Sign In