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,

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.


ROOT 6.04
CentOS 7.1, gcc4.8


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


Corrected macro: unbinnedTest.cxx (1.2 KB)


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

*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



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.


Yes, this is correct !


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