Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
df_mixed = {'mass': np.append(np.random.random_sample(1000)*7 - 3.5, np.random.normal(0, 0.5, 1000))}
df_mixed = pd.DataFrame(df_mixed)
df_bkg = {'mass': np.random.random_sample(2000)*7 - 3.5}
df_bkg = pd.DataFrame(df_bkg)
x = ROOT.RooRealVar('mass', 'M', 0, -3, 3, 'GeV')
pdf_sig = Gauss(x, mean=(-1, 1))
pdf_bkg = Chebychev(x, n=1)
pdf = pdf_sig + pdf_bkg
sf = SimFit(pdf, pdf_bkg)
sf.use_extended = True # bug
sf.use_minos = True
sf.fit([(pdf, df_mixed), (pdf_bkg, df_bkg)])
#pdf_bkg.plot('simultaneous_fit_bkg.pdf', df_bkg)
pdf.plot('simultaneous_fit.pdf',
df_mixed,
nbins=20,
extra_info=[["Legend"], ["More Legend"], ['#mu', *pdf_sig.get('mean')], ['#sigma', *pdf_sig.get('sigma')]])
pdf.get()