Tweaking the ROOT fitting function


I have used ROOT and QTiplot to fit the same data set and I have found different results. I found out that the parameters fitted by ROOT were not optimal. Are there any tweaks that I could adjust to improve the fitting in ROOT?

Below is the code I used, I appreciate any comments and suggestions.

void fittings (char* file)

  TGraphErrors* gd = new TGraphErrors (file);
  TF1  *f1bi  = new TF1("bimolecular","[0]/(pow([1]/x,[2])+1)", 0, 15);
  f1bi->SetParameters(1., 13,0.8);
  gd->Fit (f1bi,  "RF");

  cout << "The reduced ChiĀ² is " << f1bi ->GetChisquare()/f1bi->GetNDF() << endl;

[url]Tolerance for TH1::Fit() interface
[url]Changes in default Minuit2 behavior between root 5.28 / 5.30
Numerical Minimization

Thanks, but it did not help.
I checked all links and materials about it. I also run several example codes from the tutorial folder to understand how the minimizer works. I foound out that the following lines may have some impact on the Minuit2 but not in the Minuit


Strangely, everything other than the default parameters (including the Minuit choice over Minuit2) were worse.
I realize that the function I am trying to fit is challenging (f(x) = a/((b/x)^c+1)) but I expected that Minuit was able to fit the best parameters.

Any other advice?


Is your graph having error in X? Maybe these are not correct and not included in the other packages.
Otherwise please post the root file with the TGraphError object, so we can loo, at it

Best Regards


Hi Lorenzo,

The errors in X have neglible effect in the dataset I am working on. For the Minuit results with errors in X and Y I got

  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  p0           1.13763e+00   8.51748e-02   6.70312e-06   1.53132e-03
   2  p1           1.17319e+01   1.93265e+00   1.18619e-04  -1.13628e-04
   3  p2           8.55609e-01   2.64470e-02   5.38305e-06  -3.73964e-03

While for the same settings but errors only in Y I got these parameters

  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  p0           1.13544e+00   8.33254e-02   6.68515e-06  -7.03141e-03
   2  p1           1.16820e+01   1.88393e+00   1.17572e-04  -1.30154e-04
   3  p2           8.56290e-01   2.58683e-02   5.32436e-06  -3.69521e-03

However I was expecting to have
p0 = 1.2480995824280e+00 +/- 7.4807803504031e-02
p1 = 1.4539488049510e+01 +/- 2.0257945985255e+00
p2 = 8.1946939644770e-01 +/- 2.3876243155693e-02

This is the dataset I am working on

0	0	0
0.926	0.1150838325343	0.0007054888079979
1.852	0.1983710834188	0.001088253083328
3.704	0.3100125958307	0.001631037596244
5.556	0.3888950010415	0.001402720011703
7.408	0.4548426604148	0.002544775444051
11.112	0.553191696933	0.002448489977949
14.816	0.632009149	0.002911425192782

And the only modification I made to the code above is that I dropped the X errors and replaced the TGraphErrors line by:

TGraphErrors* gd = new TGraphErrors (file, "%lg %lg %lg");

I did notice that the results are quite sensitive to the Y errors. If I reduce the errors in Y I get different results; with narrow error bars I get closer (but not the same) numbers to what I expect. I do understand that the minimizer should take the errors into account, however it seems to me that the minimizer is giving too much weigth for the errors.