Computation of FCN similar to Minuits one

Hi,

I would like to modify the chi2 in my minuit fit. First, I decided that for control purposes I’ll attempt to recreate results of minuit fit with standard FCN. My FCN is:

void myFcn(Int_t & /*nPar*/, Double_t * /*grad*/ , Double_t &fval, Double_t *p, Int_t /*iflag */  )
{
	double chi2 = 0; 
	double tmp, x[2]; 

	for(int i=-nbxo2; i<=nbxo2; ++i)
	{
		for(int j=-nbyo2; j<=nbyo2; ++j)
		{
			x[0] = (Double_t)i;
			x[1] = (Double_t)j;
			fval = multifun(x, p);			
			if(TF2::RejectedPoint()) continue;			
			tmp = (img_histo->GetBinContent(i+nbxo2+1,j+nbyo2+1)-fval)/img_histo->GetBinError(i+nbxo2+1,j+nbyo2+1);
			chi2 += tmp*tmp;
		}
	}
	fval = chi2;
}

And it should basically make similar fval as in the standard procedure. However, it is not always so. In some cases, the fit with myFCN and stadard FCN goes the same way, but suddenly in one case it shows different EDM (although FCN value is the same), than different Correlation Coefficients. It results in adding 1 to diagonal of error matrix in one case and in another not and the final result is different (although in both cases it does not converge - a different matter).

My question is - is there something obviously different between myFCN and standard FCN? I’ve noticed that standard FCN calculates gradients, but I think minuit does this externally?

Ofcourse, multifun is the function which is called by TF2 object sent to Fit(), img_histo is the data histogram and in many cases fit gives exactly the same results in both cases, so I don’t suspect differences in function/data.

How about:

Unfortunately this changes nothing - I have no empty bins in my histogram…

A stupid idea … in both cases, try to replace “==” with “<=”

Anyhow, if the fit did not converge, the minimizer may be left in a “strange” state, I believe.