Skip to content

test: migrate stats/base/dists/logistic/variance to ULP-based assertions - #14484

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-logistic-variance
Aug 22, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-logistic-variance

Conversation

@kgryte

@kgryte kgryte commented Aug 21, 2026

Copy link
Copy Markdown
Member

Ref #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for stats/base/dists/logistic/variance from computed floating-point tolerances to ULP-based assertions, per [RFC]: Migrate math/base/special packages from relative tolerance testing to ULP difference testing (tracking issue) #11352.
  • replaces the delta/tol (2.0 * EPS * abs( expected[i] )) comparison in test/test.js with isAlmostSameValue( y, expected[ i ], 3 ).
  • replaces the equivalent delta/tol comparison in test/test.native.js with isAlmostSameValue( y, expected[ i ], 3 ).
  • adds the @stdlib/assert/is-almost-same-value require and drops the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires.

Final ULP bound: 3 in both test/test.js and test/test.native.js.

Measured minimum: starting from a high bound and tightening, 3 is the minimum integer bound which passes over the full fixture set. Sweeping the bound over the 100 Julia fixture values gives, for both test files:

Bound test/test.js test/test.native.js
0 49 failing 49 failing
1 7 failing 7 failing
2 1 failing 1 failing
3 all pass all pass

The maximum observed ULP difference is 3 for both the JavaScript and the native implementation (worst case at mu = -3.790154994337721, s = 3.0019267654139057). The native add-on was built locally so that test/test.native.js actually executed rather than being skipped. The full suite (110 assertions in test/test.js, 111 in test/test.native.js) was run twice at the final bound with identical results, so no FMA/arch-related nondeterminism was observed on this platform (Linux x86-64, gcc).

That the two implementations agree exactly is expected: both evaluate ( s*s ) * PI_SQUARED / 3.0, which offers no multiply-add for a compiler to contract.

Only the two test files are modified; no source, documentation, benchmark, or fixture files are touched.

Related Issues

Does this pull request have any related issues?

This pull request has the following related issues:

Questions

Any questions for reviewers of this pull request?

  • The bound of 3 reflects the accuracy of the Julia reference values relative to the double-precision result of s^2 * pi^2 / 3, not an implementation deficiency. If reviewers would prefer a round number for readability over the measured minimum, 4 would leave a single ULP of headroom.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

  • Verification performed: package tests green (110/110 and 111/111 assertions, each run twice), lint clean via eslint --config etc/eslint/.eslintrc.tests.js over both files, and git status confirms only the two test files changed.

Checklist

Please ensure the following tasks are completed before submitting this pull request.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance.

This PR was written primarily by Claude Code, which selected the package, mirrored the conversion idiom used in previously converted packages, measured the ULP bound against the fixture set, and verified tests and linting.


@stdlib-js/reviewers


Generated by Claude Code

…tions

Replaces the computed EPS-scaled relative tolerance comparisons in both
the JavaScript and native tests with `isAlmostSameValue` assertions.
Over the full 100-value Julia fixture set, the maximum ULP difference is
3 for both the JavaScript and native implementations, so the tightest
passing bound is 3 ULP.

Ref: #11352

Claude-Session: https://claude.ai/code/session_01Q6vFzKDfHmLxXqHG2jScRi
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Good First PR A pull request resolving a Good First Issue. labels Aug 21, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/logistic/variance $\\color{green}176/176$
$\\color{green}+100.00\\%$
$\\color{green}9/9$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}176/176$
$\\color{green}+100.00\\%$

The above coverage report was generated for the changes in this PR.

@kgryte kgryte added the Tests Pull requests specifically adding tests. label Aug 22, 2026
@kgryte
kgryte marked this pull request as ready for review August 22, 2026 00:14
@kgryte
kgryte requested a review from a team August 22, 2026 00:14
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 22, 2026
@kgryte
kgryte merged commit b7c8197 into develop Aug 22, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-stats-base-dists-logistic-variance branch August 22, 2026 00:15
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Good First PR A pull request resolving a Good First Issue. Statistics Issue or pull request related to statistical functionality. Tests Pull requests specifically adding tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants