Repository navigation
Extend weighted quantile selection to single interior probabilities - #295
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Use partition selection for scalar and one-element averagedInverseCDF requests at any probability strictly between zero and one. Keep the 16-row cutoff and existing safeguards for integer relative weights. Test both quartiles at exact cumulative-weight boundaries and immediately to either side. Update the quantile selection design notes. AI-Assisted-By: Codex (GPT-6 Astra Medium)
jmh530
force-pushed
the
codex/weighted-single-interior
branch
from
November 17, 2026 22:07
19d7da8 to
94f3bf0
Compare
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.
#294 introduced partition selection for a single weighted median. This change extends the same selector to any
averagedInverseCDFprobability strictly between 0 and 1. For example, both0.25and[0.25]can now select the lower quartile without sorting all observations.The existing eligibility rules apply: observations must be unordered, at least 16 rows must have positive integer-typed relative weights, and their cumulative sum must be exactly representable. At an exact cumulative-weight boundary, the selector averages the two adjacent distinct values. Single requests at 0 and 1 continue to use ordinary preparation.
Performance
On Ubuntu LDC 1.36, end-to-end RC scalar calls were faster in all 120 shuffled-input benchmark cases. The benchmark covered probabilities of 0.1, 0.25, 0.75, and 0.9, including targets both inside an observation’s weight and exactly on a boundary. Relative to #294, the median time reduction was 38% at 16 positive-weight rows, 57% at 1,024, and 75% at 32,768.
Validation
Windows DMD 2.113 passed 42 modules of unit tests with DIP1000. New regression tests exercise scalar and one-element quartile requests at exact boundaries and one representable probability to either side.
A focused Ubuntu LDC 1.36 run with optimization and DIP1000 passed 128 comparisons against sorted lookup, plus a lazy-input check. It covered tied values, unequal weights, endpoints, and all three allocation variants. The broader Ubuntu LDC test run remains unverified: its DIP1000 build reported lifetime errors in mean tests, and its standard build encountered a histogram linker error.
Merge order
This PR builds on #294. Merge #294 first, then rebase this branch onto
master. The follow-up can be reviewed independently in commit 19d7da8.AI-Assisted-By: Codex (GPT-6 Astra Medium)