scikit-hep / probfit

Cost function builder. For fitting distributions.
http://probfit.readthedocs.io/
MIT License
51 stars 30 forks source link

Binned histogram template fits appear to use always 199 bins. #99

Closed Norhk closed 5 years ago

Norhk commented 5 years ago

Hi, thank you for your awesome tool. I'm doing what the title says. Here's an example:

nbins = 10 # and len(bin_edges)==10
psig = HistogramPdf(hsig, bin_edges)
pbkg = HistogramPdf(hbkg, bin_edges) 
epsig = Extended(psig, extname = 'Signal')
epbkg = Extended(pbkg, extname = 'Background')
pdf = AddPdf(epsig, epbkg)
blh = BinnedLH(pdf, data, bins = nbins, bound = bound, extended = True) 
m = Minuit(blh, Signal = sum(hsig), Background = sum(hbkg), error_Signal = np.sqrt(sum(hsig)), e 
error_Background = np.sqrt(sum(hbkg)))
m.migrad()
m.minos()
m.hesse()
((data_edges, datay), (errorp, errorm), (total_pdf_x, total_pdf_y), parts) = blh.draw(m, parts = True)

Now, whatever I put for the number of bins len(data_edges)==nbins, while len(total_pdf_x)==199 (same for all the elements of parts). The probfit native plot shows the correct number of bins. Also I just noticed that the number of unique values in total_pdf_y != 10 as I would expect if this is intended behaviour... Version probfit-1.1.0

Norhk commented 5 years ago

Never mind, mistake I made. It seems the draw functions has a parameter it oversaw.