Repository navigation
fix: resolve quantile accuracy for small p in stats/base/dists/pareto-type1/quantile - #17019
Open
wanjinhao1 wants to merge 3 commits into
Open
wanjinhao1 wants to merge 3 commits into
wanjinhao1 wants to merge 3 commits into
Conversation
…eto-type1/quantile` Evaluates `beta / pow(1.0 - p, 1.0/alpha)` in log-space via `log1p` when `p < 1e-4`, avoiding floating-point cancellation in `1.0 - p` that rounds to `1.0` when `p < 2^-53` and returns `beta` instead of the true quantile. Resolves stdlib-js#17008.
Signed-off-by: wanjinhao1 <394959433@qq.com>
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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 #17008.
Description
This pull request:
stats/base/dists/pareto-type1/quantilefor smallp: evaluating1.0 - prounds to1.0whenp < 2^-53(and loses relative accuracy for smallpin general), so the quantile function returnedbetainstead of the true quantile. Whenp < 1e-4, the quantile is now evaluated in log-space asbeta * exp( -log1p( -p ) / alpha ), matching the issue's suggested fix; the existingbeta / pow( 1.0 - p, 1.0/alpha )path is kept otherwise, leaving all currently accurate results (including the Julia fixtures) unchanged. The same change is applied tolib/main.js,lib/factory.js, andsrc/main.c, and regression tests using the issue's mpmath reference values are added for both the main and factory implementations.Related Issues
This pull request has the following related issues:
stats/base/dists/pareto-type1/quantileloses accuracy for smallp#17008Reference Packages
This pull request followed these packages:
stats/base/dists/pareto-type1/quantile(existing package)log1pfor smallpinstats/base/dists/weibull/quantile#15762, fix: uselog1pfor smallpinstats/base/dists/exponential/quantile#15763, fix: avoid cancellation for smallpinstats/base/dists/kumaraswamy/quantile#15769, and fix: improve accuracy for smallpinstats/base/dists/weibull/quantile#16565.p < 1e-4for switching to thelog1ppath: below the smallestpin the existing Julia fixtures (about4e-4), so all fixture comparisons remain bit-for-bit unchanged, while every case from [BUG]:stats/base/dists/pareto-type1/quantileloses accuracy for smallp#17008 (pfrom1e-19to3.5e-14) is resolved to within ~2e-16 relative error of the 100-digit mpmath reference.Questions
No.
Other
Verification:
node test/test.js,node test/test.quantile.js,node test/test.factory.js(3027+ tests) pass. The C implementation was syntax-checked withgcc -fsyntax-only(native build/test left to CI). The five reproduction cases from #17008 now match the mpmath reference values to within 2e-16 relative error, andp === 1still returns+Infinity.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
stats/base/dists/pareto-type1/quantileloses accuracy for smallp#17008.@stdlib-js/reviewers