U.S. Open - 1st Rd: How many BIRDIES will R. McIlroy AND J. Rahm record during Holes 15-18?
Inputs To Solve
Pebble Beach Golf Links Course Stats
##### User Estimates #####
p_bird_15 = 45/(45+160+24+2)
p_bird_16 = 30/(30+162+38+1)
p_bird_17 = 42/(42+151+33+5)
p_bird_18 = 66/(3+66+102+46+12+2)
print("The probability of a PLAYER scoring BIRDE on hole 15 is ~%s" % round(p_bird_15,3))
print("The probability of a PLAYER scoring BIRDE on hole 16 is ~%s" % round(p_bird_16,3))
print("The probability of a PLAYER scoring BIRDE on hole 17 is ~%s" % round(p_bird_17,3))
print("The probability of a PLAYER scoring BIRDE on hole 18 is ~%s" % round(p_bird_18,3))
The probability of a PLAYER scoring BIRDE on hole 15 is ~0.195
The probability of a PLAYER scoring BIRDE on hole 16 is ~0.13
The probability of a PLAYER scoring BIRDE on hole 17 is ~0.182
The probability of a PLAYER scoring BIRDE on hole 18 is ~0.286
## 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 (15-18) by the 2 golfers
- Enumrate all the possible combinations of 0, 1 or 2 BIRDIES being scored on holes 15-18.
- The probability that 0, 1 or 2 BIRDIES are scored by both golfers on holes 15-18 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 15
p_other = 1 - p_bird_15
prob = (p_bird_15,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 16
p_other = 1 - p_bird_16
prob = (p_bird_16,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 17
p_other = 1 - p_bird_17
prob = (p_bird_17,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 18
p_other = 1 - p_bird_18
prob = (p_bird_18,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 15 for 2 golfers and their respective probabilities are: %s" % a)
print("The number of possible birdies on hole 16 for 2 golfers and their respective probabilities are: %s" % b)
print("The number of possible birdies on hole 17 for 2 golfers and their respective probabilities are: %s" % c)
print("The number of possible birdies on hole 18 for 2 golfers and their respective probabilities are: %s" % d)
The number of possible birdies on hole 15 for 2 golfers and their respective probabilities are: {0: 0.65, 1: 0.31, 2: 0.04}
The number of possible birdies on hole 16 for 2 golfers and their respective probabilities are: {0: 0.76, 1: 0.23, 2: 0.02}
The number of possible birdies on hole 17 for 2 golfers and their respective probabilities are: {0: 0.67, 1: 0.3, 2: 0.03}
The number of possible birdies on hole 18 for 2 golfers and their respective probabilities are: {0: 0.51, 1: 0.41, 2: 0.08}
holes = ['15','16','17','18']
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()
15 | 16 | 17 | 18 | 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()
15 | 16 | 17 | 18 | p | |
---|---|---|---|---|---|
0 | 0.65 | 0.76 | 0.67 | 0.51 | 0.168800 |
1 | 0.65 | 0.76 | 0.67 | 0.41 | 0.135702 |
2 | 0.65 | 0.76 | 0.67 | 0.08 | 0.026478 |
3 | 0.65 | 0.76 | 0.30 | 0.51 | 0.075582 |
4 | 0.65 | 0.76 | 0.30 | 0.41 | 0.060762 |
p = round(probability['p'][birdies['total_birdies']<=num_birdies].sum(),3)
Solution
print("The proability that R. McIlroy AND J. Rahm record 2 or less BIRDIES on holes 15-18 is ~%s" % p)
print("The proability that R. McIlroy AND J. Rahm record 3 or more BIRDIES on holes 15-18 is ~%s" % round((1-p),2))
The proability that R. McIlroy AND J. Rahm record 2 or less BIRDIES on holes 15-18 is ~0.81
The proability that R. McIlroy AND J. Rahm record 3 or more BIRDIES on holes 15-18 is ~0.19