Support the saturated likelihood test for any selection mapping - #151
Merged
lucalavezzo merged 2 commits intoAug 20, 2026
Merged
Conversation
A projection is a selection of a channel where all axes that are not kept are summed, which the Select mapping already supports through its 'axis:sum' selections. Project now derives from Select and only adds the transposition into the requested axis order, and Normalize is expressed through the 'normalize' argument of Term.select instead of implementing its own projection. Project therefore also supports process selections, bin selections and rebinning when constructed programmatically. The command line interface and the keys under which results are stored are unchanged. Also drop the unused Term.selection_idxs and a no-op loop in parse_axis_selection that re-used a leaked loop variable. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WTEH6bvho5ziaobKWG153D
The saturated model built its per-bin scale factors by reshaping the parameter
vector to the channel shape and broadcasting over the summed axes, which can
only express keeping whole axes in the order of the channel. Mappings with a bin
selection, a rebinning or a transposition could therefore not be tested and the
test was restricted to the Project mapping.
Mappings that are a selection and a summation of input bins now report the flat
index of the output bin each input bin contributes to via 'output_indices()'
(-1 for bins that are not used). The saturated model gathers one free parameter
per output bin onto the bins contributing to it and leaves all other bins at
one, so any Select or Project mapping can be tested, e.g. to test the goodness
of fit of the signal region of an extended ABCD fit projected to one axis:
-m Select ch0 None 'eta:sum,charge:sum,mt:2,relIso:0'
Mappings that are not a plain sum of input bins, such as Normalize or a
selection of processes, return None and are skipped, as are mappings without
data. This also fixes the number of parameters for a projection to a single bin,
which was a float and raised, the number of bins for channels with flow bins,
and the naming of the parameters for projections where the axes are transposed.
Parameters of the original model that only affect bins made free by the
saturated model are degenerate with it, so the covariance of the saturated fit
can be singular. This is now a warning instead of an error, the test statistic
itself does not need the hessian.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WTEH6bvho5ziaobKWG153D
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
The saturated likelihood test (
--computeSaturatedProjectionTests) was restricted to theProjectmapping. The saturated model built its per-bin scale factors by reshaping the parameter vector to the channel shape and broadcasting over the summed axes, which can only express "keep whole axes, in the order of the channel". Mappings with a bin selection, a rebinning or a transposition could therefore not be tested.The concrete use case is the W simultaneous extended ABCD fit in
pt-eta-charge-mt-relIso: pick the signal region (mtbin 2,relIsobin 0), project it topt, and test the goodness of fit of that spectrum:Changes
1. Implement the
Projectmapping through theSelectmapping (behaviour preserving)A projection is a selection of a channel where all axes that are not kept are summed, which
Selectalready supports through itsaxis:sumselections.Projectnow derives fromSelectand only adds the transposition into the requested axis order, andNormalizeis expressed through thenormalizeargument ofTerm.selectinstead of implementing its own projection.Projecttherefore also supports process selections, bin selections and rebinning when constructed programmatically. The command line interface and the keys under which results are stored are unchanged.Also drops the unused
Term.selection_idxsand a no-op loop inparse_axis_selectionthat re-used a leaked loop variable.2. Support the saturated likelihood test for any selection mapping
Mappings that are a selection and a summation of input bins now report, through a new
Mapping.output_indices(), the flat index of the output bin each input bin contributes to (-1for bins that are not used). The saturated model gathers one free parameter per output bin onto the bins contributing to it and leaves all other bins at one, so anySelectorProjectmapping can be tested. Mappings that are not a plain sum of input bins, such asNormalizeor a selection of processes, returnNoneand are skipped, as are mappings without data.Fixed along the way:
-m Project <ch>) raised, becausenp.prod([])returns a floatprod(axis.size), which is wrong for channels with flow binsParameters of the original model that only affect bins made free by the saturated model are degenerate with it, so the covariance of the saturated fit can be singular. This is now a warning instead of an error; the test statistic itself does not need the hessian.
Validation
compute_flatexactly in 15 configurations: bin selections, strided slices, partial rebinning where half of the input bins are dropped, fully summed channels and transposed projections.Project ch0 x4.9745507501,Project ch1 b1.3181413045,Project ch1 b a47.3605767679.Select ch1now gets one as well, giving the same 47.3605767679 over the same 50 bins.ProjectandNormalizeoutputs are identical to the previous implementation in 22 configurations (axes, flow, masked channels, per-process paths, result keys,ndf_reduction). The exception isNormalizeat the 1e-17 level, where the division now happens once on the summed result instead of per bin before summing.pt-eta-charge-mt-relIsotoy the signal-region projection gives ndof 6, 2deltaNLL 1.81, p = 93.6%, agreeing with the independent linear chi2 p-value. Injecting a 12% tilt into the signal-region pt spectrum of the data drives it to 2deltaNLL 272 (p = 0%) while an untouched sideband stays at 3.12 (p = 79%).🤖 Generated with Claude Code
https://claude.ai/code/session_01WTEH6bvho5ziaobKWG153D