Repository navigation
test: migrate stats/base/dists/normal/pdf to ULP-based assertions - #15437
Merged
Merged
Conversation
Migrate the tests for `stats/base/dists/normal/pdf` from relative tolerance assertions to ULP difference assertions using `@stdlib/assert/is-almost-same-value`. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AFE6m4JZPfvHrCqv6553Sp
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
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:
stats/base/dists/normal/pdffrom relative tolerance assertions to ULP difference assertions using@stdlib/assert/is-almost-same-value.test/test.pdf.js,test/test.factory.js, andtest/test.native.js, replacing thedelta/tolcomparison against5300.0 * EPS * abs( expected[i] )witht.strictEqual( isAlmostSameValue( y, expected[ i ], 250 ), true, 'returns expected value' );and dropping the now-unusedabsandEPSrequires.test/test.jsonly asserts the shape of the main export and contains no tolerance comparisons, so it is left unchanged.ULP bound
The ULP constant for all three test files is
250, which is the measured minimum over the full R fixture set (1000 cases):N = 249N = 250The JavaScript and C implementations return bit-identical results for all 1000 fixture cases, so a single bound applies to all three test files.
The worst case is
x = -78.37837837837837,mu = 5.455455455455455,sigma = 2.3000000000000003, where the returned value5.557011046698957e-290differs from the expected5.557011046698672e-290by 250 ULP. This case is far out in the tail (z ≈ -36.45), where the relative error inz^2 / 2 ≈ 664is amplified byexp, so a bound of this magnitude is expected; the previous relative tolerance of5300 * EPSwas roughly 21x looser.The native addon was compiled locally so that
test/test.native.jsexecuted against the C implementation rather than being skipped. The suite was run twice atN = 250to confirm determinism (3068 passing assertions across the four test files on each run, no failures).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
Only the three test files are changed.
make test TESTS_FILTER=".*/stats/base/dists/normal/pdf/.*"is green, and all three files lint cleanly underetc/eslint/.eslintrc.tests.js. The EditorConfig linter could not be run in this environment because its binary could not be downloaded, so EditorConfig compliance (LF line endings, UTF-8, tab indentation, no trailing whitespace, final newline) was verified manually instead.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written primarily by Claude Code, which also measured the minimum ULP bound empirically against the fixture set and ran the test suite.
@stdlib-js/reviewers
Generated by Claude Code