Skip to content

[math] Don't use a fit Hessian that is not computed - #23674

Open
shuv-amp wants to merge 1 commit into
root-project:masterfrom
shuv-amp:fit-hessian-not-computed
Open

shuv-amp wants to merge 1 commit into
root-project:masterfrom
shuv-amp:fit-hessian-not-computed

Conversation

@shuv-amp

@shuv-amp shuv-amp commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

HasHessian() of the fit method functions also returned true for fits where the full Hessian is never computed: binned fits with the model integrated over the bins, and unbinned likelihood fits. Minuit2 then got an all-zero Hessian, and the parameter errors of gradient fits were wrong, without any warning.

For example, fitting a histogram with a formula TF1 for which clad generates the Hessian:

h.Fit(&f, "S I")    ->  mean = 0.00307 +- 0.01010
h.Fit(&f, "S G I")  ->  mean = 0.00307 +- 2.00000   (fit status 0)

Return false in HasHessian() for these fits, so that Minuit2 computes the second derivatives numerically. Also check the result of DataElement() in FitMethodFunction::Hessian() with std::isnan. It was compared to NaN with ==, which is never true, so a failure to compute the Hessian was not reported.

Fits where the full Hessian is available, like "G" without "I", are not affected.

Related to #21622, which changes the same Hessian interfaces.

I used AI to help write the fix and tests. I reviewed and tested the changes and take responsibility for them.

HasHessian() of the fit method functions also returned true for fits
where the full Hessian is never computed: binned fits with the model
integrated over the bins, and unbinned likelihood fits. Minuit2 then
got an all-zero Hessian, and the parameter errors of gradient fits were
wrong. For example, TH1::Fit(f, "G I") with a TF1 for which clad
generates the Hessian gave an error of 2 for all parameters, without
any warning.

Return false in HasHessian() for these fits, so that Minuit2 computes
the second derivatives numerically.

Also check the result of DataElement() in FitMethodFunction::Hessian()
with std::isnan. It was compared to NaN with ==, which is never true,
so a failure to compute the Hessian was not reported.

Add a test for each of the two changes.
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 18h 0m 3s ⏱️
 3 885 tests  3 884 ✅ 0 💤 1 ❌
80 844 runs  80 843 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit a3f0d68.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants