g1 = rename(gaussian, ['x','mu1','sigma']) g2 = rename(gaussian, ['x','mu2','sigma']) print describe(g1) print describe(g2) # <codecell> #make two likelihood and them up ulh1 = UnbinnedLH(g1,data1) ulh2 = UnbinnedLH(g2,data2) sim = SimultaneousFit(ulh1,ulh2) print describe(sim) #note the sigma merge # <codecell> sim.draw(args=(0.5, 1.5, 10.5)) # <codecell> m = Minuit(sim, mu1=0.5, sigma=1.5, mu2=10.5) # <codecell> m.migrad(); # <codecell> sim.show(m) # <markdowncell>
from matplotlib import pyplot as plt from numpy.random import randn, seed seed(0) width = 2. data1 = randn(1000)*width + 1 data2 = randn(1000)*width + 2 #two gaussian with shared width pdf1 = rename(gaussian, ('x', 'mu_1', 'sigma')) pdf2 = rename(gaussian, ('x', 'mu_2', 'sigma')) lh1 = UnbinnedLH(pdf1, data1) lh2 = UnbinnedLH(pdf2, data2) simlh = SimultaneousFit(lh1, lh2) m = Minuit(simlh, mu_1=1.2, mu_2=2.2, sigma=1.5) plt.figure(figsize=(8, 3)) plt.subplot(211) simlh.draw(m) plt.suptitle('Before') m.migrad() # fit plt.figure(figsize=(8, 3)) plt.subplot(212) simlh.draw(m) plt.suptitle('After')
from matplotlib import pyplot as plt from numpy.random import randn, seed seed(0) width = 2. data1 = randn(1000) * width + 1 data2 = randn(1000) * width + 2 #two gaussian with shared width pdf1 = rename(gaussian, ('x', 'mu_1', 'sigma')) pdf2 = rename(gaussian, ('x', 'mu_2', 'sigma')) lh1 = UnbinnedLH(pdf1, data1) lh2 = UnbinnedLH(pdf2, data2) simlh = SimultaneousFit(lh1, lh2) m = Minuit(simlh, mu_1=1.2, mu_2=2.2, sigma=1.5) plt.figure(figsize=(8, 3)) plt.subplot(211) simlh.draw(m) plt.suptitle('Before') m.migrad() # fit plt.figure(figsize=(8, 3)) plt.subplot(212) simlh.draw(m) plt.suptitle('After')