Fitting a function and its result

Dear experts,

It is obvious that for a large data set with very less errors on each points, the fit would return high chi-square value (FCN), if the pre-defined function is OK. But, always it is not possible to have very large error bars to reduce the chi-square value.

(1) Is there any way out in that case?

(2) Is it possible to include X-errors while fitting a 3D dataset (a TGraph or TGrapherrors)?

(3) Is it possible to take the projections of my 3D fit on YZ and XZ plane.

Hi @Sandy,

I think what will help here is the difference between chi^2 and the chi^2 probability. Chi^2 is just the squared difference between function and data point, weighted by error. With more data points, chi^2 generally grows. The chi^2 probability, however, tells you how likely you have a bad or a good fit, and it takes into account the amount of data points. See e.g. here:

ROOT can calculate the chi^2 probability with this function:
https://root.cern.ch/doc/master/group__ProbFunc.html#ga71284e1163c692051ffad74dae11a061

The number of degrees of freedom is the number of data points - number of fit parameters. Probabilities very close to zero indicate bad fits.

Now some comments to your questions. Some of these things might be unnecessary if you use chi^2 probabilities, though.

Not necessarily. If the model describes the data more accurately, chi^2 is lower. But it’s true that if the model is “good enough”, you in general get higher chi^2 with more data points. That’s not a problem, though, as I explained above.

Yes, the chi^2 probability.

I believe there’s no TGraph in 3D, but the histograms such as TH3D can be fit. They don’t take into account x errors, though, they take into account how many entries per bin you have.

Sure, in 3D histograms you can. See e.g. here:
https://root.cern.ch/doc/master/classTH3.html#a94dd0a21d42fd95756e906e7f50fa293

There’s even a function to fit slices:
https://root.cern.ch/doc/master/classTH3.html#a927fb729e31d90ecbcc2b5e4f9e23900

But I don’t think that you will need those, since when using the chi^2 probability, all problems with data statistics will go away.

2 Likes

Ok, one more thing:
For a completely unbinned fit in n dimensions, where you want to be able to first fit and then project the function onto a plane, I guess you need to do it in RooFit. This tutorial e.g. projects a PDF:
https://root.cern.ch/doc/master/rf315__projectpdf_8C.html

More tutorials are here:
https://root.cern.ch/doc/master/group__tutorial__roofit.html

1 Like

Thanks @StephanH.

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