Skip to content
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

Consider adding this Baseball example in a notebook #5

Open
nabriis opened this issue Sep 25, 2022 · 0 comments
Open

Consider adding this Baseball example in a notebook #5

nabriis opened this issue Sep 25, 2022 · 0 comments

Comments

@nabriis
Copy link
Collaborator

nabriis commented Sep 25, 2022

import pandas as pd
DATA_URL = "https://raw.githubusercontent.com/fonnesbeck/probabilistic_python/master/data/"
spin_rate_data = pd.read_csv(DATA_URL + "savant_data.csv", parse_dates=["game_date"]).dropna(subset=["spin_rate", "game_date"])

day_ind, date = pd.factorize(spin_rate_data.game_date, sort=True)
spin_rate = spin_rate_data.spin_rate.values
day_ind = xp.tensor(day_ind)

#spin_rate_data.head()
#spin_rate_data.plot.scatter(x="game_date", y="spin_rate", figsize=(14,5), alpha=0.2)

mu = Gaussian(xp.ones(2)*2500, 100)
tau = Uniform(0, 181)
sigma = HalfGaussian(100)
r = lambda tau, mu: xp.where(day_ind < tau, mu[0], mu[1])
sr = LogGaussian(r, lambda sigma: sigma)

samples = sample(mu, tau, sigma, sr, Ns=500, Nb=500, sr=spin_rate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant