Home | News | Documentation | Download

TGraphAsymm x-Errors in pol fit?



I am trying to fit a TGraphAsymmErrors with a pol1 function.
Both x and y asymmetric uncertainties are needed.
It seems I get the same results no matter the x errors are large or small. The fit options “F” did not work.
Any help?

Different fit results depending on ROOT version

You must use the “F” fitting option. See the TGraph::Fit description.
You could try to compare two cases: “F” and “F EX0”.

BTW. What do you mean when you say that the fit option “F” did not work. Without this option you should see (in your terminal window) the output from the “linear minimizer”, while with this option you should see the output from the “minuit minimizer” (they look completely different -> if you are using minuit2 then the output is similar to the “linear minimizer” case, but you should also see the name of the minimizer printed, either “Minimizer is Minuit2” or “Minimizer is Linear”).


thanks for your answer, I attach a simple example below. The results of the fit do not change,
no matter how large or small are the x-errors.
It seems the y-errors instead are taken into account.

c1 = new TCanvas(“c1”,"",200,10,700,500);
Int_t n = 3;
Double_t x[n] = { 0.35, 0.5, 1.61};
Double_t y[n] = {7.4,9,9.6};

Double_t xerr_low=2.05.;
Double_t xerr_high=2.05;

Double_t exl[n] = {.05,.051,err_low};
Double_t exh[n] = {.05,.05,err_high};

Double_t yerr_low=0.05.;
Double_t yerr_high=0.05;

Double_t eyl[n] = {.5,.4,yerr_low};
Double_t eyh[n] = {.3,.2,yerr_high};

gr = new TGraphAsymmErrors(n,x,y,exl,exh,eyl,eyh);
return c1;


Just for the record … your example runs fine in ROOT 5.18 (the last version I was using this feature with, some time ago), but it does not work in 5.28 nor 5.34 (tested now). #-o
Something got ill between 5.18 and 5.28 then. I called the emergency and the doctor’s already on the way. :mrgreen:


ok, I am using 5.34…



This is fixed now, in both trunk and 5.34 patches. The fit will consider the errors in x now and the option “EX0” will work correctly.

Some comments on fitting TGraphAsymErrors:

  • the current fitting algorithm for TGraphAsymmErrors cannot take care of asymmetric errors in the x coordinate. A symmetric error equal to 0.5*(exlow + exhigh) will be used in the fit. This could be improved in future ROOT releases, using a better algorithm which takes care of asymmetric errors also in x
  • when fitting linear functions like polynomials you cannot use a linear fitter for fitting points with asymmetri errors. So there is no need to use option “F”

Thank you for reporting this issue.