When I try to do the following, I get this error with 5.22, and I don’t remember this issue previously (ROOT ~5.21?). ROOT was compiled with: ./configure --enable-mathmore --enable-minuit2 --enable-gsl-shared

[code]In [1]: import ROOT

In [2]: f = ROOT.TFile(“broken.root”)

In [3]: thetaD = ROOT.TF1( “thetaD”, “[1]*(1+x^2+[0]*x)”, -1, 1 ); thetaD.SetParameters( 0, 1 )

In [4]: f.h.Fit(thetaD,“LL I”)[/code]
When I do this, I just expect the fit output, but instead I get the following error hundreds of times, followed by the fit output:

Error in <GSLError>: Error 5 in qag.c at 261 : could not integrate function

Any ideas what is wrong?



the problem appears because some of the fit parameter gets crazy values
(nan). This is due because the fitting function is evaluated in region where this is negative and this is not possible in a likelihood fit.

A protection has been now added to the fitting to avoid this condition, however you should use a better fit function to fit your data.
Thank you for reporting this,

Best Regards


Will calling SetParLimits() such that the function cannot go negative help?

Yes, you can set the parameter limits or restrict eventually the fitting range to avoid that the function is evaluated as negative on the given bins.
In your particular case, the function definition you are providing is far from optimal. I would try with a different function, maybe using different type of polynomials.


I don’t understand in what sense it is not optimal? Can you suggest an improved thing to fit to, and why?

Are you referring to the fit to this particular data, or just the definition of the function?

I am just referring to fitting your histogram data with your function ( a simple parabola). The fit converges, but to values very far away from the data.


This is a feature of the ML fit. For this particular case, the fit gets the correct value of [0], even though it does not describe the data in bins exactly. (I know it’s a “bad-looking” fit, but I have done independent checks that it definitely does give the correct value).