Dear root experts,
I found a possible bug in FitResult::GetConfidenceIntervals (root 5.34).
I kept getting NaN, so I had a look at the code and found that the step size for computing the function gradient with respect to the parameters in the class RichardsonDerivator is fixed to 0.001 and if the parameters is less than 0.001 it can be that the function becomes NaN, so the confidence interval has a wrong value.
I solved the problem by adding the following lines in FitResult.cxx, before d.SetFunction(fadapter)
if (fParams[ipar] < 0.001)
if (fErrors[ipar] != 0) d.SetStepSize(0.01*fErrors[ipar]);
else d.SetStepSize(TMath::Min(TMath::Abs(fParams[ipar]*0.01), 0.001));
This is correct and there is also a potential problem when computing the derivatives close to the parameter limits. I will fix this problem. Thank you for reporting it
I found another problem: fixed parameters are not skipped in the calculation (there is actually a comment “t.b.d. : skip calculation for fixed parameters”)
I added the line
if (IsParameterFixed(ipar)) grad[ipar] = 0.;
I am not sure if this is the correct way to skip the fixed parameters, but the confidence intervals produced in this way looks reasonable.
I just noticed that these two bugs (step size for the derivative and skip the gradient calculation for the fixed parameters) are still present in ROOT 6 (https://root.cern.ch/doc/master/FitResult_8cxx_source.html#l00606).
Is there any plan to release a fix soon?
Thank you for reminding this. I should have created a JIRA items, for this in order to not forget.
I have done it now and I will try to fix it as soon as possible
Thanks for reminding it