Repository navigation
Conversation
…y/quantile` `1 - p` rounds away the low-order bits of `p`, and `1 - (1-p)^(1/b)` then cancels. For `p < 2^-53` the function returned `0`. Use `-expm1( log1p(-p) / b )` and add fixtures generated from the textbook formula in extended precision.
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
Imkkey
reviewed
Oct 2, 2026
Imkkey
left a comment
There was a problem hiding this comment.
AI-assisted review of dafdeba723cb101c4c15a8fb33f6499a5e665784: no blocking issue found in the targeted numerical checks.
- The unchanged JS quantile and factory tests pass: 2,021 and 2,022 assertions. Running the quantile tests against the base implementation reproduces the reported 1,077 failures.
- Independently evaluated the textbook formula with mpmath at 2,048-bit precision. All 2,000 fixture expectations agree after rounding to float64.
- Compiled the PR's C source with published stdlib C dependencies: maximum fixture errors were 3 ULP for
data.jsonand 1 ULP forsmall_p.json. Also checked 1,816 additional finite-parameter cases and 348 C endpoint/invalid-input assertions.
For example, quantile(1e-20, 2, 3) now returns 5.7735026918962574e-11, matching the independent reference, where the base returns 0.
The checks used actual PR source and stdlib dependencies, with import-name mapping for monorepo paths. This was scoped numerical validation; the full monorepo suite and Node native addon were not run locally. The additional corpus excludes intermediate p/b underflow.
5 of 7 tasks
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.
Description
This pull request:
stats/base/dists/kumaraswamy/quantileaspow( -expm1( log1p(-p) / b ), 1/a )instead ofpow( 1 - pow( 1-p, 1/b ), 1/a )(JS, factory and C),TODOfor.Forming
1 - prounds away the low-order bits ofp, and1 - (1-p)^(1/b)then cancels. Forp < 2^-53the quantile is0:Tests:
test/fixtures/julia/runner.jlthat evaluates the textbook formula(1 - (1-p)^(1/b))^(1/a)in 2048-bitBigFloat. It writes:data.json: randomp, withaandbin[0.5, 5.5],small_p.json:plog-spaced over[1e-300, 0.1]. Theavalues there are1,2,4and8, so1/ais exact and the test measures the error from1 - p. With a generala, rounding1/aalone moves the result by up to|ln w| / aULP, wherew = 1 - (1-p)^(1/b).// TODO: Add fixtures). They are replaced with tests against the fixtures.data(develop: 219) and 1 ULP onsmall_p(develop:0forp < 2^-53). Ondevelop, 1,077 of the 2,021 assertions intest.quantile.jsfail. With this change they all pass.Related Issues
None. Companion to #15767 (
kumaraswamy/cdf) and #15768 (kumaraswamy/logcdf).Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code. I found the bug by reading the
stats/base/distsfunctions for1 - pcancellation.@stdlib-js/reviewers