Skip to content

test: migrate stats/base/dists/normal/mean to ULP-based assertions - #14472

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-normal-mean
Aug 21, 2026
Merged

test: migrate stats/base/dists/normal/mean to ULP-based assertions#14472
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-normal-mean

Conversation

@kgryte

@kgryte kgryte commented Aug 21, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for @stdlib/stats/base/dists/normal/mean from relative-tolerance assertions to ULP-based assertions using @stdlib/assert/is-almost-same-value, per the guidance in [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • updates both test/test.js and test/test.native.js to mirror the idiom used in previously converted packages (e.g. stats/base/dists/frechet/variance, stats/base/dists/chi/stdev, stats/base/dists/weibull/stdev), retaining the existing expected[i] !== null fixture guard.
  • replaces the previous 1.0 * EPS * abs( expected[ i ] ) tolerance loops in both files with t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ).
  • drops the now-unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

The tightest ULP bound was determined empirically by measuring the maximum ULP difference over the full 100-value Julia fixture set:

  • test/test.js: N = 0 ULP. Every fixture value matches the Julia reference bit-for-bit, so the measured maximum ULP difference is 0, and 0 is the tightest bound expressible.
  • test/test.native.js: N = 0 ULP. The native add-on was built locally for this package so that the native tests were exercised rather than skipped, and the maximum ULP difference for the C implementation over the same fixtures is likewise 0.

This is expected: both implementations return mu verbatim once the NaN/nonpositive-sigma guards are cleared, so no rounding is introduced and the previous tolerance branch was never taken.

Both test/test.js and test/test.native.js were run twice at the final N = 0 (110 assertions each, all passing, with the native add-on built) to confirm the bound is deterministic. Linting via make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/normal/mean/.*" is clean, and only the two test files are changed.

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.

No.

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

Disclosure

This PR was authored by Claude Code (Anthropic) running as an unattended scheduled task. The conversion mirrors the exact idiom used in previously merged ULP migrations authored by the PR author (e.g. #14434, #14447, #14469), and the ULP bound was measured empirically against the existing Julia fixtures for both the JavaScript and the locally built C implementation.


@stdlib-js/reviewers


Generated by Claude Code

Replace computed relative-tolerance comparisons with `isAlmostSameValue`
ULP-based assertions in the fixture loops.

Both the JavaScript and the C implementations return `mu` verbatim, so
every fixture value matches the Julia reference exactly. The measured
minimum bound is thus 0 ULP for both test.js and test.native.js, which
is the tightest bound expressible.

Ref: #11352
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Good First PR A pull request resolving a Good First Issue. labels Aug 21, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/normal/mean $\\color{green}175/175$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}175/175$
$\\color{green}+100.00\\%$

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

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 21, 2026
@kgryte
kgryte marked this pull request as ready for review August 21, 2026 10:24
@kgryte
kgryte requested a review from a team August 21, 2026 10:24
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 21, 2026
@kgryte
kgryte merged commit d48c86a into develop Aug 21, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-stats-base-dists-normal-mean branch August 21, 2026 10:25
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 21, 2026
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. 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.

3 participants