Skip to content

test: migrate stats/base/dists/bradford/mean to ULP-based assertions - #15248

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-bradford-mean
Sep 15, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-bradford-mean

Conversation

@kgryte

@kgryte kgryte commented Sep 15, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Final ULP constant: 9, for both fixture loops (test.js and test.native.js).

The bound was tightened by starting high (64) and lowering it to the minimum integer which still passes over the full fixture set. The Python fixture set contains 1000 cases, and the measured maximum ULP difference against the reference values was 9 for both the JavaScript and the C implementation:

implementation cases measured max ULP diff ULP bound used
test.js (JS) 1000 9 9
test.native.js (C) 1000 9 9

The two implementations agree exactly: the per-case ULP distribution is identical for both, namely

ULP diff 0 1 2 3 4 5 6 7 8 9
cases 938 17 22 12 5 1 2 1 1 1

9 is the tightest passing bound: a bound of 8 fails one assertion in each file, and 7 fails two. The worst case is c = 0.2585585585585586, where the returned value is 0.4808529480326162 against a reference value of 0.4808529480326157.

The previous relative tolerance was 4.7 * EPS * abs( expected[ i ] ), which is a comparable accuracy budget (4.7 * EPS relative error corresponds to roughly 9 ULP near the lower end of a binade).

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.

  • Only the two test files are changed; no source, fixture, or documentation changes.
  • The idiom mirrors the already-migrated sibling package stats/base/dists/bradford/median, including the placement of the @stdlib/assert/is-almost-same-value require.
  • test/test.js and test/test.native.js each pass 1006/1006 assertions at the final ULP bound. The suite was run twice at that bound with identical results, to rule out arch/FMA nondeterminism.
  • The native add-on was built locally (node-gyp rebuild) so that test/test.native.js actually executed rather than being skipped, which is what confirms the 9 bound for the C implementation.
  • make install-node-modules could not complete in the development environment used here: the registry mirror reachable from this environment serves es-object-atoms only up to 1.1.1, while a transitive dependency requires ^1.1.2, so npm reports ETARGET. tape and the lint tooling were therefore provided out of tree, and the tests were run directly against the package. This is an environment limitation only; no dependency or lockfile in the repository was modified.
  • Linting: the changed files were checked with ESLint 8.57 using the repository's own etc/eslint/.eslintrc.tests.js rule set (282 rules), with the in-repo stdlib plugin's rules omitted because that plugin's remark-lint-* dependency chain could not be installed in this environment. The result is 0 errors and 0 warnings. The rule set used was verified to be live by a negative control (an injected unused variable was correctly reported). Reviewers may wish to confirm the full make lint and the native tests on CI.

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, which selected the package, mirrored the idiom used by the already-migrated sibling package stats/base/dists/bradford/median, measured the minimum passing ULP bound over the full fixture set for both the JavaScript and the C implementation, and verified the tests and linting locally.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_016N9p5gjiRoDs5L3nHixpuB


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

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/bradford/mean $\\color{green}180/180$
$\\color{green}+100.00\\%$
$\\color{green}8/8$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}180/180$
$\\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 Sep 15, 2026
@kgryte
kgryte marked this pull request as ready for review September 15, 2026 23:51
@kgryte
kgryte requested a review from a team September 15, 2026 23:51
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 15, 2026
@kgryte
kgryte merged commit 5fd9c03 into develop Sep 15, 2026
82 checks passed
@kgryte
kgryte deleted the kgryte/ulp-bradford-mean branch September 15, 2026 23:52
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 15, 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