I’m struggling with the “GetChisquare” method when using the Levenberg-Marquardth Algorithm for the minimization when I limit a parameter within an certain interval with “SetParLimits”.

Although the fitted curve looks quite nice when plotted, the Chi-square is way to big when compared with TMinuitMinimizer. I’ve realized that without the “SetParLimits” everything looks normal, however I’m fitting a lot of spectra with a given function and I need to limit one of the function parameters, otherwise for some spectra the fit does not converge.

In my analysis I’m fitting real spectra with an interpolation of simulated spectra.
I was able to reproduced my problem in a small example, please find it attached.

If I remove the SetParLimits everything looks ok, or, if instead, I comment the first line and use for the minimization the TMinuitMinimizer. If I run it as it is, I get a Chi-Square of 30646.6 which does not make sense to me.

Thank you for the example. I can reproduce your problem even with a simple gaussian fit. It seems the returned chi2 value is wrong. If you use the option “V”, you should see the correct value printed. I will investigate the reason for this and try to fix it