ATP Dubai Championship - 2nd Rd (#1 Novak Djokovic v. Philipp Kohlschreiber): Will Kohlschreiber WIN 4+ GAMES in ANY SET?
10:10 AM
Yes: Kohlschreiber wins 4+ games in at least 1 set
No: Kohlschreiber doesn’t win 4+ games in any set
Inputs Needed To Solve
Service Games Won %
Djokovic and Kohlschreiber
##### User Estimates #####
ND_SRV_Wperct = .86
Pos_SRV_Wperct = .82
Method To Solve
- [1] Use Monte Carlo Simulation and simulate 9999 Sets between Djokovic and Kohlschreiber using their respective Service Games Won Percent
- [2] The ratio of Simulated MATCHES that Kohlschreiber wins 4 or more games to the total number of Simulations is an estimate of the probability of Kohlschreiber winning 4+ GAMES in ANY SET (p_4)
## [1]
import numpy as np
def sim_game(server,player1,player2):
if server:
serve = np.random.choice([1,0],1,p=[player1,1-player1])
if serve == 1:
ans = '1'
else:
ans = '0'
else:
serve = np.random.choice([1,0],1,p=[player2,1-player2])
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(player1,player2):
winner = ''
server = True
set_over_ = False
four_ = 0
while not set_over_:
game = sim_game(server,player1,player2)
winner += str(game)
server = not server
set_over_ = set_over(winner)
if winner.count('0') >= 4:
four_ = 1
return [four_,winner]
iterations = 9999
four_count = 0
for i in range(iterations):
p1 = 0
p2 = 0
while p1 < 2 and p2 < 2:
x = sim_set(Med_SRV_Wperct,Pos_SRV_Wperct)
if x[0] == 1:
four_count += 1
break
else:
if x[1].count('1') >= 6:
p1 += 1
if x[0] == 1:
four_count += 1
break
else:
p2 +=1
if x[0] == 1:
four_count += 1
break
## [2]
p_4 = four_count/iterations
Solution
print("The probability Kohlschreiber will WIN 4+ GAMES in ANY SET is ~%s" % round(p_4,3))
The probability Kohlschreiber will WIN 4+ GAMES in ANY SET is ~0.794
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 2/26/2020