Repository navigation
test: migrate stats/base/dists/chi/skewness to ULP-based assertions - #15828
Merged
Merged
Conversation
Replace the computed relative-tolerance comparisons in `test/test.js` and `test/test.native.js` with `isAlmostSameValue` assertions. The ULP bound of `12890` is the measured minimum over the full fixture set for both the JavaScript and C implementations. Ref: #11352 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016FowxTcTEq1WLD4Vqu5hFD
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
marked this pull request as ready for review
October 12, 2026 13:31
Member
Author
|
We should investigate the accuracy issues mentioned in the OP. |
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.
Description
This pull request:
stats/base/dists/chi/skewnessfrom computed relative-tolerance comparisons to ULP-based assertions, per [RFC]: Migratemath/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352.if ( y === expected[i] ) { ... } else { delta = abs( y - expected[i] ); tol = 1e-11 * abs( expected[i] ); t.ok( delta <= tol, ... ); }branches intest/test.jsandtest/test.native.jswith a singlet.strictEqual( isAlmostSameValue( y, expected[ i ], 12890 ), true, 'returns expected value' );assertion.@stdlib/assert/is-almost-same-valuerequire and removes the now-unused@stdlib/math/base/special/absrequire, along with thedelta/toldeclarations.ULP bound
12890(used in bothtest/test.jsandtest/test.native.js).12890is the measured minimum. It was determined by bisecting the ULP bound over the complete 50-pointtest/fixtures/julia/data.jsonfixture set. The worst-case point is fixture index16(k = 18.567573180927845, returned0.1696036355271358vs. expected0.16960363552749358).N = 12890the JavaScript suite reports56passing assertions and0failures and the native suite reports55passing and0failures; atN = 12889exactly one assertion fails in each file — the worst-case point.make install-node-addons) so thattest/test.native.jsactually exercises the C implementation rather than skipping. The C implementation mirrors the JavaScript implementation operation for operation, and bottoms out at the same minimum of12890.N = 12890with identical results, confirming the bound is not sensitive to FMA/arch variation on this platform.1e-11 * abs( expected[i] ), which corresponds to roughly4.5e4ULP, so the new bound is a meaningful tightening of what this suite previously accepted.Verification
make test TESTS_FILTER=".*/stats/base/dists/chi/skewness/.*"→56 / 56passing fortest/test.jsand55 / 55passing fortest/test.native.js(two consecutive runs).make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/chi/skewness/.*"→ clean, exit0.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
12890ULP is large in absolute terms. It is the tightest value that passes the existing fixtures, and it is roughly 3.5x tighter than the1e-11relative tolerance it replaces, so it is a strict improvement over the status quo. The magnitude comes from the implementation itself:skewnesscomposeschi/meanandchi/varianceand then evaluates( mu / sigma3 ) * ( 1 - 2*sigma2 ), where the1 - 2*sigma2factor cancels catastrophically askgrows. If reviewers would prefer the underlying accuracy be investigated rather than codified, happy to split that out into a separate issue.Other
stats/base/dists/weibull/skewness,stats/base/dists/planck/variance,stats/base/dists/chisquare/quantile): an inline numeric ULP literal rather than a named constant, the same bound shared betweentest.jsandtest.native.js, and the standardized'returns expected value'assertion message.pre-commitEditorConfig hook could not run in this environment, because it downloads theeditorconfig-checkerbinary from a GitHub repository outside this session's allowed scope. EditorConfig conformance was therefore checked manually for both files: LF line endings, UTF-8, tab indentation, no trailing whitespace, and a single final newline.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written by Claude Code running as an unattended scheduled task. It selected the package, mirrored the conversion idiom from previously merged PRs in the same family, measured the minimum ULP bound by bisection over the fixture set, built the native add-on to confirm the same bound holds for the C implementation, and verified the tests and linting.
@stdlib-js/reviewers
Generated by Claude Code