Skip to content

test: migrate stats/base/dists/gamma/variance to ULP-based assertions - #15877

Draft
kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-gamma-variance
Draft

kgryte wants to merge 1 commit into
developfrom
kgryte/ulp-gamma-variance

Conversation

@kgryte

@kgryte kgryte commented Oct 4, 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/gamma/variance from relative tolerance testing to ULP difference testing, replacing the computed delta/tol comparisons with @stdlib/assert/is-almost-same-value.
  • applies the same change to both test/test.js and test/test.native.js.
  • uses a ULP bound of 2 in both test files. This is the measured minimum: the maximum required ULP difference over the full 200-case Julia fixture set is exactly 2 ULPs for both the JavaScript and the native implementation, and a bound of 1 ULP fails 16 of the 200 fixture cases. The previous tolerance was 2.0 * EPS * abs( expected[ i ] ), so the bound is unchanged in spirit.

Measurements were taken with the native add-on built locally, so the native implementation was exercised rather than skipped. Both implementations compute alpha / ( beta*beta ), which involves no fused multiply-add opportunity, and the measured ULP difference was identical for the two across repeated runs.

Only the two test files are changed.

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 package test suite was run twice at the final ULP bound to confirm determinism (214 assertions passing in each of test/test.js and test/test.native.js on both runs), and make lint-javascript-tests is clean for both files.

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 mirrored the migration idiom from previously merged conversions in the same family (e.g. stats/base/dists/exponential/variance) and determined the minimum passing ULP bound empirically.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01VjahTDGZsmsCpa2WPiWmGP


Generated by Claude Code

Replace computed relative tolerance comparisons with ULP-based
assertions using `@stdlib/assert/is-almost-same-value`. The ULP bound
was tightened to the measured minimum of 2 ULPs for both the JavaScript
and native implementations over the full 200-case fixture set.

Ref: #11352

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VjahTDGZsmsCpa2WPiWmGP
@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 Oct 4, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/gamma/variance $\\color{green}192/192$
$\\color{green}+100.00\\%$
$\\color{green}10/10$
$\\color{green}+100.00\\%$
$\\color{green}2/2$
$\\color{green}+100.00\\%$
$\\color{green}192/192$
$\\color{green}+100.00\\%$

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

This branch has not been deployed

No deployments
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants