I am trying to run a likelihood fit using TMinuit by manually implementing the negative log-likelihood (-log(NLL)). My probability density function (PDF) depends on three parameters that need to be fitted simultaneously.
When I run the fit(no-limits on parameters), I get the following output, which shows that the uncertainties are calculated correctly, but the central values have some issues (non-convergence). We don’t know what the central values should be, but we assume them to be too small (~0), normally we want to extract the corresponding uncertainties:
The first thing to try is the new Minuit 2, which improves on the original Minuit implementation by changing some things to makes fits converge that didn’t converge before. All the LHC experiments that do big combined fits use Minuit 2 for that reason. And even if it doesn’t converge, it often gives you more informative errors.
If it still doesn’t converge, my first guess is that you have a large number of bins (how many?), and you are losing floating point precision when summing them all up. For that reason, the sum over bins (or events in an unbinned fit) should better be done using Kahan summation, which is also implemented in ROOT.
If it still doesn’t converge with Minuit 2 and Kahan summation, let me know and we can try to figure out what else might be going wrong!
Actually, I have 100 bins on the X-axis and 100 bins on the Y-axis (10,000 bins). I did use Kahan summation, but I’m still getting "Minuit2Minimizer: Invalid minimum - status = 3”.
The full output im getting is the following :
Info in : VariableMetricBuilder Start iterating until Edm is < 2e-08 with call limit = 100000
Info in : VariableMetricBuilder 0 - FCN = 22130894.45 Edm = 1781453142 NCalls = 13
Info in : VariableMetricBuilder 1 - FCN = 64545.04646 Edm = 6377.773391 NCalls = 31
Info in : VariableMetricBuilder 2 - FCN = 3727.713498 Edm = 159.315368 NCalls = 46
Info in : VariableMetricBuilder 3 - FCN = 0 Edm = 0 NCalls = 63
Warning in : MnPosDef Matrix forced pos-def by adding to diagonal 0.300076
Info in : MnHesse Done after 2.43343 s
Info in : VariableMetricBuilder After Hessian
Info in : VariableMetricBuilder 4 - FCN = 0 Edm = 34222.41083 NCalls = 111
Info in : VariableMetricBuilder Tolerance not sufficient, continue minimization; Edm 34222.4 Required 2e-08
Warning in : VariableMetricBuilder No improvement in line search
Info in : VariableMetricBuilder 5 - FCN = 0 Edm = 34222.41083 NCalls = 113
Warning in : VariableMetricBuilder Iterations finish without convergence; Edm 136890 Requested 2e-08
Warning in : VariableMetricBuilder FunctionMinimum is invalid after second try
Info in : VariableMetricBuilder Stop iterating after 5.71895 s
Warning in : Minuit2Minimizer::Minimize Minimization did NOT converge, Edm is above max
Minuit2Minimizer : Invalid minimum - status = 3
FVAL = 0
Edm = 34222.4
Nfcn = 111
I have attached the new code with the modifications you mentioned.The likelihood that I’m trying to minimize takes the usual following form:
I have tried to rerun the fit following the instructions you suggested. Now I have obtained more reasonable uncertainties for the parameters, and the fit converges as well.
However, I still want to confirm one thing related to the limits being set. For the fit results I obtained, I set a range limit of [-0.01,0.01] on ~ each parameter. When I tried a larger range of [-1,1], the fit failed to converge.
I am asking what test will prove that the obtained uncertainties of the considered parameters are reliable, given that we expect the central value of the parameters to be around 0.
Here is the output of the fit that converges with the limits set to [-0.01,0.01].
Info in : MnHesse Done after 235.67 ms
Info in : VariableMetricBuilder After Hessian
Info in : VariableMetricBuilder 5 - FCN = -1423678.473 Edm = 1.999534532e-07 NCalls = 88
Info in : VariableMetricBuilder Stop iterating after 633.734 ms
Minuit2Minimizer : Valid minimum - status = 0
FVAL = -1423678.47254971345
Edm = 1.99953453196305225e-07
Nfcn = 88
deltaAy = 0.0001 +/- 0.0167701 (limited)
deltaAz = 0.000507999 +/- 0.0017295 (limited)
deltaBz = 0.000999998 +/- 0.001263 (limited)