MLB (Phillies @ Giants): How many EXTRA-BASE HITS will be recorded during Innings 5-8?
8:52PM
3 XBH or Fewer
4 XBH or More
Inputs To Solve
XBH per Game by Team (Phillies and Giants)
##### User Estimates #####
PHI_XperG = (215+17+149)/118
SFG_XperG = (236+21+126)/119
expected_total_Xs = PHI_XperG + SFG_XperG
print("Use %s + %s = %s as total expected XBH be recorded in the game." % (round(PHI_XperG,3),round(SFG_XperG,3),round(expected_total_Xs,3)))
Use 3.229 + 3.218 = 6.447 as total expected XBH be recorded in the game.
## Inputs Defined in the Problem
period_of_innings = 4
XBH = [0,1,2,3]
Method to Solve
- [1] Estimate lambda - expected arrival rate of XBH for 3 Innings (lambda_)
- [2] Use the Poisson Distribution to compute the probability of 0, 1, 2 or 3 XBH being recorded during Innings 5-8 (p_3orless)
## [1]
lambda_ = expected_total_Xs * period_of_innings / 9
print("lambda = the total expected RUNS SCORED over %s innings" % period_of_innings)
print("lambda = %s * %s / %s" % (round(expected_total_Xs,3),period_of_innings,9))
print("lambda ~ %s" % (round(lambda_,3)))
lambda = the total expected RUNS SCORED over 4 innings
lambda = 6.447 * 4 / 9
lambda ~ 2.865
## [2]
import math
str_ = ""
print("The probability of k events occurring in a Poisson interval = e^(-lambda) * (lambda^k)/k!")
print("where k = [0,1,2,3]")
print(' ')
p_3orless = 0
for i in XBH:
p_3orless += math.exp(-lambda_)*(lambda_**(i))/(math.factorial(i))
if(i<=2):
str_ += str(round(math.exp(-lambda_)*(lambda_**(i))/(math.factorial(i)),3)) + " + "
print("e^(-%s) * (%s^%s)/%s! + " % (round(lambda_,2),round(lambda_,2),(i),(i)))
else:
str_ += str(round(math.exp(-lambda_)*(lambda_**(i))/(math.factorial(i)),3))
print("e^(-%s) * (%s^%s)/%s!" % (round(lambda_,2),round(lambda_,2),(i),(i)))
print('')
print('p_3orless = ' + str_)
The probability of k events occurring in a Poisson interval = e^(-lambda) * (lambda^k)/k!
where k = [0,1,2,3]
e^(-2.87) * (2.87^0)/0! +
e^(-2.87) * (2.87^1)/1! +
e^(-2.87) * (2.87^2)/2! +
e^(-2.87) * (2.87^3)/3!
p_3orless = 0.057 + 0.163 + 0.234 + 0.223
Solution
print("The probability that 3 XBH or Fewer are recorded during Innings 5-8 is ~%s" % round(p_3orless,3))
The probability that 3 XBH or Fewer are recorded during Innings 5-8 is ~0.677
Posted on 8/12/2019