Women’s US Open - 1st Rd (#4 Simona Halep v. Nicole Gibbs): How many GAMES will S. Halep WIN?
1:30PM
12 Games
Any Other Number
Inputs Needed To Solve
Service Games Won %
Simona Halep
Nicole Gibbs
##### User Estimates #####
SH_SRV_Wperct = .82
NG_SRV_Wperct = .45
## Inputs Defined in the Problem
games_won = 12
Method To Solve
- [1] Simulate 9999 Sets between Simona Halep and Nicole Gibbs their respective Service Games Won Percent
- [2] The ratio of Simulated Matches where Simona Halep wins exactly 12 games to the total number of Simulations is an estimate of the probability she wins 12 Games (p_12) based on the Monte Carlo Method.
## [1]
import numpy as np
def sim_game(server,perct1,perct2):
if server:
serve = np.random.choice([1,0],1,p=[perct1,1-perct1])
if serve == 1:
ans = '1'
else:
ans = '0'
else:
serve = np.random.choice([1,0],1,p=[perct2,1-perct2])
if serve == 1:
ans = '0'
else:
ans = '1'
return ans
def set_over(winner):
set_over = False
if winner.count('1') >= 7:
set_over = True
if winner.count('0') >= 7:
set_over = True
if winner.count('1') >=6 and winner.count('0') < 5:
set_over = True
if winner.count('0') >=6 and winner.count('1') < 5:
set_over = True
if winner.count('0') == 6 and winner.count('1') == 6:
set_over = True
return set_over
def sim_set(perct1,perct2):
winner = ''
server = True
set_over_ = False
while not set_over_:
game = sim_game(server,perct1,perct2)
winner += str(game)
server = not server
set_over_ = set_over(winner)
return winner
## [2]
iterations = 999
_12_games = 0
#H = 0
for i in range(iterations):
SH = 0
NG = 0
total_games = 0
while SH < 2 and NG < 2:
winner = (sim_set(SH_SRV_Wperct,NG_SRV_Wperct))
if winner.count('1') > winner.count('0'):
SH += 1
else:
NG += 1
total_games += winner.count('1')
if total_games == games_won:
_12_games += 1
if i <10:
print(total_games)
#if winner.count('1') > winner.count('0'):
# H += 1
p_12 = _12_games/iterations
12
12
12
18
12
12
12
12
12
12
Solution
print("The probability S. Halep WINS 12 Games is ~%s" % round(p_12,3))
The probability S. Halep WINS 12 Games is ~0.712
Info
download md 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/27/2019