Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import random
- Falcon_TD_rate = 0.202 #2017 0.237
- Falcon_FG_rate = 0.155 #2017 0.196
- Seahawks_TD_rate = 0.202 #2017 0.209
- Seahawks_FG_rate = 0.155 #2017 0.148
- Seahawks_win_fake = 0
- Seahawks_win_FG = 0
- Falcon_win = 0
- no_simulation = 100000
- fake_FG_success_rate = 0.38
- FG_success_rate = 0.83
- for i in range(no_simulation):
- for decision in range(2):
- Falcon_point = 24
- Seahawks_point = 17
- if(decision == 0):
- if(random.random() < fake_FG_success_rate):
- Seahawks_point += 7
- elif(random.random() < FG_success_rate):
- Seahawks_point += 3
- no_drive_seahawks = np.random.poisson(11.6/2+0.25)
- for drive in range(no_drive_seahawks):
- rng_number = random.random()
- if(rng_number < Seahawks_TD_rate): #Touchdown
- Seahawks_point += 7
- elif(rng_number < Seahawks_TD_rate+Seahawks_FG_rate): #Field Goal
- Seahawks_point += 3
- else:
- Seahawks_point += 0
- no_drive_falcon = np.random.poisson(11.6/2-0.25)
- for drive in range(no_drive_falcon):
- rng_number = random.random()
- if(rng_number < Falcon_TD_rate): #Touchdown
- Falcon_point += 7
- elif(rng_number < Falcon_TD_rate+Falcon_FG_rate): #Field Goal
- Falcon_point += 3
- else:
- Falcon_point += 0
- if(Falcon_point > Seahawks_point):
- Falcon_win += 1
- elif(Falcon_point < Seahawks_point):
- if(decision == 0):
- Seahawks_win_fake += 1
- elif(decision == 1):
- Seahawks_win_FG += 1
- else: #OT
- if(random.random() > 0.5):
- pass
- else:
- if(decision == 0):
- Seahawks_win_fake += 1
- elif(decision == 1):
- Seahawks_win_FG += 1
- print("Win rate after fake FG = %f" % (Seahawks_win_fake/float(no_simulation)))
- print("Win rate after FG = %f" % (Seahawks_win_FG/float(no_simulation)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement