Skip to content

feat(stats): add C implementation for stats/base/dists/hypergeometric/cdf - #10341

Merged
Planeshifter merged 13 commits into
stdlib-js:developfrom
whizzel:hypergeometric-cdf
Sep 2, 2026
Merged

Planeshifter merged 13 commits into
stdlib-js:developfrom
whizzel:hypergeometric-cdf

Conversation

@whizzel

@whizzel whizzel commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #3659 .

Description

What is the purpose of this pull request?

This pull request:

  • Adds a C implementation of the hypergeometric cdf.
  • Includes benchmarks for the C implementation.
  • Provides examples demonstrating the usage of the hypergeometric cdf in C.

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.

No.

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.".

{{TODO: add disclosure if applicable}}


@stdlib-js/reviewers

@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. Needs Review A pull request which needs code review. and removed Good First PR A pull request resolving a Good First Issue. labels Feb 18, 2026
@whizzel whizzel closed this Feb 18, 2026
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Feb 18, 2026
…/cdf

---
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: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: na
  - task: lint_repl_help
    status: na
  - task: lint_javascript_src
    status: passed
  - task: lint_javascript_cli
    status: na
  - task: lint_javascript_examples
    status: na
  - task: lint_javascript_tests
    status: passed
  - task: lint_javascript_benchmarks
    status: passed
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: missing_dependencies
  - task: lint_c_examples
    status: missing_dependencies
  - task: lint_c_benchmarks
    status: missing_dependencies
  - 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
---
@whizzel whizzel reopened this Feb 18, 2026
---
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: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: passed
  - 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: na
  - task: lint_javascript_benchmarks
    status: na
  - task: lint_python
    status: na
  - task: lint_r
    status: na
  - task: lint_c_src
    status: missing_dependencies
  - 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 commented Feb 18, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/hypergeometric/cdf $\\color{green}446/446$
$\\color{green}+0.00\\%$
$\\color{green}48/48$
$\\color{green}+0.00\\%$
$\\color{green}5/5$
$\\color{green}+0.00\\%$
$\\color{green}446/446$
$\\color{green}+0.00\\%$

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

---
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: passed
  - task: lint_markdown
    status: na
  - task: lint_package_json
    status: passed
  - 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: na
  - 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
---
@whizzel whizzel changed the title feat(stats): add C implementation for stats/base/dists/hypergeometric/cdf feat(stats): add C implementation for stats/base/dists/hypergeometric/cdf Feb 18, 2026
@whizzel

whizzel commented Feb 25, 2026

Copy link
Copy Markdown
Contributor Author

@kgryte a quick review plz!

Copilot AI review requested due to automatic review settings April 9, 2026 11:58

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Fix manifest.json indentation to 2-space convention
- Remove unused pinf dependency, add missing is-infinite dependency
- Add trunc and is-infinite to benchmark/examples dependency lists
- Add missing stdint.h include in example.c
- Add blank line between license header and includes in main.c
- Split combined variable declarations to one per line
- Change benchmark parameter arrays from int32_t to double to match function signature

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Planeshifter
Planeshifter requested a review from a team September 2, 2026 19:27
Planeshifter and others added 6 commits September 2, 2026 14:51
- Handle negative infinity in CDF (was UB: trunc(-Inf) cast to int32_t)
- Add direct stdint.h include in main.c instead of relying on transitive include
- Remove unnecessary stdint.h from cdf.h (signature is all-double)
- Fix operator spacing in main.c and example.c to match stdlib convention
- Change t.equal to t.strictEqual in test.native.js
- Normalize assertion messages to 'returns expected value' in test.native.js

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Change N, K, n parameters from double to int32_t to match the sibling PMF
  function signature and DIII_D NAPI convention
- Update addon.c macro from DDDD_D to DIII_D
- Remove is-nonnegative-integer dependency (integer validation now uses
  direct comparisons on int32_t, matching PMF pattern)
- Restore int32_t benchmark arrays (matching PMF benchmark)
- Eliminates the double-to-int32_t casts that were in the function body

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
With int32_t parameters, the NAPI layer converts JS values before the C
function receives them (NaN->0, 30.5->30, PINF->INT_MAX). Remove tests
for NaN/fractional/infinite parameter values that can only be validated
on the JS side. Keep negative integer tests which are still caught by
the C validation. Matches the PMF test.native.js pattern.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Add C APIs section to README with usage, signature docs, and example
- Add random_discrete helper in example.c using stdlib_base_round
  instead of raw int32_t casts, matching PMF convention
- Add round dependency to examples task in manifest.json

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
… native docblock

- Add missing section.c wrapper, C APIs heading, horizontal rule, and
  intro section to README C API block (matching PMF structure)
- Cast int32_t operands to double before multiplication in the CDF
  recurrence to prevent overflow with large population sizes
- Trim native.js docblock to only show examples that work through the
  DIII_D NAPI layer (remove NaN/fractional/PINF parameter examples)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
- Replace random_discrete/stdlib_base_round pattern with random_int
  helper using rand()%range, matching sibling hypergeometric packages
  (mean, mode)
- Update example.c, benchmark.c, and README C example consistently
- Remove round dependency from benchmark and examples manifest tasks

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Planeshifter
Planeshifter merged commit f29c023 into stdlib-js:develop Sep 2, 2026
13 checks passed
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Sep 2, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RFC]: Add C implementation for @stdlib/stats/base/dists/hypergeometric/cdf

4 participants