RootTalk


ROOT Discussion Forums

TGraphAsymm x-Errors in pol fit ?

Discuss installing and running ROOT here. Please post bug reports here.

Moderator: rootdev

TGraphAsymm x-Errors in pol fit ?

Unread postby michela » Wed Oct 31, 2012 2:39

Hello

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?
Thanks
Michela
michela
 
Posts: 5
Joined: Wed Feb 23, 2011 14:42

Re: TGraphAsymm x-Errors in pol fit ?

Unread postby Wile E. Coyote » Wed Oct 31, 2012 7:41

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").
Wile E. Coyote
 
Posts: 776
Joined: Sun Sep 30, 2012 10:50

Re: TGraphAsymm x-Errors in pol fit ?

Unread postby michela » Wed Oct 31, 2012 18:38

Hello
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);
gr->SetMarkerColor(4);
gr->SetMarkerStyle(21);
gr->Draw("AP");
gr->Fit("pol1","F");
return c1;
}
michela
 
Posts: 5
Joined: Wed Feb 23, 2011 14:42

Re: TGraphAsymm x-Errors in pol fit ?

Unread postby Wile E. Coyote » Wed Oct 31, 2012 22:22

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:
Wile E. Coyote
 
Posts: 776
Joined: Sun Sep 30, 2012 10:50

Re: TGraphAsymm x-Errors in pol fit ?

Unread postby michela » Thu Nov 01, 2012 1:00

ok, I am using 5.34...
thanks!
michela
 
Posts: 5
Joined: Wed Feb 23, 2011 14:42

Re: TGraphAsymm x-Errors in pol fit ?

Unread postby moneta » Thu Nov 01, 2012 16:17

Hi,

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.

Lorenzo


Lorenzo
moneta
 
Posts: 1416
Joined: Fri Jun 03, 2005 14:38
Location: CERN


Return to ROOT Support

Who is online

Users browsing this forum: Bing [Bot] and 4 guests