Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.12 KB | None | 0 0
  1. import numpy  as np
  2. import random
  3. Falcon_TD_rate = 0.202 #2017 0.237
  4. Falcon_FG_rate = 0.155 #2017 0.196
  5. Seahawks_TD_rate = 0.202 #2017 0.209
  6. Seahawks_FG_rate = 0.155 #2017 0.148
  7.  
  8. Seahawks_win_fake = 0
  9. Seahawks_win_FG = 0
  10. Falcon_win = 0
  11.  
  12. no_simulation = 100000
  13.  
  14. fake_FG_success_rate = 0.38
  15. FG_success_rate = 0.83
  16.  
  17.  
  18.  
  19. for i in range(no_simulation):
  20.  
  21.     for decision in range(2):
  22.         Falcon_point = 24
  23.         Seahawks_point = 17
  24.         if(decision == 0):
  25.             if(random.random() < fake_FG_success_rate):
  26.                 Seahawks_point += 7
  27.         elif(random.random() < FG_success_rate):
  28.                 Seahawks_point += 3
  29.         no_drive_seahawks = np.random.poisson(11.6/2+0.25)
  30.  
  31.         for drive in range(no_drive_seahawks):
  32.             rng_number = random.random()
  33.             if(rng_number < Seahawks_TD_rate): #Touchdown
  34.                 Seahawks_point += 7
  35.             elif(rng_number < Seahawks_TD_rate+Seahawks_FG_rate): #Field Goal
  36.                 Seahawks_point += 3
  37.             else:
  38.                 Seahawks_point += 0
  39.  
  40.         no_drive_falcon = np.random.poisson(11.6/2-0.25)
  41.         for drive in range(no_drive_falcon):
  42.             rng_number = random.random()
  43.             if(rng_number < Falcon_TD_rate): #Touchdown
  44.                 Falcon_point += 7
  45.             elif(rng_number < Falcon_TD_rate+Falcon_FG_rate): #Field Goal
  46.                 Falcon_point  += 3
  47.             else:
  48.                 Falcon_point  += 0
  49.  
  50.  
  51.         if(Falcon_point > Seahawks_point):
  52.             Falcon_win += 1
  53.         elif(Falcon_point < Seahawks_point):
  54.             if(decision == 0):
  55.                 Seahawks_win_fake += 1
  56.             elif(decision == 1):
  57.                 Seahawks_win_FG += 1
  58.         else: #OT
  59.             if(random.random() > 0.5):
  60.                 pass
  61.             else:
  62.                 if(decision == 0):
  63.                     Seahawks_win_fake += 1
  64.                 elif(decision == 1):
  65.                     Seahawks_win_FG += 1
  66.  
  67. print("Win rate after fake FG = %f" % (Seahawks_win_fake/float(no_simulation)))
  68. print("Win rate after FG = %f" % (Seahawks_win_FG/float(no_simulation)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement