test: migrate stats/base/dists/negative-binomial/pmf to ULP-based assertions - #14101
Draft
kgryte wants to merge 1 commit into
Draft
test: migrate stats/base/dists/negative-binomial/pmf to ULP-based assertions#14101kgryte wants to merge 1 commit into
stats/base/dists/negative-binomial/pmf to ULP-based assertions#14101kgryte wants to merge 1 commit into
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/negative-binomial/pmffrom computed relative tolerance testing (delta = abs( y - expected[i] ),tol = k * EPS * abs( expected[i] ),t.strictEqual( delta <= tol, ... )) to ULP difference testing using@stdlib/assert/is-almost-same-value.test/test.pmf.jsandtest/test.factory.js, each of which contains four fixture loops (one per Julia fixture file).test/test.jscontains no tolerance math and is unchanged. The package has notest/test.native.js.@stdlib/math/base/special/absand@stdlib/constants/float64/epsrequires from both files (neither is used elsewhere in these files).ULP bounds (tightened to the measured minimum over the full fixture set):
fixtures/julia/high_high.jsonrandp655fixtures/julia/high_small.jsonr, smallp688fixtures/julia/small_high.jsonr, largep143fixtures/julia/small_small.jsonrandp110The main export and the factory-created function produce bit-identical results on every fixture value, so
test.pmf.jsandtest.factory.jsuse the same bound per fixture set.Notes on how the bounds were determined:
64and adjusting, the suite passes at the tabulated bounds and fails at each bound minus one (exactly four failing assertions, one per fixture loop), confirming the bounds are tight rather than merely sufficient.high_high:pmf( 1, 64, 0.7906898438417092 )returns3.975250904822743e-6against a reference of3.975250904823298e-6.high_small:pmf( 8, 88, 0.02637417550853125 )returns1.1366780042760316e-128against a reference of1.1366780042759434e-128.small_high:pmf( 14, 3, 0.9980475521581332 )returns1.3955555222417722e-36against a reference of1.3955555222417961e-36.small_small:pmf( 9, 13, 0.0038654584213952074 )returns1.2210093592394756e-26against a reference of1.2210093592394914e-26.650.0 * EPS,450.0 * EPS,80.0 * EPS, and80.0 * EPS; since a relative tolerance ofk * EPScorresponds to roughly2kULP, the measured bounds sit within the accuracy budget the tests already allowed. Thehigh_smallset is the one case where the measured error exceeds the naivek-to-ULP reading of the old multiplier, because the old comparison was relative toabs( expected[i] )rather than to the representable gap at that magnitude.binomcoefln/gammaln-based log terms followed by exponentiation, so argument reduction amplifies the error of the underlying kernels for largerand for smallp.test.pmf.js, 4026 fortest.factory.js, and 3 fortest.js, all passing, per run), so the bounds are not sensitive to FMA/contraction differences on this machine.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
One point:
110through688), so this PR keeps a per-fixture-loop bound rather than collapsing to a single package-wide maximum. That matches the per-loop tolerances the tests previously carried, but if reviewers would prefer one bound per file,688would cover all four sets at the cost of loosening the three tighter loops.Other
make test TESTS_FILTER=".*/stats/base/dists/negative-binomial/pmf/.*". Linting is clean viamake lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/negative-binomial/pmf/.*", which usesetc/eslint/.eslintrc.tests.js.editorconfigpre-commit hook could not run in this environment, as it downloads its binary from a host this session cannot reach. The two files were instead checked against.editorconfig(LF endings, tab indentation, final newline, UTF-8, no trailing whitespace); the diff introduces no new violations.stats/base/dists/hypergeometric/pmf(test: migratestats/base/dists/hypergeometric/pmfto ULP-based assertions #14091) andstats/base/dists/halfnormal/stdev(test: migratestats/base/dists/halfnormal/stdevto ULP-based assertions #14084), which use an inline integer ULP argument per fixture loop and the'returns expected value'assertion message.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. The test migration follows the idiom established by previously merged conversions, and the ULP bounds were measured empirically against the fixture data rather than guessed.
@stdlib-js/reviewers