# Difference of minFCN and Chi2 in EvaluateLogL Fits (B-K Chi2)

Hi there,

I’m currently trying to fit a TH1 by using the ROOT::Fit::Fitter class.
As minimization method I want to use the “Poisson likelihood chi-square” described in the well-known Baker-Cousins paper, such that the principal code looks like this:

```ROOT::Fit::Fitter fitter; fitter.SetFunction(WrappedFitFunction, false); fitter.LikelihoodFit(BinData) ```
Up to a factor of 2, this is implemented in the extended Root LikelihoodFit by FitUtil::EvaluateLogL (root.cern.ch/doc/master/FitUtil … ource.html , line 1209).

However, after my fit, I’m wondering about the meaning of the minFCN and Chi2 value:
minFCN = 5041.89
Chi2 = 126.197
NDf = 42

minFCN is calculated in EvaluateLogL as

`loglike = Sum_over_bins [theory(i) - data(i) + data(i)*ROOT::Math::Util::EvalLog(data(i)/theory(i))]`, such that the returned value in EvaluateLogL (nloglike) should be Chi2_P/2.

I tried to find the definition of the Chi2 in the source code, but I failed.
What is the Chi2 in Fitter::Result() and how is it calculated? It doesn’t look like the Poisson likelihood chi-square (or my conclusion about minFCN is wrong).

Thanks a lot!

Allright, I’ve calculated the chi2 after a fit on my own, and minFCN is Chi2_Baker_Cous_Poiss/2 (as expected).
So I guess that the other “Chi2” shown is calculated based on a different method?

Hi,

yes the chi2 computed in FitResult is the Neyman chi2 (computed using the observed errors and the obtained fit result function), while minFCN is the Baker-Cousins likelihood ratio value. 2 * minFCN is also having asymptotically a chi2 distribution, actually much better than the Neyman chi2.

You could also use TH1::Chisquare(TF1) to get both the Neyman and the Baker-Cousins chi2 values (option L) . You need to use the master or 6.08 patches.
root.cern.ch/doc/master/classTH … 4fd63e2cb4

Best Regards

Lorenzo

Thanks a lot for the detailed explanation!