Repository navigation
fix: avoid overflow in stats/base/dists/rayleigh/quantile - #14480
Merged
Merged
Conversation
Propagates fix from f51d7fe ("fix: avoid overflow and duplicate computation") to the Rayleigh quantile function, which computed an unnecessary intermediate `sigma*sigma` that overflows to infinity for `sigma > ~1.34e154` (returning `Infinity` for all probabilities) and underflows for `sigma < ~1.5e-154` (returning `0`). Factoring `sigma` out of the square root avoids the squaring entirely. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TXQVJeeR1SEeUHiN9Q58eY
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
approved these changes
Aug 22, 2026
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:
developbetween 2026-08-20 and 2026-08-21 to sibling packages.Propagates the overflow fix from f51d7fe (#14446) to
@stdlib/stats/base/dists/rayleigh/quantile. Computingsigma*sigmaoverflows forsigma > ~1.34e154, returningInfinityfor everyp, and underflows to0forsigma < ~1.5e-154; replacingsqrt( -2.0 * s2 * log1p( -p ) )withsigma * sqrt( -2.0 * log1p( -p ) )avoids the intermediate square and returns correct finite values across the fullsigmarange. Applied identically to the JSmain.js,factory.js, and Cmain.cimplementations; all 3000 Julia fixture values pass at the existing1.0 * EPStolerance.lib/node_modules/@stdlib/stats/base/dists/rayleigh/quantile/lib/main.jslib/node_modules/@stdlib/stats/base/dists/rayleigh/quantile/lib/factory.jslib/node_modules/@stdlib/stats/base/dists/rayleigh/quantile/src/main.cRelated Issues
No related issues.
Questions
No.
Other
Validation performed: signature search over
stats/base/dists/*forpow( sigma, 2.0 )/sigma * sigmakernels; two independent validation passes confirming the defect and guard preservation at each site (edge casessigma === 0,sigma === Infinity,p === 0,p === 1,NaNverified bit-identical); an adaptation pass producing per-file patches; and a style-consistency pass against the conventions of f51d7fe. Existing Julia fixtures were re-run against the patched code:0/3000failures for bothquantileandfactorypaths.Deliberately excluded:
rayleigh/{pdf,logpdf,cdf,logcdf}carry the samesigma^2overflow defect, but their test fixtures were generated by Julia code using the same squared-form algebra at0–2ULP tolerances, so the ratio-form fix shifts results by up to ~1180 ULP throughexp()amplification and fails 1–1146 of 3000 fixture assertions per package. Landing those requires loosening tolerances (as already done fornormal/*,lognormal/*, andhalfnormal/logpdf) or regenerating fixtures — a reviewer decision, so they are left out of this propagation.wald/logpdfwas checked and is already fixed (#14412).Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code as part of an automated fix-propagation routine: candidate sites were located by pattern search, validated by independent review passes, and verified against the existing Julia test fixtures before committing.
@stdlib-js/reviewers
Generated by Claude Code