[quote=“Wile E. Coyote”]I would say that, for the moment, the safest approach is to set all “y-errors” to a very small positive value (e.g. +1e-7) and do not use the “W” fit option -> then also your “x-errors” should PROPERLY be taken into account.
P.S. Lorenzo, please note that (s)he DID try it -> this is exactly the problem that (s)he faces.[/quote]
Hi, Wile E. Coyote,
Thanks for your suggestion.
As I showed above, I set the “y-error” to 1e-7, the fit seems working, but the fitted errors of parameters are so small ~1e-8, if I use TGraph for fitting, errors of paras would be ~1e-2. This makes me uncomfortable since my first intuition is the TGraphErrors would give bigger error.
The problem is like this. If I set both x-error and y-error to 1e-7, in principle, fit to TGraphError should give the same result as TGraph, but not (shown below). I know there would be some corrections in TGraph fit, but I don’t know much detail. All these things make me feel unsatisfied to just use the y-error of 1e-7.
Hua
[code]****************************************
void test3(){
Double_t x[100], y[100],xe[100],ye[100];
for (int i=0; i<100; i++){
x[i] = gRandom->Uniform(-1, 1);
y[i] = -1 + 2*x[i] + gRandom->Gaus(0, 0.2);
xe[i]=1e-7;//gRandom->Gaus(0, 0.2);
ye[i]=1e-7;
}
TF1 *fpol = new TF1(“fpol”, “[0]+[1]*x”, -1, 1);
TGraph *gr = new TGraph(100, x,y);
gr->Fit(“fpol”,“F”);
TGraphErrors *gre = new TGraphErrors(100, x,y,xe,ye);
gre->Fit(“fpol”,“F”);
}
// Fit result of TGraph
Minimizer is Minuit / Migrad
Chi2 = 4.25313
NDf = 98
Edm = 2.34623e-09
NCalls = 29
p0 = -1.01514 +/- 0.0208327
p1 = 1.96667 +/- 0.0350903
// Fit result of TGraphErrors
Warning in : Abnormal termination of minimization.
FCN=8.56765e+13 FROM MIGRAD STATUS=FAILED 73 CALLS 74 TOTAL
EDM=11070.6 STRATEGY= 1 ERR MATRIX APPROXIMATE
EXT PARAMETER APPROXIMATE STEP FIRST
NO. NAME VALUE ERROR SIZE DERIVATIVE
1 p0 -1.01526e+00 2.25011e-08 1.02067e-04 -1.86870e+09
2 p1 2.01567e+00 3.75321e-08 6.92710e-05 -3.80736e+09
[/code]