Skip to content

Remove the row cutoff for single weighted inverse-CDF requests - #299

Merged
jmh530 merged 1 commit into
libmir:masterfrom
jmh530:codex/small-weighted-inverse-cdf
Nov 18, 2026
Merged

jmh530 merged 1 commit into
libmir:masterfrom
jmh530:codex/small-weighted-inverse-cdf

Conversation

@jmh530

@jmh530 jmh530 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

#297 uses partition selection for a single inverseCDF or averagedInverseCDF request starting at 16 positive-weight rows. This PR removes that cutoff. In two Ubuntu LDC 1.36 benchmark runs, selection reduced median end-to-end RC call time at every size from 3 through 15 unordered rows for both algorithms. At three rows, scalar calls took about 30% less time and one-element batches took about 24% less time.

The change applies to interior probabilities with integer relative weights. Ordered inputs still take their existing path, and selection retains its exact-sum check, signed-zero handling, and partition work limit. A private compile-time predicate identifies the two inverse-CDF algorithms across validation, selection, sorted preparation, and table support.

The regression test and design notes use the same three-row example. With values [30, 10, 20] and weights [1, 1, 2], the value 10 holds exactly 25% of the total weight. At p = 0.25, inverseCDF returns 10, while averagedInverseCDF averages 10 and 20 to return 15.

Validation

Windows DMD 2.113 with DIP1000 passed all 42 modules in the focused unit-test run. Optimized Ubuntu LDC 1.36 with DIP1000 passed 440 comparisons against #297, including signed zeros, oversized weights, floating-point weights, zero-weight rows, and integer observations above 2^53.

Merge order

This PR adds one commit on top of #297. Merge #297 first, then rebase this branch onto master. The follow-up can be reviewed independently in commit 04aef68.

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 eligible interior probabilities on small
unordered inputs. Share a compile-time predicate for inverseCDF and
averagedInverseCDF across validation, selection, and table support.

Replace the cutoff tests with a three-row case that exercises both
algorithms at an exact weight boundary. Document the same example in
the quantile selection design notes.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
@jmh530
jmh530 force-pushed the codex/small-weighted-inverse-cdf branch from 04aef68 to 0c0317e Compare November 18, 2026 01:02
@jmh530
jmh530 merged commit 3b2a555 into libmir:master Nov 18, 2026
23 checks passed
@jmh530
jmh530 deleted the codex/small-weighted-inverse-cdf branch November 18, 2026 01:19
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