Skip to content

Fix Gamma/InverseGamma quantile NaN for extreme alpha #1397

Description

@synesenom

Goal

As a user calling .q(p) on Gamma or InverseGamma with extreme shape parameters (alpha ~ 0.01–0.02) and p very close to 0 or 1, the quantile should converge to a finite correct value instead of silently returning NaN.

Scope

  • src/dist/gamma.js
  • src/dist/inverse-gamma.js

The closed-form _q(p) implementations.

Acceptance Criteria

  • new dist.Gamma(0.01256450685433316, 8.836044349967338).q(3.6121091725799824e-6) returns a finite value (not NaN)
  • new dist.InverseGamma(0.01015699205818355, 50.384930286066414).q(0.9999928271253562) returns a finite value (not NaN)
  • The two additional Gamma small-alpha NaN cases surfaced by the sweep also resolve to finite values
  • Round-trip |cdf(q(p)) - p| for Gamma/InverseGamma passes the harness's non-convergence hard-failure check (scripts/difftest-quantile.py) across the extended tail sweep
  • No regression in existing Gamma/InverseGamma precision-gate reference values

Out of Scope

General closed-form quantile redesign for all alpha ranges — only the extreme small-alpha near-boundary-p regime identified by this sweep.

How found

Discovered by the new quantile accuracy sweep added in #1269 (scripts/difftest-quantile.py). new dist.Gamma(0.01256..., 8.836...).q(3.612e-6) and new dist.InverseGamma(0.01016..., 50.385...).q(0.99999...) both return NaN, plus two additional confirmed Gamma small-alpha NaN cases — a hard non-convergence failure in the closed-form formulas.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions