Skip to content

test: migrate stats/base/dists/logistic/pdf to ULP-based assertions - #15024

Merged
kgryte merged 2 commits into
developfrom
kgryte/ulp-logistic-pdf
Sep 6, 2026
Merged

test: migrate stats/base/dists/logistic/pdf to ULP-based assertions#15024
kgryte merged 2 commits into
developfrom
kgryte/ulp-logistic-pdf

Conversation

@kgryte

@kgryte kgryte commented Sep 6, 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/pdf from relative tolerance testing (delta/tol computed from EPS) to ULP difference testing using @stdlib/assert/is-almost-same-value.
  • updates test/test.pdf.js, test/test.factory.js, and test/test.native.js. No other files are changed, and no source, benchmark, example, or documentation files are touched.

The ULP bound used in every migrated assertion is 4, and this is the measured minimum. Across all three Julia fixture sets (positive_mean, negative_mean, large_variance; 2980 compared values after applying the existing null/underflow guards), the maximum observed ULP difference between the returned value and the expected value is exactly 4, for both the main export and the function returned by factory. Lowering the bound to 3 produces 14 failures; 4 is therefore the tightest integer bound that passes over the full fixture set.

The previous per-loop tolerances were 3.0 * EPS for the positive-/negative-mean fixtures and 3.0 * EPS for the large-variance fixture, so the new bound is a comparable, and in ULP terms tighter and better-defined, accuracy budget.

The full package test suite (6002 assertions) passes, and was run twice at the final bound with identical results, 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?

  • test/test.native.js is skipped locally because the native add-on was not built in this environment. To avoid guessing at the bound for the C implementation, src/main.c was compiled directly against its declared dependency closure and evaluated over the same fixtures: the maximum ULP difference is also 4 at -O0, -O2, -O3, and -O3 -ffp-contract=fast -march=native (i.e., with FMA contraction enabled), so the same bound of 4 is used in test/test.native.js. Reviewers may wish to confirm this against a real add-on build.

Other

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

  • The existing guard conditions (expected[i] !== null and !(expected[i] === 0.0 && y < EPS)) are preserved unchanged, so the set of compared values is exactly the same as before. The EPS import is retained for those guards; the now-unused abs import is replaced by the isAlmostSameValue import.
  • The change mirrors the idiom settled on in prior conversions in this family, e.g. stats/base/dists/levy/pdf (test: migrate stats/base/dists/levy/pdf to ULP-based assertions #14985).

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 written by Claude Code, running unattended as a scheduled task. The ULP bound was determined empirically by measuring the maximum ULP difference over the full fixture set rather than by guessing, and was verified by confirming that the next lower bound fails.


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01N5UvaSs85zP3Le1hoAaHvK


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

stdlib-bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/logistic/pdf $\\color{green}314/314$
$\\color{green}+0.00\\%$
$\\color{green}29/29$
$\\color{green}+0.00\\%$
$\\color{green}4/4$
$\\color{green}+0.00\\%$
$\\color{green}314/314$
$\\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 6, 2026
@kgryte
kgryte marked this pull request as ready for review September 6, 2026 03:27
@kgryte
kgryte requested a review from a team September 6, 2026 03:27
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Sep 6, 2026
Comment thread lib/node_modules/@stdlib/stats/base/dists/logistic/pdf/test/test.factory.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/logistic/pdf/test/test.factory.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/logistic/pdf/test/test.native.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/logistic/pdf/test/test.native.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/logistic/pdf/test/test.pdf.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/logistic/pdf/test/test.pdf.js Outdated
Co-authored-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
@kgryte
kgryte merged commit fa314b2 into develop Sep 6, 2026
12 checks passed
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 6, 2026
@kgryte
kgryte deleted the kgryte/ulp-logistic-pdf branch September 6, 2026 03:32
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