test: migrate stats/base/dists/normal/mean to ULP-based assertions - #14472
Merged
Conversation
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
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
marked this pull request as ready for review
August 21, 2026 10:24
This was referenced Aug 21, 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.
Resolves a part of #11352.
Description
This pull request:
@stdlib/stats/base/dists/normal/meanfrom relative-tolerance assertions to ULP-based assertions using@stdlib/assert/is-almost-same-value, per the guidance in [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.test/test.jsandtest/test.native.jsto 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 existingexpected[i] !== nullfixture guard.1.0 * EPS * abs( expected[ i ] )tolerance loops in both files witht.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' ).@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.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
muverbatim once theNaN/nonpositive-sigmaguards are cleared, so no rounding is introduced and the previous tolerance branch was never taken.Both
test/test.jsandtest/test.native.jswere run twice at the finalN = 0(110 assertions each, all passing, with the native add-on built) to confirm the bound is deterministic. Linting viamake lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/normal/mean/.*"is clean, and only the two test files are changed.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
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