-
-
Save terrycojones/8f9f38d877ef570d0c4229a5547c9620 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pandas as pd | |
import pymc as pm | |
from pymc import HalfCauchy, Model, Normal, sample | |
print(f"Running on PyMC v{pm.__version__}") | |
RANDOM_SEED = 8927 | |
rng = np.random.default_rng(RANDOM_SEED) | |
size = 200 | |
true_intercept = 1 | |
true_slope = 2 | |
x = np.linspace(0, 1, size) | |
true_regression_line = true_intercept + true_slope * x | |
y = true_regression_line + rng.normal(scale=0.5, size=size) | |
data = pd.DataFrame(dict(x=x, y=y)) | |
with Model() as model: | |
sigma = HalfCauchy("sigma", beta=10) | |
intercept = Normal("Intercept", 0, sigma=20) | |
slope = Normal("slope", 0, sigma=20) | |
likelihood = Normal("y", mu=intercept + slope * x, sigma=sigma, observed=y) | |
idata = sample(3000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment