The question is was posted in early Septermber, 2017, here and is a undergraduate level probabilty problem:
You’re hanging out with some friends, shooting the breeze and talking sports. One of them brags to the group that he once made 17 free throws in a row after years of not having touched a basketball. You think the claim sounds unlikely, but plausible. Another friend scoffs, thinking it completely impossible. Let’s give your bragging friend the benefit of the doubt and say he’s a 70-percent free-throw shooter.
So, who’s right? What is the number of free throws that a 70-percent shooter would be expected to take before having a streak of 17 makes in a row? And what if his accuracy was a bit worse?
This lends itself to a binomial probability distribution. The shooter has a 70% chance of making and a 30% chance of missing any given free throw. It should be immediate that for the shooter to make 17/17 the probability would be This is roughly a 0.2% chance that the shooter will make 17 in a row while taking 17 shots.
But that's not the question...
We want the expected number of attempts until the shooter hits a streak of 17 in a row.
Let's look at a similar problem that is a bit easier to wrap our heads around. I could ask how many times would I need to flip a coin before I got a streak of two heads. Clearly the probability of getting two heads in a row is (0.5)*(0.5) = 0.25, or 25%.
The event we are concerned with is the event that we get two heads in a row. This is unknown so let's represent it with a variable, X. Let's say the first flip is a tails, which happens with a probability of 1/2, and is one wasted flip, so now we need X + 1 flips to get a streak of two heads.
Suppose that the first flip was heads but the second flip was tails. This happens with proabbility 1/4 and we have two wasted flips so we now need X + 2 further flips.
The only other possibility is that the two flips were both heads, which happens with probability 1/4 and took 2 flips. Summing these up we have
X = (1/2)(X+1) + (1/4)(X + 2) + (1/4)2
Or X = 6. That is, on average, you should expect to get a streak of 2 heads every 6 flips.
Generalizing this, for the k-th flip to be tails the number of flips would be , and one can deduce the expected number of flips to get a streak of N heads would be
What if it's not a fair coin?¶
Let's start with two flips again and let's assume the head comes up with a 70% chance and tails only 30%. Let X be the number of flips needed to get a streak of two heads.
If the first flip is a tail, that happens with a probability of 0.3 and we have wasted a flip so now we need X + 1 flips. If the first flip is a head, but the second flip is a tail, that happens with a probability of (0.7)(0.3) and we need X + 2 flips. If two consecutive flips are heads, which happen with probabilty (0.7)(0.7) we acheived success in two flips. Now our equation looks like:
X = (0.3)(X+1) + (0.7)(0.3)(X + 2) + (0.7)(0.7)2
Solving for X we get
If let X now be 3 heads in a row, we go through the same analysis and end up with an equation that looks like
X = (0.3)(X+1) + (0.7)(0.3)(X + 2) + (0.7)(0.7)(0.3)(X + 3) + (0.7)(0.7)(0.7)3
and solving for X we get that it takes approximately 6.38 flips.
In general, if we let a = probability of heads, then (1 - a) = probability of tails and if we look for a streak of X = 3 heads the equation above becomes,
More generally, the expected number of flips to get N heads is
and solving for X we have a nice tidy formula,
Solving Using Python¶
import numpy as np import pandas as pd import matplotlib.pyplot as plt %matplotlib inline def get_expected_value(a,N): # this method returns the expected number # of flips, free throws or whatever num = (1 - a)*np.sum([k*a**(k-1) for k in range(1,N+1)]) + a**N*N den = 1 - (1-a)*np.sum([a**(k-1) for k in range(1,N+1)]) return num/den def hours_and_minutes_to_acieve(attempts): s = 11.0 # assume 11 seconds per free throw return s*attempts/60.0/60.0
# test it print(get_expected_value(0.5,2)) # should be 6 print(get_expected_value(0.7,2)) # should be 3.469
# Free throws: print("The expected number of free throws \n\ for a 70% free throw shooter to hit 17 in a row is ...\n") print(int(get_expected_value(0.7,17)),"attempts")
The expected number of free throws for a 70% free throw shooter to hit 17 in a row is ... 1429 attempts
How long was he in the gym?¶
So, let's say, on average it takes 11 seconds to take a free throw and recover your miss/make. Your buddy would, on average, spent 11$\times$1429 seconds or about 4 hours and 22 minutes to acieve this.
print("The length, in hours, to hit 17 in a row:",hours_and_minutes_to_acieve(1429))
The length, in hours, to hit 17 in a row: 4.366388888888889
# for fun let's see how long it would take varous free throw shooters percentage = [40 + i for i in range(54)] # reasonable range shooting_info = pd.DataFrame(columns=['expected attempts','time'],index=percentage)
atts =  times =  for val in shooting_info.index: attempts = get_expected_value(val*.01,17) atts.append(attempts) times.append(hours_and_minutes_to_acieve(attempts)) shooting_info['time'] = times shooting_info['expected attempts'] = atts
fig = plt.figure(figsize=(11,8)) plt.grid(zorder=0) plt.bar(shooting_info['expected attempts'][20:].index,shooting_info['expected attempts'][20:], align='center', color='skyblue', zorder=3) plt.title('Expected attempts for shooters of different \n FT percentages to hit 17 in a row') plt.xlabel('shooting percentage') plt.ylabel('expected attempts');
fig = plt.figure(figsize=(11,8)) plt.grid(zorder=0) plt.bar(shooting_info['time'][17:].index,shooting_info['time'][17:], align='center', color='skyblue', zorder=3) plt.title('Expected time for shooters of different \n percentages to hit 17 in a row') plt.xlabel('shooting percentage') plt.ylabel('time (hours)');
What about Drummond? It would take him approximately 86,682,190 attempts, and if we assume 11 seconds between attempts it would take him 264,862 hours, or about 30 years of non-stop, 24 hours a day free throw shooting.
So, quite a fun little problem!