Skip to content

test: migrate stats/base/dists/halfnormal/entropy to ULP-based assertions - #14612

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-halfnormal-entropy
Aug 25, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-stats-base-dists-halfnormal-entropy

Conversation

@kgryte

@kgryte kgryte commented Aug 25, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

ULP bound: 2 (both test/test.js and test/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 isAlmostSameValue across the full SciPy fixture set (1000 values), the minimum admissible bound is exactly 2. The distribution of ULP differences over the fixtures is:

  • 0 ULP (bit-identical to the SciPy reference): 961 values
  • 1 ULP: 36 values
  • 2 ULP: 3 values

The largest ULP difference is therefore 2, attained at sigma = 3.3000421880500923 (returned 1.9197266052930475 vs. expected 1.919726605293048). Lowering the bound to 1 was confirmed to fail (3 failing assertions out of 1006 per suite), so the bound cannot be tightened further. The suite was then run twice at the final bound with identical results (1006/1006 passing per suite in each run), so the bound is not sensitive to run-to-run variation.

The previous relative tolerance was 1.5 * EPS * abs( expected[ i ] ), which corresponds to roughly 1.5–3 ULP depending on where the expected value falls within its binade, so 2 sits within the prior accuracy budget rather than loosening it.

To confirm that 2 is also correct for the C implementation, the native addon was compiled locally and test/test.native.js was executed against the real addon rather than being skipped: it likewise passes all 1006 assertions at 2 ULP, twice, and bisecting the native results independently also yields 2 as the minimum, with the worst case at the same fixture index. This matches the sibling conversions in this family (beta/entropy, binomial/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

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.

Notes on local verification:

  • make install-node-modules initially failed in this environment because the local npm cache held a stale packument for es-object-atoms, causing es-object-atoms@^1.1.2 to 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 the editorconfig-checker binary 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.
  • eslint --config etc/eslint/.eslintrc.tests.js reports no problems for either file.
  • make test TESTS_FILTER=".*/stats/base/dists/halfnormal/entropy/.*" passes (1006/1006).

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 helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".

This PR was authored by Claude Code running as an unattended scheduled task. It studied previously merged conversions under #11352 (including the beta/entropy and binomial/entropy siblings) 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

@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 25, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/halfnormal/entropy $\\color{green}168/168$
$\\color{green}+100.00\\%$
$\\color{green}8/8$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}168/168$
$\\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 25, 2026
@kgryte
kgryte marked this pull request as ready for review August 25, 2026 06:41
@kgryte
kgryte requested a review from a team August 25, 2026 06:41
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Aug 25, 2026
@kgryte
kgryte merged commit ada926b into develop Aug 25, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-stats-base-dists-halfnormal-entropy branch August 25, 2026 06:42
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Aug 25, 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