Repository navigation
fix: resolve Infinity results for large finite quantiles in stats/base/dists/betaprime/quantile - #17136
Open
wanjinhao1 wants to merge 2 commits into
Open
fix: resolve Infinity results for large finite quantiles in stats/base/dists/betaprime/quantile#17136wanjinhao1 wants to merge 2 commits into
Infinity results for large finite quantiles in stats/base/dists/betaprime/quantile#17136wanjinhao1 wants to merge 2 commits into
Conversation
…eta outputs to avoid rounding to Infinity
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
Infinity results for large finite quantiles in stats/base/dists/betaprime/quantile
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #17099.
Description
This pull request:
stats/base/dists/betaprime/quantilereturningInfinityfor large finite quantiles. Previously the quantile was computed asx / (1.0 - x)wherex = betaincinv(p, alpha, beta); when the true quantile exceeds ~1e16,xrounds to1.0and1.0 - xis0. Now bothlib/main.js,lib/factory.js, andsrc/main.ccallkernelBetaincinv(alpha, beta, p, 1.0-p), which returns bothxand1-xwithout a catastrophic cancellation, and computex / (1-x)from the two returned values (the approach suggested in the issue).manifest.jsonswaps thebetaincinvadd-on dependency forkernel-betaincinv, matching howstats/base/dists/f/quantileis wired.Related Issues
This pull request has the following related issues:
Reference Packages
This pull request followed these packages:
stats/base/dists/f/quantileQuestions
No.
Other
The issue's three reproduction cases now return
9.999999999999112e+199,1.071508607186194e+301, and1.0000000000000554e+250, within a few ULP of the closed-form reference values. Small/ordinary quantiles are unchanged.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
AI assistance (Claude Code agent operated by the repository contributor wanjinhao1) was used to analyze the issue, implement the fix, add the regression tests, and draft this pull request. The fix approach was proposed in the issue itself; the contributor reviewed and verified the changes locally:
node test/test.js,node test/test.quantile.js(3024 tests, including 3 new regression cases),node test/test.factory.js(3023 tests) all pass, and the C side passesgcc -fsyntax-only.