Created
January 13, 2017 17:33
-
-
Save jcbozonier/315b47efcc3f0d13ffaf6c59b3ead1ca to your computer and use it in GitHub Desktop.
Pymc3 approach
This file contains hidden or 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
%matplotlib inline | |
import pymc3 as pm | |
with pm.Model() as model: | |
_a = pm.Uniform('a', lower=-10, upper=0) | |
_h = pm.Uniform('h', lower=4, upper=12) | |
_k = pm.Uniform('k', lower=18000, upper=30000) | |
_sigma = pm.Uniform('sigma', lower=5, upper=25) | |
predicted_y = _a * (x_data - _h)**2 + _k | |
prediction_error = observed_y - predicted_y | |
y_probability = pm.Normal('y_probability', mu=0, observed=prediction_error, sd=_sigma) | |
start = pm.find_MAP() # Find starting value by optimization | |
step = pm.NUTS(scaling=start) # Instantiate MCMC sampling algorithm | |
trace = pm.sample(25000, step, start=start) | |
pm.traceplot(trace) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment