U.S. Open - 4th Rd: How many BIRDIES will Gary Woodland AND Justin Rose record during Holes 8-11?
Inputs Needed to Solve
Pebble Beach Golf Links Course Stats
##### User Estimates #####
p_bird_8 = float(23)/400
p_bird_9 = float(32)/400
p_bird_10 = float(37)/400
p_bird_11 = float(42)/400
print("The probability of a PLAYER scoring BIRDIE on hole 8 is ~%s" % round(p_bird_8,3))
print("The probability of a PLAYER scoring BIRDIE on hole 9 is ~%s" % round(p_bird_9,3))
print("The probability of a PLAYER scoring BIRDIE on hole 10 is ~%s" % round(p_bird_10,3))
print("The probability of a PLAYER scoring BIRDIE on hole 11 is ~%s" % round(p_bird_11,3))
The probability of a PLAYER scoring BIRDIE on hole 8 is ~0.058
The probability of a PLAYER scoring BIRDIE on hole 9 is ~0.08
The probability of a PLAYER scoring BIRDIE on hole 10 is ~0.092
The probability of a PLAYER scoring BIRDIE on hole 11 is ~0.105
## Inputs Defined in the Problem
num_birdies = 2
Method to Solve
- Compute the probability of 0, 1 or 2 Birdies being scored on each hole (8-11) by the 2 golfers
- Enumrate all the possible combinations of 0, 1 or 2 BIRDIES being scored on holes 8-11.
- The probability that 0, 1 or 2 BIRDIES are scored by both golfers on holes 8-11 is the sum of the probabilities for all the outcomes where the total number of BIRDIES is less than or equal to 2.
import numpy as np
import pandas as pd
# Hole 8
p_other = 1 - p_bird_8
prob = (p_bird_8,p_other)
bird = (1,0)
a = {}
y = np.array([(x,y) for x in bird for y in bird])
birdies = pd.DataFrame(y)
#birdies.columns = golfers
birdies['total_birdies'] = birdies.sum(axis=1)
x = np.array([(x,y) for x in prob for y in prob])
probability = pd.DataFrame(x)
#probability.columns = golfers
probability['p'] = probability.product(axis=1)
for i in set(birdies.total_birdies):
a[i] = round(probability['p'][birdies['total_birdies']==i].sum(),2)
# Hole 9
p_other = 1 - p_bird_9
prob = (p_bird_9,p_other)
bird = (1,0)
b = {}
y = np.array([(x,y) for x in bird for y in bird])
birdies = pd.DataFrame(y)
#birdies.columns = golfers
birdies['total_birdies'] = birdies.sum(axis=1)
x = np.array([(x,y) for x in prob for y in prob])
probability = pd.DataFrame(x)
#probability.columns = golfers
probability['p'] = probability.product(axis=1)
for i in set(birdies.total_birdies):
b[i] = round(probability['p'][birdies['total_birdies']==i].sum(),2)
# Hole 10
p_other = 1 - p_bird_10
prob = (p_bird_10,p_other)
bird = (1,0)
c = {}
y = np.array([(x,y) for x in bird for y in bird])
birdies = pd.DataFrame(y)
#birdies.columns = golfers
birdies['total_birdies'] = birdies.sum(axis=1)
x = np.array([(x,y) for x in prob for y in prob])
probability = pd.DataFrame(x)
#probability.columns = golfers
probability['p'] = probability.product(axis=1)
for i in set(birdies.total_birdies):
c[i] = round(probability['p'][birdies['total_birdies']==i].sum(),2)
# Hole 11
p_other = 1 - p_bird_11
prob = (p_bird_11,p_other)
bird = (1,0)
d = {}
y = np.array([(x,y) for x in bird for y in bird])
birdies = pd.DataFrame(y)
#birdies.columns = golfers
birdies['total_birdies'] = birdies.sum(axis=1)
x = np.array([(x,y) for x in prob for y in prob])
probability = pd.DataFrame(x)
#probability.columns = golfers
probability['p'] = probability.product(axis=1)
for i in set(birdies.total_birdies):
d[i] = round(probability['p'][birdies['total_birdies']==i].sum(),2)
print("The number of possible birdies on hole 8 for 2 golfers and their respective probabilities are: %s" % a)
print("The number of possible birdies on hole 9 for 2 golfers and their respective probabilities are: %s" % b)
print("The number of possible birdies on hole 10 for 2 golfers and their respective probabilities are: %s" % c)
print("The number of possible birdies on hole 11 for 2 golfers and their respective probabilities are: %s" % d)
The number of possible birdies on hole 8 for 2 golfers and their respective probabilities are: {0: 0.89, 1: 0.11, 2: 0.0}
The number of possible birdies on hole 9 for 2 golfers and their respective probabilities are: {0: 0.85, 1: 0.15, 2: 0.01}
The number of possible birdies on hole 10 for 2 golfers and their respective probabilities are: {0: 0.82, 1: 0.17, 2: 0.01}
The number of possible birdies on hole 11 for 2 golfers and their respective probabilities are: {0: 0.8, 1: 0.19, 2: 0.01}
holes = ['8','9','10','11']
outcomes = (0,1,2)
y = np.array([(w,x,y,z) for w in outcomes for x in outcomes for y in outcomes for z in outcomes])
birdies = pd.DataFrame(y)
birdies.columns = holes
birdies['total_birdies'] = birdies.sum(axis=1)
x = np.array([(w,x,y,z) for w in a.values() for x in b.values() for y in c.values() for z in d.values()])
probability = pd.DataFrame(x)
probability.columns = holes
probability['p'] = probability.product(axis=1)
birdies.head()
8 | 9 | 10 | 11 | total_birdies | |
---|---|---|---|---|---|
0 | 0 | 0 | 0 | 0 | 0 |
1 | 0 | 0 | 0 | 1 | 1 |
2 | 0 | 0 | 0 | 2 | 2 |
3 | 0 | 0 | 1 | 0 | 1 |
4 | 0 | 0 | 1 | 1 | 2 |
probability.head()
8 | 9 | 10 | 11 | p | |
---|---|---|---|---|---|
0 | 0.89 | 0.85 | 0.82 | 0.80 | 0.496264 |
1 | 0.89 | 0.85 | 0.82 | 0.19 | 0.117863 |
2 | 0.89 | 0.85 | 0.82 | 0.01 | 0.006203 |
3 | 0.89 | 0.85 | 0.17 | 0.80 | 0.102884 |
4 | 0.89 | 0.85 | 0.17 | 0.19 | 0.024435 |
p = round(probability['p'][birdies['total_birdies']<num_birdies].sum(),3)
Solution
print("The proability that Gary Woodland AND Justin Rose record 0 or 1 BIRDIES during Holes 8-11 is ~%s" % p)
print("The proability that Gary Woodland AND Justin Rose record 2 or More BIRDIES during Holes 8-11 is ~%s" % round((1-p),2))
The proability that Gary Woodland AND Justin Rose record 0 or 1 BIRDIES during Holes 8-11 is ~0.866
The proability that Gary Woodland AND Justin Rose record 2 or More BIRDIES during Holes 8-11 is ~0.134