Skip to content

test: tighten fixture tolerances in stats/base/dists/lognormal/pdf - #15577

Merged
kgryte merged 1 commit into
stdlib-js:developfrom
anandkaranubc:tighten-lognormal-pdf-tolerances
Sep 27, 2026
Merged

kgryte merged 1 commit into
stdlib-js:developfrom
anandkaranubc:tighten-lognormal-pdf-tolerances

Conversation

@anandkaranubc

Copy link
Copy Markdown
Contributor

Resolves stdlib-js/metr-issue-tracker#1377

Description

What is the purpose of this pull request?

This pull request:

  • Lowers the fixture test tolerances in stats/base/dists/lognormal/pdf from 800/1489/305 ULP to 4 ULP in test/test.pdf.js, test/test.factory.js, and test/test.native.js. The old tolerances matched the error of the previous implementation; after fix: avoid overflow and duplicate computation #14446 changed the formula, the measured maximum error against the same fixtures is 4 ULP.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

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.

Measured maximum error per fixture (JS main, factory, and a freshly built native add-on): 4 ULP for positive_location.json, negative_location.json, and large_variance.json.

One caveat for the native bound: the 4 ULP figure holds wherever the compiler does not contract floating-point expressions — x86-64 CI (no FMA in the baseline ISA) and any build with -ffp-contract=off. On arm64 with default flags, FMA contraction shifts the compiled ln by 1 ULP at one positive_location input, which exp( z ) at z ≈ -386 amplifies to ~1986 ULP in the pdf. This is a property of the toolchain, not of this package (the previous 800 ULP bound already failed that case on such builds); local arm64 runs reproduce the 4 ULP bound with CFLAGS="-ffp-contract=off" make install-node-addons.

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

@stdlib-js/reviewers

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: passed
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@anandkaranubc
anandkaranubc requested a review from a team September 27, 2026 00:43
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Sep 27, 2026
@anandkaranubc anandkaranubc added METR Pull request associated with the METR project. Tests Pull requests specifically adding tests. labels Sep 27, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/lognormal/pdf $\\color{green}315/315$
$\\color{green}+100.00\\%$
$\\color{green}23/23$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}315/315$
$\\color{green}+100.00\\%$

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

@kgryte kgryte added review: 5 and removed Needs Review A pull request which needs code review. labels Sep 27, 2026

@kgryte kgryte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the follow-up, @anandkaranubc!

@kgryte
kgryte merged commit 5b8d729 into stdlib-js:develop Sep 27, 2026
114 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. METR Pull request associated with the METR project. review: 5 Statistics Issue or pull request related to statistical functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tighten test tolerances in stats/base/dists/lognormal/pdf

3 participants