ChiSquare calculation in a TGraph fit

Dear experts,

I’m fitting a TGraph from the fit panel of ROOT TCanvas. The TGrpah consists of variable x (particle mass [GeV]) and variable y(mass resolution[GeV]) listed here:

double x[11]={0.25675, 0.40256, 0.700988, 1.00258, 1.99748, 4.99926, 8.49263, 14.9808, 24.9651, 34.9468, 57.8769}
double y[11]={0.00928133, 0.00962651, 0.0096632, 0.0131867, 0.0183589, 0.0403145, 0.071257, 0.127619, 0.212356, 0.290219, 0.492529}
TGraph* gr = new TGraph(11,x,y);

Then I open the fit panel from the Tools menu, and fit in the range 0-61GeV with a pol2 function, with the default fit method Chi-square in the Fit Settings. The fit reports:

Minimizer is Linear / Migrad
Chi2 = 6.16599e-05
NDf = 8
p0 = 0.00445091 +/- 0.00121854
p1 = 0.00799295 +/- 0.000155698
p2 = 7.52289e-06 +/- 2.84154e-06

The Chi2 is ~10^-5. When I do calculation in excel, using the fitted value from the fitted polynomial-2 fucntion and the actual y[i], with this formula: (y[i] - fitted y[i])^2 / fitted y[i], I get a total sum of 0.00251692, which is on the order of 10^-3, not 6.16599e-05 as it reports.

So I wonder how the Chi2 is calculated in the ROOT fit above? Is it using a different formula when doing the Chi2 calculation?


if you have no uncertainty associated to the y the chi2 method reduce to the least square method and root
compute the Chi2 as the sum (y_i - fitted y_i)^2.
When you compute the Chi2 with excel you should weight the square difference with the uncertainties squared and not with the fitted ys, Weighted Least Squares. I am not aware of any least square method where the weights are the fitted ys.


1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.