MLB (Cubs @ Cardinals): How many STRIKEOUTS will be recorded during Innings 1-3?
8:15 PM
5 or Fewer
6 or More
Inputs Needed to Solve
Starting Pitcher Strikeout per Out Rates
##### User Estimates #####
Dar_K_Rate = float(132)/(115*3)
Wain_K_Rate = float(103)/(98*3)
print("Yu Darvish's 2019 K per Out rate is ~%s" % round(Dar_K_Rate,3))
print("Adam Wainright's 2019 K per Out rate is ~%s" % round(Wain_K_Rate,3))
Yu Darvish's 2019 K per Out rate is ~0.383
Adam Wainright's 2019 K per Out rate is ~0.35
## Inputs Defined in the Problem
K_ = 5
Method to Solve
- Enumerate all possible combinations of STRIKEOUTS for both pitchers
- The probability that 0, 1, 2, 3, 4 or 5 STRIKEOUTS are recorded is the sum of the probabilities for all the outcomes where the total number of STRIKEOUTS is less than or equal to 5.
import numpy as np
import pandas as pd
p_K_dar = Dar_K_Rate
p_no_K_dar = 1 - p_K_dar
p_K_wain = Wain_K_Rate
p_no_K_wain = 1 - p_K_wain
prob_dar = (p_K_dar,p_no_K_dar)
prob_wain = (p_K_wain,p_no_K_wain)
K_grid = (1,0)
a = {}
y = np.array([(h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,z) for h in K_grid for i in K_grid for j in K_grid for k in K_grid
for l in K_grid for m in K_grid for n in K_grid for o in K_grid for p in K_grid for q in K_grid
for r in K_grid for s in K_grid for t in K_grid for u in K_grid for v in K_grid for w in K_grid
for x in K_grid for z in K_grid])
K = pd.DataFrame(y)
K['total_Ks'] = K.sum(axis=1)
x = np.array([(h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,y,z) for h in prob_wain for i in prob_wain for j in prob_wain for k in prob_dar
for l in prob_dar for m in prob_dar for n in prob_wain for o in prob_wain for p in prob_wain for q in prob_dar
for r in prob_dar for s in prob_dar for t in prob_wain for u in prob_wain for v in prob_wain for w in prob_dar
for y in prob_dar for z in prob_dar])
probability = pd.DataFrame(x)
probability['p'] = probability.product(axis=1)
for i in set(K.total_Ks):
a[i] = round(probability['p'][K['total_Ks']==i].sum(),2)
K.head()
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | total_Ks | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 18 |
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 17 |
2 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 17 |
3 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 0 | 16 |
4 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 | 17 |
probability.head()
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | p | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 1.397020e-08 |
1 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.617391 | 2.254282e-08 |
2 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.617391 | 0.382609 | 2.254282e-08 |
3 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.617391 | 0.617391 | 3.637591e-08 |
4 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.382609 | 0.382609 | 0.382609 | 0.35034 | 0.35034 | 0.35034 | 0.617391 | 0.382609 | 0.382609 | 2.254282e-08 |
print("The number of possible STRIKEOUTS in Innings 1-3 and their respective probabilities are: %s" % a)
The number of possible STRIKEOUTS in Innings 1-3 and their respective probabilities are: {0: 0.0, 1: 0.0, 2: 0.01, 3: 0.04, 4: 0.09, 5: 0.15, 6: 0.19, 7: 0.19, 8: 0.15, 9: 0.1, 10: 0.05, 11: 0.02, 12: 0.01, 13: 0.0, 14: 0.0, 15: 0.0, 16: 0.0, 17: 0.0, 18: 0.0}
p = round(probability['p'][K['total_Ks']<=K_].sum(),3)
Solution
print("The probability that 5 or FEWER STRIKOUTS are recorded in Innings 1-3 is ~%s" % p)
The probability that 5 or FEWER STRIKOUTS are recorded in Innings 1-3 is ~0.302
Posted on 7/30/2019