TF1 Integral -> inf


I am having troubles in performing the integral of a function. I am testing a set of functions to fit my distribution,
with 2,3,4 or 5 parameters using the Fisher test. To evaluate which function is the right one I need to compute the integral of the function in a certain range, which is a bin range.

Now, the issue is that I randomly get errors while integrating, independently if I am performing the fit beforehand, or if I am passing a defined function.
This is the error that I get:

Error in <GSLError>: Error 21 in qags.c at 553 : bad integrand behavior found in the integration interval
Warning in <TF1::IntegralOneDim>: Error found in integrating function f1 in [1800.000000,1900.000000] using AdaptiveSingular. Result = inf +/- nan  - status = 21
Integral: Function Parameters = { p0=4.58732e-28 p1=87.1005 p2=42.0679 p3=6.46168 }

This is true also with two parameters. Also, sometimes, it does the integral but it is nan (without showing any error ), other times the integral is correctly computed.

This is the function that I am using:

(par[0]*pow((1+(x[0]/(13000))),par[1]) * pow((x[0]/(13000)),(-par[2] - log(x[0]/(13000))*(par[3] + par[4]*log((x[0]/(13000)))))))

It happens something similar using a different function, such as a simple polinomial:

 (par[0]*x[0]+ par[1]*pow(x[0],2) + par[2]*pow(x[0],3) + par[3]*pow(x[0],4) + par[4]*pow(x[0],5))

In this case I do not get the error, but the value of the integral is too large (order of magnitudes higher than expected).

This is how I am defining the function:

Double_t func(Double_t *x, Double_t *par)
   return (par[0]*pow((1+(x[0]/(13000))),par[1]) * pow((x[0]/(13000)),(-par[2] - log(x[0]/(13000))*(par[3] + par[4]*log((x[0]/(13000)))))));

And this is how I use it:

 TF1 *f1;
  f1 = new TF1("f1",func,range_min,range_max,par);

I set the parameters and then I use the method Integral to get integral value.

Can you, please, help me in solving this problem? Thank you very much,


ROOT Version: 6.06/09
Platform: Not Provided
Compiler: Not Provided

for what concerns the first function seems the error is due to the integrating the function where diverges (why x is divideby 13000? )

Regarding the integral with the polynomial function have you multiplied the function for your bin width?

Moreover if you can provide a reproducer it will be easier to help.


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