Hi,
The question is about fitting error results.
I defined a function, and use it to fit a histogram or graph. The printed fitting error result on the screen is not same as the one printed on the canvas (if I use SetOptFit to print them on my canvas) and obtained by access methods GetParError.
An example code here:
test_fit_err() {
double x[5] = {1, 2, 3, 4, 5};
double y[5] = {1.3, 1.4, 1.2, 1.25, 1.35};
TGraph * g = new TGraph(5, x, y);
g->SetMarkerStyle(20);
g->Draw("ap");
TF1 * f = new TF1("func", "[0]+[1]*x", 0.2, 0.6 );
f->SetLineStyle(2);
f->SetLineColor(8);
g->Fit(f);
//g->Fit("pol0");
TF1 *myfunc = g->GetFunction("func");
//TF1 *myfunc = g->GetFunction("pol0");
gStyle->SetOptFit(11111);
Double_t par0 = myfunc->GetParameter(0);
Double_t err0 = myfunc->GetParError(0);
cout << "FitPar: " << par0 << " FitError: " << err0 << endl;
}
I tried pre-defined-in-root functions, the fitting error results from the screen and the canvas are consistent. I don’t know why. Which error result should be used?
Cheers,
Zhiyi.