Skip to content

test: migrate stats/base/dists/logistic/mgf to ULP-based assertions - #15132

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-stats-base-dists-logistic-mgf
Draft

test: migrate stats/base/dists/logistic/mgf to ULP-based assertions#15132
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-stats-base-dists-logistic-mgf

Conversation

@kgryte

@kgryte kgryte commented Sep 9, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

  • migrates the tests for stats/base/dists/logistic/mgf from relative tolerance testing to ULP difference testing.

Changes are limited to the package's test files:

  • test/test.mgf.js
  • test/test.factory.js
  • test/test.native.js

In each fixture loop, the delta/tol computation and the y === expected[i] special case are replaced with a single assertion:

t.strictEqual( isAlmostSameValue( y, expected[ i ], 3 ), true, 'returns expected value' );

The @stdlib/assert/is-almost-same-value require is added, and the now unused @stdlib/math/base/special/abs and @stdlib/constants/float64/eps requires are removed. No fixtures, implementations, or test cases were otherwise modified.

ULP bound: 3, applied uniformly across all three test files.

This is the measured minimum. Maximum observed ULP difference over the full fixture set (3 fixtures x 1000 values, evaluated against both lib/main.js and lib/factory.js):

Fixture max ULP (JS) max ULP (C)
positive_mean.json 2 2
negative_mean.json 2 2
large_variance.json 3 3

Tightness was confirmed by re-running the suite at lower bounds: 2 fails (1 assertion), 1 fails (156), and 0 fails (621). The suite was run twice at 3 with identical results (3011 passing assertions in test.mgf.js, 3017 in test.factory.js, 0 failures), so the bound is not sensitive to run-to-run variation.

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?

No.

Other

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

The C implementation (src/main.c) mirrors the JS implementation exactly (exp( mu*t ) / sinc( s*t )). Because the Node addon was not built in the environment used to prepare this PR, test/test.native.js skipped locally. To avoid guessing at the native bound, the C routine was compiled into a standalone harness and evaluated against the same fixtures; it agrees with the JS implementation and also peaks at 3 ULP, which is why test.native.js uses the same constant.

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

This PR was authored by Claude Code running as an unattended scheduled task. The test migration, the ULP bound measurement, and this description were produced by Claude Code; the ULP bound was determined empirically by measuring the fixture set and verifying that lower bounds fail.


@stdlib-js/reviewers


Generated by Claude Code

Replace relative tolerance comparisons with `isAlmostSameValue` ULP-based
assertions across the package's test files. The bound is tightened to the
measured minimum of 3 ULP over the full fixture set.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014tDJcwG5Ru7a73zmYG7pba
@stdlib-bot stdlib-bot added Good First PR A pull request resolving a Good First Issue. Statistics Issue or pull request related to statistical functionality. and removed Good First PR A pull request resolving a Good First Issue. labels Sep 9, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/logistic/mgf $\\color{green}306/306$
$\\color{green}+100.00\\%$
$\\color{green}22/22$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}306/306$
$\\color{green}+100.00\\%$

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants