Re: [ROOT] wrong error calculation in TGraphAsymmErrors::GetErrorY(int point)

From: Rene Brun (Rene.Brun@cern.ch)
Date: Wed Dec 11 2002 - 21:02:16 MET


Hi Miro,

This is solved in 3.04/01

Rene Brun

On Wed, 11 Dec 2002, Miroslav Helbich wrote:

> 
> 
>  Hi Rene, Fons and other rooters,
> 
>   I think this behaviour of the 
> TGraphAsymmErrors::GetErrorY(int point) and TGraphAsymmErrors::GetErrorY(int point)
> is not as expected.
> 
> root [6] gr1 = TGraphErrors(1)
> (class TGraphErrors)146016688
> root [7] gr1->SetPoint(0,1.,1.)
> root [8] gr1->SetPointError(0.,0.,0.5)
> root [11] gr1->GetErrorY(0)
> (const Double_t)5.00000000000000000e-01     <----- correct
> 
> root [12] gr2 = new TGraphAsymmErrors(1)
> (class TGraphAsymmErrors*)0x8ebe288
> root [13] gr2->SetPoint(0,1.,1.)
> root [14] gr2->SetPointError(0,0.,0.,0.5,0.5)
> root [15] gr2->GetErrorY(0)
> (const Double_t)7.07106781186547573e-01    <------ sqrt(2)*0.5
> 
> I would expect the errors to be the same since the graphs are the same.
> 
> This formula is used to calculate the chi2 which then leads to a
> factor of 2 lower chi2 for the same data set defined with different class.
> 
> I understand it is difficult to fit data with assymetric error bars
> and no simple prescription can be given. 
> 
>  So far the error is calculated as
>  return TMath::Sqrt(elow*elow + ehigh*ehigh);
> 
> I would suggest something of the following 
>  (elow+ehigh)/2.
>  sqrt((elow*elow+ehigh*ehigh)/2.) 
>  max(elow,ehigh)
> 
> I am not sure which one is the best - it depends on the problem. Probably #3 or #1 would do.
> 
> 						    Miro
> 
> 
> 
> Double_t TGraphAsymmErrors::GetErrorY(Int_t i) const
> {
> //    This function is called by GraphFitChisquare.
> //    It returns the quadratic error along Y at point i.
> 
>    if (i < 0 || i >= fNpoints) return -1;
>    if (!fEYlow && !fEYhigh) return -1;
>    Double_t elow=0, ehigh=0;
>    if (fEYlow)  elow  = fEYlow[i];
>    if (fEYhigh) ehigh = fEYhigh[i];
>    return TMath::Sqrt(elow*elow + ehigh*ehigh);
> }
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:23 MET