Fitting a spectra of gaussians

You shouldn’t be using NormalMixture for this kind of data. In short, if you plot the histogram of the data and it looks like a mixture of gaussian, then you should use NormalMixture. Otherwise, what you are trying to do is estimating some parameter of a nonlinear function.

What you are doing is on the right track, trying to implement a better mixture gaussian function should help:

from pymc3.math import logsumexp
import theano.tensor as tt
def mixture_density(w, mu, sd, x):
    logp = tt.log(w) + pm.Normal.dist(mu, sd).logp(x)
    return tt.sum(tt.exp(logp))

w, mu, sd should be theano vector. So you will need to do for example: w = tt.stack([amp, amp2])