# TMinuit Chi-square of data with no errors

I am trying to fit data points that are basically described by a sine function. When I try to fit this by a sine TF1, I get a very small Chi2 (of the order of e-10), which makes sense since my data points and my function are basically equal.
However, the expression of Chi2 expresses the deviation of the observed data from the fit, weighted inversely by the error of each data point. If none of my data points have an associated error, what is TMinuit considering for the uncertainty?
Is this the cause that my Chi2 is so small?

@StephanH any ideas here?

Hi,
I assume you are using a TGraph (or TGraphErrors):
If all errors are 0 option “W” , i.e. set all errors to 1
is applied.
Just try it out using no option or “W” and/or move one of
your points away by a small amount.
Also look at this about parameter errors for this case:
https://root.cern/doc/master/classTGraph.html#aa978c8ee0162e661eae795f6f3a35589

Otto

My understanding is that a small Chi2 is good, right? It means that my model (the function I choose for the fit) agrees with the data. If that’s correct, I have no problem with that.
I just want to understand how TMinuit fits my data if I don’t have any errors at all.

When you say that it sets all errors to 1, it means an absolute value of +/- 1? For example, if my data is of the order of 10^4, my data will have error of 10^4 +/-1? I don’t think I am understanding this correctly. Could you please clarify this?

See NOTE 5 in the above link.

Hi,

Could you clarify what you mean by chi2? Do you mean:

1. after fitting you call TF1->Chi2() , or
2. after fitting you get the value of FCN?

Following on what OSchaile said, I think by using “W”, it ignores error bars (according to the link) i.e. if you are minimizing the chi2, the error term in the denominator of the chi2 formula is set to 1 and so you’ll be minimizing the least squares instead. It could be the default if the points have no errors but I am just guessing. This would make sense since (as you pointed out) your data points are essentially equal to your function, the square of the difference between the observed and fitted values would be very small, and with the error set to 1, that is all that is being considered in the “chi2”.

Not sure how correct this is though.

@oxon The “NOTE: 5.” says that, after the fit procedure finishes, the errors of the fit function parameters are “corrected”. However, the calculation of the `chi^2` itself is not influenced in any way.

For Chi2 I mean TF1->Chi2(). Your explanation makes sense to me. We can see that Chi2 is just the difference between model and data squared, weighted by the inverse of the data uncertainty. The definition of the option “W” says “Set all weights to 1”, so it would be like making the denominator equal to 1.
It would be great if someone could confirm this.

Hi
to clarify a few things:
A TF1 has a priori no Chi2,
only after a fit Chi2 is set to the value of FCN (the function to be minimized)

``````root [5] hh->Fit(ff)
FCN=27.6966 FROM MIGRAD    STATUS=CONVERGED      62 CALLS          63 TOTAL
...
root [6] ff->GetChisquare()
(double) 27.696591
``````

option “W” (or no errors provided (TGraph)) sets in fact all weights to 1
which is computational same as errors=1
However in this case Chi2 doesnt make much sense since its outcome
is not dependent on the real uncertainty of the measurement

To learn about the role of Chi2 (distribution) you should consult
a textbook on statistics or at least wikipedia.

Cheers
Otto

Thank you for the clarification. I am aware that if we don´t have errors in our data points, we can´t really determine if the fit is good or not, just “how separated” data points and function points are.

I think that, according to what it says here , if my TGraph doesn’t have errors, I don’t even need to specify the option “W”. I was just wondering if TMinuit considered some standard error when the user does not specify any, but I guess not.

Hi,

Yes: “In case of a pure TGraph, the denominator is 1”

To be exact:
TMinuit doesnt even know about errors of data. Its task is to minimize
the function (FCN) provided by the user directly or by the fitting procedure invoked
e.g. TGraph::Fit and to calculate the parameters errors.
It is in FCN where in the special case of a Chi2Fit chi2 is calculated as function
of data values, their errors and the parameters.

Otto