# Chi2/ndf issue

**URL:** <https://root-forum.cern.ch/t/chi2-ndf-issue/62821>\
**Category:** Newbie\
**Created:** [February 4, 2025, 8:49pm UTC](https://root-forum.cern.ch/t/chi2-ndf-issue/62821 "2025-02-04T20:49:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Illiaklyuyev](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/illiaklyuyev/32/38403_2.png) [@Illiaklyuyev](https://root-forum.cern.ch/u/Illiaklyuyev)\
**Post date:** [February 4, 2025, 8:49pm UTC](https://root-forum.cern.ch/t/chi2-ndf-issue/62821/1 "2025-02-04T20:49:59Z")

</div>

I have an issue with Chi2/ndf in fitting data on Root. For example o have fit function of sqrt(ax+b) , and data. The visual of graph is ok, i think, but the value of chi2/ndf espesialy value of chi2 is very very big. I cant understand where is the problem.  
Here how its looks like.

 ![image](https://root-forum.cern.ch/uploads/default/original/3X/d/d/dd6fd5b2ee53f5860d7246f853657234b37cd0e3.png)  
Minimizer is Minuit2 / Migrad  
Chi2 = 46335  
NDf = 8  
Edm = 3.0815e-06  
NCalls = 561  
p0 = 0.391581 +/- 0.00229985 -0.0023068 +0.00230125 (Minos)  
p1 = 0.00284131 +/- 5.91676e-06 -5.91951e-06 +5.93552e-06 (Minos)  
Reduced chi2= 5791.87  
P.s. previosly i have fitted plutonium spectra with counts/channel data. I done the energy calibration and thw chi2/ndf value was closer to 1. Then i have done this Fwhm/energy calibration but have issue with chi2/ndf.

---

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [February 5, 2025, 12:06am UTC](https://root-forum.cern.ch/t/chi2-ndf-issue/62821/2 "2025-02-05T00:06:06Z")

</div>

In my very naive understanding, it’s caused by the points that away from the fitted function (with error weighted). You can try:

1. Set a better initial value so that minimizer can avoid the local minimum. `ROOT::Math::Minimizer::SetVariable()` or `TF1::SetParameter()`
2. Try another function that fits the data better, say `log(ax+b)`
