ROOT::Fit::UnBinData. example is not working

Dear all,

I would like to carry out an unbinned likelihood fit. I think I should use the class ROOT::Fit::UnBinData,
https://root.cern.ch/doc/v608/classROOT_1_1Fit_1_1UnBinData.html

but it is not clear to me how to do it. Please, find attached of a tentative example (not working).
unbinnedTest.cxx (1.1 KB)

Thank you for you time.

Regards,
Alvaro.


ROOT 6.04
CentOS 7.1, gcc4.8


Hi,

Your example will not work, because you are missing two things:

  • your fitting function must be normalised in the given range. So a simple polynomial like the one you are giving is not correct
  • the initial fit parameters must be set. You can do this by calling
    Fitter.Config().SetParamSettings( n, initialParams);

Look at the correct example using a normalised gaussian as function. You can do with a line fit, but you will have a single parameter (the shape one)

Best Regards

Lorenzo

Corrected macro: unbinnedTest.cxx (1.2 KB)

Hello,

wow, thank you for your quick reply!

In general, does it means that I would need to normalise the model function* inside the fitting function** before evaluating it?

double fitFunction( x, par )
{
integralFactor = integralFunction( par, xlow, xhigh );
value =  function( x , par);
return value/integralFactor ;
}

Thank you very much for your time

Regards,
atd
*model function = the function with physical meaning
** fitting function = the function for the ROOT fitter

Yes, this is correct ! You might need also to fix the normalisation parameter, since a simple unbinned likelihood fit does not fit the normalisation. If you leave it floating, you might have problem in convergence in Minuit since some parameters will be 100% correlated

Lorenzo

Hello,

ouch, I did not think about that issue :confused:

So, a more convenient way should consist in removing one parameter from the fit, for example the last one, par(n), and computing this parameter inside the function so that the integral of the function is always 1.

double fitFunction( x, par(0)... par(n-1) )
{

par(n) = helperFunction( par );

value =  function( x , par(0) ... par(n) );

return value ;
}

Is this correct?

Thank you very much for your time.

Regards,
atd

Yes, this is correct !

Lorenzo

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.