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?
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 differentnlines variable than the one used by the for loop. Setting it to = 0 right before the fscanfwhile 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.