Skip to content

Extend checked Poisson tails and inverse CDF to larger rates - #283

Open
jmh530 wants to merge 1 commit into
libmir:masterfrom
jmh530:codex/poisson-mode-prototype
Open

jmh530 wants to merge 1 commit into
libmir:masterfrom
jmh530:codex/poisson-mode-prototype

Conversation

@jmh530

@jmh530 jmh530 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Extend poissonTailsChecked and poissonInvCDFChecked for finite Fp rates of 1,024 or greater. Previously, these rates returned workLimit for interior queries even at the maximum term budget. At rate 2,000, Fp!64 now certifies both tails at the mode within 1,024 terms and finds the median within the default 256.

The calculation starts at floor(lambda), sums relative masses outward, and bounds the omitted mass on each side. It returns found when both tails are certified to round correctly, or when it proves the least count whose exact CDF reaches the inverse query. The inverse search replays weights from the mode using fixed stack storage.

Rates below 1,024 continue to use the existing sum from zero. The fixed rate threshold keeps algorithm selection independent of maxTerms. Both methods retain the 1,024-term ceiling and return workLimit when the bounds are inconclusive.

Regression tests cover rates immediately below, at, and above the threshold. At rate 2,000, two adjacent Fp!64 probabilities yield inverse counts of 2,000 and 2,001, exercising the distinction between the exact CDF and its rounded value.

Validation on Windows:

  • The Poisson suite passed with DMD on 32-bit and 64-bit targets and with optimized LDC on 64-bit.
  • Optimized 64-bit DMD and LDC each ran 1,296 reference cases through the public APIs. Every certified result matched the independent reference.
  • On 32-bit LDC, 576 focused cases covering the new method passed with the released dependency. The ordinary Poisson suite reproduced the baseline division failure and passed all 11 modules with the isolated fix associated with Fix x86 BigInt division by powers of two mir-algorithm#506.

Refs #157.

AI-Assisted-By: Codex (GPT-6 Astra Medium)

For finite rates of 1024 or greater, sum relative masses outward from
the mode and bound the omitted mass on both sides. Return found only
when the bounds certify both independently rounded tails or the least
count whose exact CDF reaches the query probability.

Use a fixed rate threshold so changing maxTerms keeps the same
algorithm. Keep the 1024-term ceiling and use fixed stack storage
by replaying weights from the mode during the inverse search.

Cover rates on either side of the threshold, adjacent work budgets,
and adjacent probabilities at rate 2000 whose inverse counts differ.

AI-Assisted-By: Codex (GPT-6 Astra Medium)
@jmh530
jmh530 force-pushed the codex/poisson-mode-prototype branch from e4d40aa to 620b8d5 Compare November 16, 2026 21:22
@codecov

codecov Bot commented Nov 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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