MLB (Tigers @ Astros): Which TEAM will SCORE FIRST?
8:10PM
Tigers Score First
Astros Score First
Inputs To Solve
Distribution of Runs Scored per Inning MLB
##### User Estimates #####
p_NoRuns = .72
# the probabilty an mlb team scores zero runs in an inning
Method to Solve
- [1] Use the Monte Carlo Method and simulate 9999 games between the Tigers and the Astros, keeping track of which team scores first.
- [2] The ratio of times the Tigers score first is an estimate of the probability the Tigers will score first (p_TIGERS) in the game.
## [1]
import numpy as np
iterations = 9999
_1st_count = 0
print("The team that scores first in the first 10 simulations are:")
print('')
for i in range(iterations):
score = False
while not score:
flip = np.random.choice(['Runs','None'],1,p=[1-p_NoRuns,p_NoRuns])
#print(flip)
if flip == 'Runs':
score = True
team = 'Tigers'
else:
flip = np.random.choice(['Runs','None'],1,p=[1-p_NoRuns,p_NoRuns])
if flip == 'Runs':
score = True
team = 'Astros'
if team == 'Tigers':
_1st_count += 1
if i < 10:
print(team)
The team that scores first in the first 10 simulations are:
Tigers
Astros
Tigers
Tigers
Astros
Astros
Tigers
Tigers
Astros
Tigers
## [2]
p_TIGERS = _1st_count/iterations
Solution
print("The probability the TIGERS will SCORE FIRST is ~%s" % round(p_TIGERS,3))
The probability the TIGERS will SCORE FIRST is ~0.583
Info
download markdown file
email: krellabsinc@gmail.com
twitter: @KRELLabs
import sys
print(sys.version)
3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)]
Posted on 8/20/2019