Skip to content

test: migrate stats/base/dists/beta/pdf to ULP-based assertions - #15848

Merged
kgryte merged 1 commit into
developfrom
kgryte/ulp-beta-pdf
Oct 12, 2026
Merged

kgryte merged 1 commit into
developfrom
kgryte/ulp-beta-pdf

Conversation

@kgryte

@kgryte kgryte commented Oct 3, 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/beta/pdf from relative tolerance assertions (delta <= tol, where tol = N * EPS * abs( expected[ i ] )) to ULP-based assertions using @stdlib/assert/is-almost-same-value.
  • updates test/test.pdf.js, test/test.factory.js, and test/test.native.js. Only test files are changed; no implementation, fixture, or documentation changes are included.

Each ULP bound is the measured minimum which passes over the full fixture set (1000 values per fixture). The minimum was determined by computing ulpDifference( actual, expected ) for every fixture value and taking the maximum; for each bound below, N passes and N-1 fails:

Test file Fixture Previous tolerance ULP bound (measured minimum)
test.pdf.js both_large.json 180.0 * EPS 245
test.pdf.js large_alpha.json 150.0 * EPS 153
test.pdf.js large_beta.json 150.0 * EPS 226
test.factory.js both_large.json 180.0 * EPS 245
test.factory.js large_alpha.json 150.0 * EPS 160
test.factory.js large_beta.json 150.0 * EPS 226
test.native.js both_large.json 180.0 * EPS 245
test.native.js large_alpha.json 150.0 * EPS 153
test.native.js large_beta.json 150.0 * EPS 226

Notes:

  • The large_alpha bound is 160 in test.factory.js versus 153 in test.pdf.js. The factory-created function and the main export evaluate the pdf in a different order for the same inputs, yielding a slightly different result for x = 0.5585154674819639, alpha = 15.443236158393903, beta = 9.67752027613441.
  • The native add-on was built locally (make install-node-addons NODE_ADDONS_PATTERN="stats/base/dists/beta/pdf") and the C implementation reproduced the JavaScript results exactly, so test.native.js uses the same bounds as test.pdf.js.
  • The test suite was run twice at the final bounds, producing identical results (9093 passing assertions, 0 failing) in both runs.

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.

  • make test TESTS_FILTER=".*/stats/base/dists/beta/pdf/.*" passes (run twice).
  • make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/beta/pdf/.*" is clean.
  • EditorConfig linting could not run in the authoring environment because the editorconfig-checker binary download was blocked by a network policy. The changed files were instead checked manually for LF line endings, tab indentation, no new trailing whitespace, and a final newline.

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 written by Claude Code running as an unattended scheduled task. The test edits, the ULP minimization, and the verification runs described above were all performed by Claude Code; the migration idiom was mirrored from previously merged conversions in this family (e.g. #15656, stats/base/dists/beta/logpdf).


@stdlib-js/reviewers

🤖 Generated with Claude Code

https://claude.ai/code/session_01HhsK6pmAqQ5LtJMuHQMo7E


Generated by Claude Code

Ref: #11352

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

---
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 Statistics Issue or pull request related to statistical functionality. Good First PR A pull request resolving a Good First Issue. labels Oct 3, 2026
@stdlib-bot

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/beta/pdf $\\color{green}387/387$
$\\color{green}+100.00\\%$
$\\color{green}47/47$
$\\color{green}+100.00\\%$
$\\color{green}4/4$
$\\color{green}+100.00\\%$
$\\color{green}387/387$
$\\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 Oct 12, 2026
@kgryte
kgryte marked this pull request as ready for review October 12, 2026 13:24
@kgryte
kgryte requested a review from a team October 12, 2026 13:24
@kgryte
kgryte merged commit 159f303 into develop Oct 12, 2026
66 checks passed
@kgryte
kgryte deleted the kgryte/ulp-beta-pdf branch October 12, 2026 13:24
@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. and removed Needs Review A pull request which needs code review. labels Oct 12, 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