I’m having some problem with fitting a histogram. The fit routine is first fitting a small range (70 keV wide) and the resulting ndf is correct (64 and 61 for 6 and 9 parameters respectively). However the last fit is then done at a larger range (double the size), but the ndf doesn’t change.
All following fits on the same histogram (but at different ranges) return negative ndfs (-6 and -9), i.e. for some reason the number of fit points is zero.
The fit range of the function is set correctly and the fit option includes “R”, so that is not the problem.
So the question is what kind of error am I making to create such a behavior?
At what point is the number of fit points set?
Thanks for any help,
Could you post s short running example explaining your problem?
I’ve tried to condense my program down as far as possible. I’m not sure whether the problem that shows up now is the same as the one before since the program is totally different now but it’s still showing negative ndf so I’m obviously doing something wrong.
I’ve added the output of the program as description and you can see that FCN is zero and NDF -4.
tmp.c (696 Bytes)
In this example, you are fitting in a range with no data, so the fit did not proceed.
We will return ndf=0 in this case. (fix will be put in SVN)
Hmm, okay, so it seems that I’ve reduced the example to far. In the original program that did not happen:
- subfitrange: 1297.49 to 1367.49 => 676299 entries
- Reduced chisquare: -0 (0/-6, free parameter : 6)
I will try to reproduce this with a simpler program and post it again.
I’ve solved the problem. In the original program the fitted histogram was saved together with the fitting function(s) to a file. In order to see only the relevant part of the spectrum
was inserted. The next fit was NOT in the range a-b so it didn’t work.
Including a spec->GetXaxis()->SetRange() fixed the problem with the negative ndf.