Skip to content

fix: avoid overflow in stats/base/dists/wald/logpdf - #14412

Draft
Planeshifter wants to merge 1 commit into
developfrom
philipp/fix-commit-review-2026-08-19
Draft

fix: avoid overflow in stats/base/dists/wald/logpdf#14412
Planeshifter wants to merge 1 commit into
developfrom
philipp/fix-commit-review-2026-08-19

Conversation

@Planeshifter

Copy link
Copy Markdown
Member

Description

What is the purpose of this pull request?

This pull request:

  • provides follow-up fixes for commits merged to develop between 2026-08-18 17:33 PDT (fd16a2f) and 2026-08-19 05:08 PDT (dd78acd). An automated review of the 25 commits in that window (style-guide compliance audit plus two independent bug scans over the union diff) surfaced one validated, high-signal issue.

stats/base/dists/wald/logpdf

  • Fixes a numerical overflow in 47b5192: the exponent term (lambda*v*v)/(mu*mu*x) overflows before dividing, so logpdf(1.0, 1e155, 1.0) returns NaN and logpdf(1e155, 1.0, 1.0) returns -Infinity instead of finite values, violating the documented NaN-only-on-invalid-input contract. Reassociated as ((lambda/x)*(v/mu))*(v/mu) in lib/main.js:97, lib/factory.js:83, and src/main.c:57; all 100 Julia fixtures still pass at 2 ULP.

Related Issues

Does this pull request have any related issues?

No.

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

Validation performed on the commit window:

  • Style-guide compliance audit (two independent passes) of all changed code against docs/style-guides and established reference packages (e.g., the new stats/base/dists/wald/* packages against stats/base/dists/wald/cdf and stats/base/dists/lognormal/*): no violations found.
  • Bug scan (two independent passes) of the union diff: verified the Wald quantile/logcdf/logpdf/stdev formulas and documented example values numerically, JS↔C parity, and the fromIndex index-resolution logic in blas/ext/base/ndarray/dfirst-index-less-than. Only the overflow above survived validation.
  • Deliberately excluded: subjective concerns, style preferences not required by the style guides, and anything requiring changes outside the window's diff to validate.

The fix was verified by reproducing the failure on the shipped code, re-running the reassociated implementation, and confirming all 100 Julia fixture cases pass at the tests' 2-ULP tolerance for both logpdf and logpdf.factory.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was produced by a scheduled automated commit-review run using Claude Code: agents reviewed the last 24 hours of commits merged to develop, and the fix in this PR was generated and validated by Claude Code. A human maintainer will audit before marking ready for review.


Generated by Claude Code

@stdlib-bot stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label Aug 19, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/wald/logpdf $\\color{green}327/327$
$\\color{green}+100.00\\%$
$\\color{green}33/33$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}327/327$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants