Model with extended likelihood function using pm.DensityDist or pm.Potential

Thanks, junpenglao.
I found those examples helpful, but I believe they have slightly different goals than the unbinned extended likelihood example of this thread.

  • The “Fitting a spectra of gaussians” post essentially uses maximum likelihood (ML) with binned data.
  • Interpolated PDF in a Mixture Model” uses ML with unbinned data via pm.Mixture, but does not use an extended likelihood term. Because the pm.Mixture environment constrains the sum of the proposed weights to be 1 (pymc3/mixture.py::logp()), if one wanted to overlay the result of this model atop the observed spectrum, the result would need to be scaled by the integral of the observed spectrum.

I too seek to use unbinned ML, but rather than scaling the model by the spectrum integral after-the-fact, I wish to consider the spectrum integral (size in my code) as a parameter to be estimated. I was trying to accomplish this by incorporating an extended likelihood term, but was having trouble getting things to work.