Skip to content

Instantly share code, notes, and snippets.

@jdmoore7
Created December 8, 2021 17:33
Show Gist options
  • Save jdmoore7/103f3fa31c13108281eea56b3d2d5a29 to your computer and use it in GitHub Desktop.
Save jdmoore7/103f3fa31c13108281eea56b3d2d5a29 to your computer and use it in GitHub Desktop.
Bayesian linear model
import pymc3 as pm
with pm.Model() as model:
m = pm.Normal('m',mu=0, sd=2)
b = pm.Normal('b',mu=0, sd=2)
s = pm.Exponential('s',lam=1)
y_hat = pm.math.dot(m, X) + b
lik = pm.Normal('lik', mu=y_hat, observed=pm.math.log(Y), sigma=s)
trace = pm.sample(chains=4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment