Skip to content

test: migrate stats/base/dists/weibull/skewness to ULP-based assertions - #15484

Merged
kgryte merged 2 commits into
developfrom
kgryte/ulp-stats-base-dists-weibull-skewness
Sep 24, 2026
Merged

kgryte merged 2 commits into
developfrom
kgryte/ulp-stats-base-dists-weibull-skewness

Conversation

@kgryte

@kgryte kgryte commented Sep 24, 2026

Copy link
Copy Markdown
Member

Resolves a part of #11352.

Description

What is the purpose of this pull request?

This pull request:

Both test/test.js and test/test.native.js previously compared against a computed relative tolerance:

delta = abs( y - expected[ i ] );
tol = 1e-11 * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. ...' );

and now assert:

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

ULP constant: 36208 in both test/test.js and test/test.native.js.

This is the measured minimum over the full 500-value Julia fixture set, tightened empirically:

maxULP result
16384 4 failing
36206 1 failing
36207 1 failing
36208 514 passing, 0 failing

The JavaScript and C implementations were each measured independently against the fixtures and both peak at exactly 36208 ULP on the same input (k = 3.625597586389692, lambda = 2.9758629782847215), so a single constant is used for both test files.

The bound is larger than is typical for this migration because the Weibull skewness has a zero crossing near k ≈ 3.6. Around that root the result is computed via cancellation of same-magnitude terms

( Γ(1+3/k)·λ³ − 3·μ·σ² − μ³ ) / σ³

so the absolute error stays tiny (Δ ≈ 3.1e-17 at the worst case) while the ULP distance grows as the expected value approaches zero. The previous 1e-11 relative tolerance was approximately 45000 * EPS, so 36208 ULP is a tightening of the accepted error budget, not a loosening.

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.

Verification performed:

  • make test TESTS_FILTER=".*/stats/base/dists/weibull/skewness/.*" → 514 passing in test/test.js and 514 passing in test/test.native.js.
  • The native add-on was built locally (make install-node-addons NODE_ADDONS_PATTERN="stats/base/dists/weibull/skewness") so that test/test.native.js actually executes rather than being skipped.
  • The full suite was run twice at the final ULP value, with identical results both times, to confirm there is no FMA/architecture-dependent flakiness.
  • ESLint is clean against etc/eslint/.eslintrc.tests.js for both files.
  • Only the two test files are modified.

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. It studied the already-merged conversions in this family (e.g. stats/base/dists/binomial/skewness, stats/base/dists/geometric/variance, stats/base/dists/triangular/stdev) to match the established idiom, then determined the ULP bound empirically by bisecting on the measured maximum ULP difference over the fixture set and re-running the suite to confirm minimality and determinism.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_012ZDpXGX4VLAhBiWQNHMi81


Generated by Claude Code

…ions

Replace the relative tolerance assertions in `test/test.js` and
`test/test.native.js` with `@stdlib/assert/is-almost-same-value`, using
the minimum ULP bound which passes over the full fixture set.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012ZDpXGX4VLAhBiWQNHMi81

---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
  - task: lint_filenames
    status: passed
  - task: lint_editorconfig
    status: skipped
  - task: lint_markdown_pkg_readmes
    status: na
  - task: lint_markdown_docs
    status: na
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: na
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: na
  - task: lint_c_examples
    status: na
  - task: lint_c_benchmarks
    status: na
  - task: lint_c_tests_fixtures
    status: na
  - task: lint_shell
    status: na
  - task: lint_typescript_declarations
    status: passed
  - task: lint_typescript_tests
    status: na
  - task: lint_license_headers
    status: passed
---
@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. labels Sep 24, 2026
@stdlib-bot

stdlib-bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/weibull/skewness $\\color{green}210/210$
$\\color{green}+0.00\\%$
$\\color{green}10/10$
$\\color{green}+0.00\\%$
$\\color{green}2/2$
$\\color{green}+0.00\\%$
$\\color{green}210/210$
$\\color{green}+0.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 24, 2026
@kgryte
kgryte marked this pull request as ready for review September 24, 2026 08:50
@kgryte
kgryte requested a review from a team September 24, 2026 08:50
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 24, 2026
@kgryte
kgryte merged commit d3e9d24 into develop Sep 24, 2026
30 checks passed
@kgryte
kgryte deleted the kgryte/ulp-stats-base-dists-weibull-skewness branch September 24, 2026 09:08
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 24, 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.

2 participants