# Using (G)MM to infer coefficients of nonlinear model

Hi all,

I have been trying to fit a multi-variate Gaussian mixture model to my nonlinear model to get posterior on two model parameters. However, I think I have fundamentally misunderstood something. What I think I should be doing is this:

y = MODEL(x,theta)

where

• x is a set of 50 vector variables that will not change
• theta (2x1) are the two parameters I would like to get posterior for
• y is some scalar quantity that summarizes the simulation result

So I’m modeling this as y ~ GMM(MODEL(x,theta),sigma)

At this point it’s still univariant and it runs for k=1 when I add the theta vars. Or I can also run k>1 when I just try to fit the distribution for given thetas. But when I want to have k>1 (as the distribution is bimonal at least) with prior on the Thetas it doesn’t run. I assume I have to somehow assign the array of mus to different components? Or how do I do this? What am I missing here?

``````
with pm.Model() as model_b3:
k = 1
theta1 = pm.Uniform('theta1', 100,2000)  # Prior for our cooling coefficient
theta2 = pm.Uniform('theta2', 100,2000)  # Prior for our cooling coefficient

# mu      = pm.Normal("mu",0,2,shape=k,transform=pm.distributions.transforms.ordered,initval=np.sort(np.random.normal(0,2,k)))
mu = runSimPymcAll(theta1,theta2)
sigma   = pm.InverseGamma("sigma", 2,1,shape=k)
weights = pm.Dirichlet("w", np.ones(k))

components = pm.Normal.dist(mu=mu,sigma=sigma,shape=k)

TbPred = pm.Mixture("TbPred",w=weights,comp_dists=components,observed=Yscaled)

trace_b2 = pm.sample(2000, tune=100,cores=6)  # Explore and Sample the Parameter Space!
``````