Repository navigation
test: migrate stats/base/dists/beta/entropy to ULP-based assertions - #14558
Merged
Merged
Conversation
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/beta/entropyfrom relative tolerance testing to ULP difference testing, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.delta/tolcomparisons intest/test.jsandtest/test.native.jswitht.strictEqual( isAlmostSameValue( y, expected[ i ], 384 ), true, 'returns expected value' );, adding the@stdlib/assert/is-almost-same-valuerequire and dropping the now unused@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires.ULP bound:
384(bothtest/test.jsandtest/test.native.js), the measured minimum over the fixture set.The bound was determined empirically rather than assumed. Starting from a high bound and bisecting downward over
isAlmostSameValueacross the full Julia fixture set (1000 values), the minimum admissible bound is exactly384: 401 of the 1000 returned values are bit-identical to the Julia reference, and the largest ULP difference among the remainder is384, attained atalpha = 10.003231427967421,beta = 13.875047324311737. Lowering the bound to383was confirmed to fail (3 failing assertions out of 1014), so the bound cannot be tightened further. The suite was then run twice at the final bound with identical results (1014/1014 passing per suite in each run), so the bound is not sensitive to run-to-run variation.The previous relative tolerance was
250.0 * EPS * abs( expected[ i ] ), which corresponds to roughly 250–500 ULP depending on where the expected value falls within its binade, so384sits within the prior accuracy budget rather than loosening it.To confirm that
384is also correct for the C implementation, the native addon was compiled locally viamake install-node-addons NODE_ADDONS_PATTERN="stats/base/dists/beta/entropy"andtest/test.native.jswas executed against the real addon rather than being skipped: it likewise passes all 1014 assertions at384ULP, twice, and bisecting the native results independently also yields384as the minimum. This matches the sibling conversions in this family (weibull/entropy,normal/entropy,logistic/entropy), which likewise use a single bound across both suites.Only the two test files are modified; no implementation, fixture, or documentation changes are included.
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
Notes on local verification:
make install-node-modulesinitially failed in this environment because the local npm cache held a stale packument fores-object-atoms, causinges-object-atoms@^1.1.2to resolve as nonexistent. Clearing the npm cache resolved it; no repository files were involved.make lint-editorconfig-files(run via the pre-commit hook) could not execute because theeditorconfig-checkerbinary download is blocked in this environment. The changed files were instead checked manually for indentation (tabs), trailing whitespace, line endings (LF), and final newline, and match the surrounding files exactly.make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/beta/entropy/.*"reports no problems for either file.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was authored by Claude Code running as an unattended scheduled task. It studied previously merged conversions under #11352 (including the
weibull/entropyandrayleigh/cdfsiblings) to match the established idiom, applied the migration, measured the minimum ULP bound empirically against the fixtures for both the JavaScript and the locally compiled C implementation, and verified that the tests pass and that the files lint cleanly.@stdlib-js/reviewers
Generated by Claude Code