Maximum likelihood fit of count histogram with variable bin

Hello,

I would like to perform a maximum likelihood fit (assuming Poisson statistics) of count histograms with variable bin width. Calling Sumw2, and using Scale(1., “width”) to normalize the content of each bin to the bin’s width, I get correct results when performing a chi2 fit - provided that the fit option “I” is used. However, for maximum likelihood fits I have not yet been successful, neither with Root versions 5.30 or 5.34. Is there a combination of fit options that would make Root take into account correctly the actual number of counts in each bin and at the same time use the “I” option in combination with fit options “L” or “WL”? During the fit, the actual number of counts could be derived from the known bin content and the bin width. However, in my attempts so far, my impression was that instead of the actual number of counts in each bin the bin content after normalization to the bin width is used.

Thank you very much for any advice,

Georg

Hi,

It is true that when fitting variable bin histograms you need first to scale the histogram using the bin width (calling Scale(1., “width”) and Sumw2).
We should probably display and also fit automatically histograms scaling them by the bin width. If we just do in the fit and not in the histogram, the fitted function will be correct but the data points will be wrongly displayed.
If you want to to a likelihood fit, you should use the option “W” in order to get the right fit errors, because you have scaled the histogram.
So the correct option to use in your case is “WLI”. Below is a small code example

   double x[] = { -5,-3,-2,-1.5,-1,-0.7, -0.5, -0.3, -0.1., 0., 0.1, 0.3, 0.5, 0.7, 1, 1.5, 2, 3, 5};

   TH1D *h1 = new TH1D("h1","h1",18,x);

   h1->FillRandom("gaus",1000);

   h1->Sumw2();
   h1->Scale(1,"width");

   h1->Fit("gaus","WLI");  // likelihood fit 
   //h1->Fit("gaus","I");    // chi2 fit

Note that the option “WL” is available only from 5.34.

Best Regards

Lorenzo