Solving 538's Free Throw Riddler

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 \underbrace{(0.7)*(0.7)...*(0.7)}_{17 \text{ times}} = 0.0023 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.

Expected Values

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 \frac{1}{2^k}(x + k), and one can deduce the expected number of flips to get a streak of heads would be X = 2^{N+1} - 2

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 X \approx 3.469

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,

X = (1-a)(X+1) + (1-a)(a)(X + 2) + (1-a)(a^2)(X + 3) + a^33

More generally, the expected number of flips to get heads is
 X = (1-a)\sum_{k=1}^Na^{k-1}(X + k) + a^NN

and solving for X we have a nice tidy formula,

X = \frac{(1-a)\sum_{k=1}^Nka^{k-1} + a^NN}{1 - (1 - a)\sum_{k=1}^Na^{k-1}}

We want to explore a 70% free throw shooter. The answer lies below and we use Python to develop the general case. Let's keep in mind there are free throw shooter's in the NBA much worse that 70%.In fact, Andre Drummnd of the Detroit Pistons once was shooting around 35%. How long would it take him to hit 17 in a row? The result is astoundingly funny.

Solving Using Python

In [9]:

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 read more

An Interactive (DATA) dump: Using the NBA to Explore Python's Visualization Capabilities

Recent advances in data acquisition in the NBA allow us to gain insight into the sport and it's players, and, we can use this data to play with Python's visualization abilities. In this post data from the current season is used to see just how dominant the Golden State Warriors are; Fivethirtyeight's ELO rankings help to make an interactive graph (not usable on a mobile device); shot charts from help to build a 3D visualization of a player's shots; and, we will look for any changes in Stephen Curry's play that may explain his explosive 2015-2016 season. read more

Stephen Curry is a Black Swan: A once in a 151-year season

There will be two epoch's in the history of the NBA, before Curry, BC, and after Curry, AC; Fivethirtyeight's "Stephen Curry is the Revolution" and  "How the Golden State Warriors are Breaking the NBA" are among recent articles arguing how absurdly good his 2015-2016 season has been. There is no hyperbole too grand. Is he a "Golden God?" read more