Re: different fit behaviour in ROOT and ROOFIT

From: Lorenzo Moneta <Lorenzo.Moneta_at_cern.ch>
Date: Mon, 5 Sep 2011 08:06:56 +0000


Dear Roberta,

 I have investigate this further and I found the reason for the difference. It is due how the binned likelihood fits are implemented in ROOT and ROOFIT. When implementing the likelihood both ROOT and ROOFIT approximates the expected number of events for each bin by using the function value at the center for the bin, instead of using the integral. The formula in ROOT is the one described in the PDG (equation 33.12 in http://pdg.lbl.gov/2011/reviews/rpp2011-rev-statistics.pdf ). ROOFIT uses a similar formula, but it replaces the sum of the expected bin content by its total value. By doing this, the approximation of using the function value at the center of the bin instead of the integral is not used. This enhances the bias with respect to ROOT, where the approximation is always used. Since the two terms containing the expected bin entries (nu(i) in 33.12) have opposite sign, in the formula used in ROOT, the bias is reduced with respect to ROOFIT. I could reproduce this by fitting a toy example with exponential backgrounds plus a gaussian signal. In this cases by using the function value at the center of the bin one overestimates the expected bin entries and then your fitted values of number of entries will be biased to lower values, like in your histogram.

If you want to be safe, use then the option "I" when fitting in ROOT where the integral of the fitted function in the bin is used for computing the expected bin content. Unfortunately RooFIt does not provide this possibility in binned fits. I will report this problem to the RooFit author and ask him also to implement the option of using the integral for each bin.

  Thank you for reporting this problem,

  Lorenzo
On Sep 2, 2011, at 10:19 AM, Roberta Arnaldi wrote:

> Dear Lorenzo,
>
> thanks a lot for having looked to my problem and for spotting the "guilty" fitter :)
> Unfortunately, the discrepancy between Root and Roofit is something which I always observe, while performing fits to the invariant mass spectra, i.e. it is not something related to the specific histogram I had
> attached to the mail...
> It's really a pity to give up the use of Roofit, since (before discovering the discrepancy with ROOT) I had the impression that the fit stability and the speed where really very good!
>
> ...in my opinion, it would be important to understand why roofit seems not to behave properly, since it is now widely used in the LHC experiments!
> Please, let me know if there are any news!
>
> Ciao and thanks again!
>
> Roberta
>
>
>
> On Thu, 1 Sep 2011, Lorenzo Moneta wrote:
>

>> Hi Roberta,
>> 
>> Sorry for having looking late into this problem. I have investigated more, it required me some time and I have concluded that the RooFIt result is probably not right, while the ROOT is. The reason for the difference is still to be found.
>> I have been using the same pdf definition of RooFit, by transforming the pdf in a TF1 and then fitted using ROOT and I get consistent results
>> with your TestROOT macro. In particular if I use as input the RooFit parameters , I get clearly a smaller value of the likelihood  function
>> (meaning that is not optimal).
>> Furthermore, when using a chi2 fit method (not maximum likelihood) which should work perfectly fine and give the same results in your case since the histogram bin errors are gaussian I get again the same result. ( NJPSI ~ 2200)
>> 
>> So, something is probably wrong in the RooFIt fitting, it could be also a numerical problem not dealt correctly in the likelihood calculation in RooFit.
>> 
>> I attach my macro, which uses the RooFit to build the model but  ROOT for fitting
>> 
>> Cheers,
>> 
>> Lorenzo
>> 
>> 
Received on Mon Sep 05 2011 - 10:07:04 CEST

This archive was generated by hypermail 2.2.0 : Mon Sep 05 2011 - 11:50:01 CEST