11.3 Multi-Dimensional Models
It is straightforward then to include more than one parameter and to do regression using this technique. For example, here is an example with some artificial data,
def linear(x,a,b):
return a*x+b
model=MCMCModel_Regression(x,y,linear,
a=Uniform(-10,10),
b=Uniform(0,100),
)

model.run_mcmc(500)
model.plot_chains()
plot(x,y,'o')
model.plot_predictions(xfit,color='g')

model.plot_distributions()

And we can look at best estimates, quartiles, and probability comparisons,
model.percentiles([5,50,95])
Show expected output
{'_sigma': array([ 0.97143798, 1.00744104, 1.0467333 ]),
'a': array([ 0.07063144, 0.24939562, 0.42523751]),
'b': array([ 39.88446461, 39.98633744, 40.09010139])}model.P('a>0')
Show expected output
0.98936000000000002Adapted from Statistical Inference for Everyone, by Brian Blais (Bryant University), licensed under CC BY-SA 4.0 (dual-licensed under the GNU FDL 1.2 or later; this adaptation uses the CC BY-SA grant). Changes were made; this adaptation is distributed under the same license. License: CC-BY-SA-4.0.