Goal
As a user calling .q(p) on Beta with extreme shape parameters (e.g. alpha, beta far from 1) and p very close to 0, the numerically-inverted quantile should return the true tiny-but-nonzero value instead of silently underflowing to exactly the lower support boundary (0).
Scope
src/dist/_distribution.js — the base class _qEstimateRoot/_qInitialGuess numerical bracket-search machinery used by any distribution without a closed-form _q, exercised here via src/dist/beta.js.
Acceptance Criteria
new dist.Beta(0.16984646079370425, 0.017049068904112768).q(6.561641048288602e-6) returns a finite positive value close to the independently mpmath-verified true answer (~3.9455721960421885e-25), not exactly 0.
- The fix generalizes at the base-class level (not a Beta-specific patch) so other numerically-inverted distributions with similarly extreme parameters benefit.
- Round-trip
|cdf(q(p)) - p| for Beta and other affected numerically-inverted distributions passes the harness's out-of-support hard-failure check (scripts/difftest-quantile.py) across the extended tail sweep.
- No regression in existing base-class quantile tests (
test/dist-base-*.js) or other distributions relying on _qEstimateRoot.
Out of Scope
Closed-form _q implementations for distributions that currently lack one — this issue is scoped to the numerical bracket-search algorithm itself.
How found
Discovered by the new quantile accuracy sweep added in #1269 (scripts/difftest-quantile.py). new dist.Beta(0.1698..., 0.0170...).q(6.56e-6) returns exactly 0, but an independent mpmath solve gives 3.9455721960421885e-25 whose cdf round-trips to the requested p to 10 significant figures — the base-class bracket search failed to find the true root. scripts/difftest-quantile.py's mpmath_quantile function (in the same PR) demonstrates a working log-space/logit-space bracket-search fix for the equivalent problem in the harness's own mpmath reference solver, which may be a useful reference for the shape of a production fix.
Goal
As a user calling
.q(p)onBetawith extreme shape parameters (e.g.alpha,betafar from 1) andpvery close to 0, the numerically-inverted quantile should return the true tiny-but-nonzero value instead of silently underflowing to exactly the lower support boundary (0).Scope
src/dist/_distribution.js— the base class_qEstimateRoot/_qInitialGuessnumerical bracket-search machinery used by any distribution without a closed-form_q, exercised here viasrc/dist/beta.js.Acceptance Criteria
new dist.Beta(0.16984646079370425, 0.017049068904112768).q(6.561641048288602e-6)returns a finite positive value close to the independently mpmath-verified true answer (~3.9455721960421885e-25), not exactly0.|cdf(q(p)) - p|for Beta and other affected numerically-inverted distributions passes the harness's out-of-support hard-failure check (scripts/difftest-quantile.py) across the extended tail sweep.test/dist-base-*.js) or other distributions relying on_qEstimateRoot.Out of Scope
Closed-form
_qimplementations for distributions that currently lack one — this issue is scoped to the numerical bracket-search algorithm itself.How found
Discovered by the new quantile accuracy sweep added in #1269 (
scripts/difftest-quantile.py).new dist.Beta(0.1698..., 0.0170...).q(6.56e-6)returns exactly0, but an independent mpmath solve gives3.9455721960421885e-25whosecdfround-trips to the requestedpto 10 significant figures — the base-class bracket search failed to find the true root.scripts/difftest-quantile.py'smpmath_quantilefunction (in the same PR) demonstrates a working log-space/logit-space bracket-search fix for the equivalent problem in the harness's own mpmath reference solver, which may be a useful reference for the shape of a production fix.