Skip to content

Extend weighted quantile selection to single interior probabilities - #295

Merged
jmh530 merged 1 commit into
libmir:masterfrom
jmh530:codex/weighted-single-interior
Nov 17, 2026
Merged

jmh530 merged 1 commit into
libmir:masterfrom
jmh530:codex/weighted-single-interior

Conversation

@jmh530

@jmh530 jmh530 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

#294 introduced partition selection for a single weighted median. This change extends the same selector to any averagedInverseCDF probability strictly between 0 and 1. For example, both 0.25 and [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)

@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

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
jmh530 force-pushed the codex/weighted-single-interior branch from 19d7da8 to 94f3bf0 Compare November 17, 2026 22:07
@jmh530
jmh530 merged commit 7b02477 into libmir:master Nov 17, 2026
23 checks passed
@jmh530
jmh530 deleted the codex/weighted-single-interior branch November 17, 2026 22:18
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.

1 participant