Unnaturally small chi-square; no fit convergence with non-zero errors

Dear Colleagues,
In the attached code, performing on a TGraphErrors graph1 gives an unexpectedly small chi-square value if I assume no errors on my ‘x’ and ‘y’ values. However, any attempt to use non-zero errors stops the fits from converging. To supply some context, this a graph of excitation spectra containing multiple peaks.
I have read through other postings that discuss problems with chi-square values, but I have been unable resolve it myself. Can anyone please offer advice?

read_sample_prime2_4var_wl_err.c (5.7 KB)
fitting.txt (9.1 KB)

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

Hi Ricardo,

The macro doesn’t work at all for me. After fixing a couple of coding issues it now crashes in the line x_data[nlines] = data[0]; because nlines is uninitialized: it’s a different nlines variable than the one used by the for loop. Setting it to = 0 right before the fscanf while loop fixes it for me.

In the TGraphErrors constructor, err_y and err_x seem to be swapped.

If I initialize the fit parameters for the “with uncertainty” case with the values from the “no uncertainty case” then I get a more reasonable fit result:

 double I_k_eq_1 = 0.0024;  // Intensity for k =1  
 double S_k_eq_1 =    3.5 ;     //Huang Rhees parameter for k=1  
 double e_sigma_k_eq_1 =  4.4;  // electronic sigma for k = 1 
 double p_sigma_k_eq_1 = 1.4;  // phonon sigma for k = 1  

and the fit does converge for me with

   err_x[nlines] = 0.0001;
   err_y[nlines] = 0.001;

(and fixing the order of err_x and err_y in the TGraphErrors constructor):

 FCN=1789.43 FROM MIGRAD    STATUS=CONVERGED     231 CALLS         232 TOTAL
                     EDM=8.93134e-07    STRATEGY= 1      ERROR MATRIX ACCURATE 
  EXT PARAMETER                                   STEP         FIRST   
  NO.   NAME      VALUE            ERROR          SIZE      DERIVATIVE 
   1  I_{0}        2.86117e-03   2.26070e-05   1.11041e-07   1.63007e+02
   2  S            3.97438e+00   1.57564e-02   6.84637e-05  -2.21736e-01
   3  #sigma/cm^{-1}   4.34854e+00   2.39140e-02   1.24424e-04  -7.83025e-02
   4  #sigma_{0}/cm^{-1}   9.93528e-01   5.98344e-02   3.56095e-04  -4.91787e-02

The $\chi^2$ is still horrible - but that seems to be a problem of the fit function, not necessarily of the convergance: even in the no-error case the low-x range of the data isn’t reproduced well by the fit function. And your uncertainties might be poissonian, relative, what do I know - I was just giving an example with an arbitrary uncertainly value.


Thanks, Axel, for your work on the problem. In the end, I was able to perform a good fit that gave me a reasonable value of $\chi^2$ using OriginLab.