-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add EWM method for 3PAT averaging #1
base: master
Are you sure you want to change the base?
Conversation
|
||
fg3m_s = [] | ||
#simulate n_simulations games | ||
for _ in trange(n_simulated_games, desc=f'Simulating 3PM outcomes for {player_name} vs {opponent}...'): | ||
|
||
#simulate FGA | ||
fga_i = np.random.poisson(np.random.normal(fga_per_game_est_mean, fga_per_game_est_std)) | ||
fga_i = np.random.poisson(max(np.random.normal(fga_per_game_est_mean, fga_per_game_est_std),0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So above you're not actually bootstrapping (for ema) so I don't think it's fair to draw from a normal distribution to input into the poisson. In fact I think this may be skewing the results for simulations quite a bit since the rolling std should be much larger than std of the bootstrapped emas. I could be wrong on that second part though.
fga_per_game_est_std = np.std(fga_per_game_est) | ||
elif fga_method == 'ewm': | ||
fga_per_game_est_mean = fga_per_game_data['SHOT_ATTEMPTED_FLAG'].ewm(span = len(fga_per_game_data)).mean().values[-1] | ||
fga_per_game_est_std = fga_per_game_data['SHOT_ATTEMPTED_FLAG'].ewm(span = len(fga_per_game_data)).std().values[-1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No bootstrapping is getting done here, won't be able to compress into a list comprehension but I think we can write a for loop to do it:
eg.
bootstrapped_emas = []
for _ in range(bootstrap_samples):
fga_boot = np.random.choice(fga_per_game_array, size=len(fga_per_game_array), replace=True)
fga_boot_ema = pd.ewma(fga_boot, span=len(fga_boot)).mean()[-1]
bootstrapped_emas.append(fga_boot_ema)
fga_per_game_est_mean = np.mean(bootstrapped_means)
fga_per_game_est_std = np.std(bootstrapped_means)
I've never actually done this before and I'd like to actually examine the distribution here in a notebook or something. Since EMA is dependent on the ordering I'm not sure this is valid, but I think it does work (mentioned this point earlier)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually having messed around with this in a notebook i dont think it does work. ordering does matter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not bootstrapping for ema. Left comments on the code below
No description provided.