Skip to content

[hist] Add option I to TH1::Chisquare for bin integral chi2#21951

Open
JasMehta08 wants to merge 1 commit intoroot-project:masterfrom
JasMehta08:fix/th1-chisquare-integral-option
Open

[hist] Add option I to TH1::Chisquare for bin integral chi2#21951
JasMehta08 wants to merge 1 commit intoroot-project:masterfrom
JasMehta08:fix/th1-chisquare-integral-option

Conversation

@JasMehta08
Copy link
Copy Markdown
Contributor

This Pull Request

Changes or fixes

TH1::Fit supports option "I" which uses the integral of the fitted function over each bin instead of the value at the bin center. TH1::Chisquare did not parse this option, so TF1::GetChisquare() and TH1::Chisquare(f, "I") returned different results after a fit with option "I".
Changes across 3 files:

  • TH1.cxx: parse option "I" into useIntegral, pass it to ROOT::Fit::Chisquare, and
    document the new option alongside the existing "R", "L", "P" options.

  • HFitImpl.cxx: add bool useIntegral = false to ROOT::Fit::Chisquare(TH1) and
    HFit::ComputeChi2. Set DataOptions::fIntegral = useIntegral before BinData is filled.

  • HFitInterface.h: update the public declaration with the new parameter, defaulted to
    false for full backward compatibility.

Before this fix:

h.Fit(f, "QI")
f.GetChisquare() # 7.26965
h.Chisquare(f, "I") # 7.27083 <-- "I" was silently ignored

After this fix:

h.Fit(f, "QI")
f.GetChisquare() # 7.26965
h.Chisquare(f, "I") # 7.26965 <-- correct

Checklist

  • tested changes locally
  • updated the docs (if necessary)

This PR fixes #21695

@JasMehta08 JasMehta08 requested a review from hageboeck as a code owner April 19, 2026 06:32
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 19, 2026

Test Results

    21 files      21 suites   2d 23h 31m 5s ⏱️
 3 833 tests  3 830 ✅  1 💤 2 ❌
72 199 runs  72 179 ✅ 18 💤 2 ❌

For more details on these failures, see this check.

Results for commit e01ba9e.

♻️ This comment has been updated with latest results.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chi2 between TH1 and TF1 using integral of bins

2 participants