I have noticed a rather worrying inconsistency between the Minuit fit errors and the covariance matrix. I first saw this in a ~4000-parameter RooFit fit, but (you will be relieved to hear) I have been able to reproduce the problem with a simple Gaussian TH1::Fit.
I had assumed that the errors were taken from the (square root of the) diagonals of the covariance matrix (which in turn is taken from the inverse of the Hessian). But when parameter limits are specified, I get slightly different numbers from result->Error(i) and sqrt(result->GetCovarianceMatrix()(i,i)). If the parameter is close to the limit, the difference can be quite substantial. I see the same effect in Minuit1 and Minuit2.
I attach a simple program to demonstrate the effect. This performs a Gaussian fit, with limits on the mean and sigma. The results are:-
Parameter Constant = 61.274047 +/- 1.266762 (error) +/- 1.266762 (sqrt(V)) Parameter Mean = 16.106904 +/- 7.289780 (error) +/- 5.806527 (sqrt(V)) L(15 - 100) Parameter Sigma = 65.502962 +/- 5.614515 (error) +/- 5.616678 (sqrt(V)) L(59 - 100)
Here the fitted mean of 16.1 is close to the lower limit of 15, and has an error of 7.3, while sqrt(V(1,1))=5.8. The fitted sigma of 65.5 is further from the limit at 59, and the two measures of the error are much closer (2% off). The constant term has no limits and the two measures of the error are identical.
I assume this is something to do Minuit’s internal parameter transformations to define the limits, but I can’t see why the error and covariance matrix diagonals should behave differently. Is this the intended behaviour?
PS. I think the example program shows a small bug in TF1::GetParLimits in ROOT 6.04. They seem to be changed after the fit, so the program prints out “L( 0 - 274)” for Sigma. For clarity, I fixed this in what I wrote above. ROOT 6.02 and 5.34 don’t show this problem.
covtest.cc (1.16 KB)