You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: stats/base/dists/betaprime/quantile returns Infinity for large finite quantiles #17099
stats/base/dists/betaprime/quantile returns Infinity when the quantile is large but finite. For example, quantile( 0.5, 1.0, 0.001 ) returns Infinity. With alpha = 1, the CDF is 1 - (1+x)^(-beta), so the quantile is (1-p)^(-1/beta) - 1, which is 2^1000 - 1 ≈ 1.0715e301 here.
The quantile is computed as x / ( 1.0 - x ), where x = betaincinv( p, alpha, beta ) (lib/main.js and src/main.c). When the quantile is above about 1e16, x rounds to 1.0, so 1.0 - x is 0 and the result is Infinity.
A possible fix: call kernelBetaincinv( alpha, beta, p, 1.0-p ), which returns both x and 1-x, and compute x / (1-x) from those two values instead of computing 1-x by subtraction. I tested this on the cases below. It gives finite results within 0 to 616 ULP of the exact values (the current implementation is off by about 1e17 to 2e18 ULP, i.e. returns Infinity).
Found while comparing stats/base/dists functions against SciPy and mpmath. The comparison and this report were done with AI assistance (Claude Code); I checked the reproduction and reference values.
Activity