Skip to content

[RF] Fix RooBinIntegrator for ranges cutting through integrand bins#22922

Open
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:fix-binintegrator-partial-range
Open

[RF] Fix RooBinIntegrator for ranges cutting through integrand bins#22922
guitargeek wants to merge 1 commit into
root-project:masterfrom
guitargeek:fix-binintegrator-partial-range

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

RooBinIntegrator builds its integration grid from the integrand's binBoundaries(xlo, xhi), which only returns the boundaries lying strictly inside the integration range. As a result, the integrator summed only the bins fully contained in the range and silently dropped the partial bins at the edges, because the integration limits were never added as the outermost bin boundaries.

For example, integrating a 5-bin RooHistPdf (edges 0,2,4,6,8,10) over the sub-range [3,7] returned 2 instead of the correct 5.5.

Fix this by prepending xmin and appending xmax as the outermost boundaries when they are not already present. The guard avoids zero-width bins when a range boundary coincides with a bin edge. Each resulting sub-bin then lies entirely within one original bin, so the midpoint rule stays exact for a piecewise-constant histogram.

Add unit tests comparing the numeric RooBinIntegrator result against the analytic RooHistPdf integral for several range types, in both one and two dimensions.

Closes #22858.

🤖 Done with the help of AI.

RooBinIntegrator builds its integration grid from the integrand's
binBoundaries(xlo, xhi), which only returns the boundaries lying strictly
inside the integration range. As a result, the integrator summed only the
bins fully contained in the range and silently dropped the partial bins at
the edges, because the integration limits were never added as the outermost
bin boundaries.

For example, integrating a 5-bin RooHistPdf (edges 0,2,4,6,8,10) over the
sub-range [3,7] returned 2 instead of the correct 5.5.

Fix this by prepending xmin and appending xmax as the outermost boundaries
when they are not already present. The guard avoids zero-width bins when a
range boundary coincides with a bin edge. Each resulting sub-bin then lies
entirely within one original bin, so the midpoint rule stays exact for a
piecewise-constant histogram.

Add unit tests comparing the numeric RooBinIntegrator result against the
analytic RooHistPdf integral for several range types, in both one and two
dimensions.

Closes root-project#22858.

🤖 Done with the help of AI.
@github-actions

Copy link
Copy Markdown

Test Results

    23 files      23 suites   3d 17h 31m 25s ⏱️
 3 873 tests  3 873 ✅ 0 💤 0 ❌
79 803 runs  79 803 ✅ 0 💤 0 ❌

Results for commit a51a501.

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.

[RF] RooBinIntegreator gives wrong result for integrals that cut thought bin boundaries

1 participant