Skip to content

feat: add C implementation for stats/base/dists/signrank/quantile - #10059

Open
nirmaljb wants to merge 13 commits into
stdlib-js:developfrom
nirmaljb:feat/signrank-quantile
Open

feat: add C implementation for stats/base/dists/signrank/quantile#10059
nirmaljb wants to merge 13 commits into
stdlib-js:developfrom
nirmaljb:feat/signrank-quantile

Conversation

@nirmaljb

@nirmaljb nirmaljb commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Resolves #3885 .

Description

What is the purpose of this pull request?

This pull request:

  • Adds a C implementation of the signrank quantile function.
  • Includes benchmarks for the C implementation.
  • Provides examples demonstrating the usage of the signrank quantile 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 Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Feb 2, 2026
@stdlib-bot

stdlib-bot commented Feb 2, 2026

Copy link
Copy Markdown
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/signrank/quantile $\\color{green}372/372$
$\\color{green}+0.00\\%$
$\\color{green}47/47$
$\\color{green}+0.00\\%$
$\\color{green}5/5$
$\\color{green}+0.00\\%$
$\\color{green}372/372$
$\\color{green}+0.00\\%$

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

@nirmaljb

nirmaljb commented Feb 2, 2026

Copy link
Copy Markdown
Contributor Author

/stdlib update-copyright-years

@stdlib-bot stdlib-bot added bot: In Progress Pull request is currently awaiting automation. and removed bot: In Progress Pull request is currently awaiting automation. labels Feb 2, 2026
@nirmaljb
nirmaljb marked this pull request as draft February 2, 2026 19:35
@nirmaljb
nirmaljb force-pushed the feat/signrank-quantile branch from 13bc930 to b3908cf Compare February 2, 2026 20:46
@nirmaljb

nirmaljb commented Feb 2, 2026

Copy link
Copy Markdown
Contributor Author

The test is stuck at test.native.js test with large n values (up to 150) from the fixtures. The recursive weights function has O(2^n) complexity, making it extremely slow.
Should I reduce the value of N to compensate for it?

@nirmaljb
nirmaljb marked this pull request as ready for review February 2, 2026 20:49
@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 Feb 2, 2026
@nirmaljb nirmaljb changed the title feat: add C implementation for signrank quantile feat: add C implementation for stats/base/dists/signrank/quantile Feb 3, 2026
@nirmaljb
nirmaljb marked this pull request as draft February 3, 2026 08:03
@stdlib-bot stdlib-bot removed the Needs Review A pull request which needs code review. label Feb 3, 2026
@nirmaljb

nirmaljb commented Feb 4, 2026

Copy link
Copy Markdown
Contributor Author

Hello Maintainer, just a heads up.

  1. I reduced the C benchmark constraints as well as test.native.js constraints to a lesser ( n <= 20 ) value from the fixture because the tests were stuck, simply because the recursive weights function has O(2^n) complexity, making it extremely slow.
  2. I removed the test case that checks whether the value of N is an integer or not. Because in main.c int32_t truncates 4.8 to 4 (valid positive integer), so the function returns a valid result.

@nirmaljb
nirmaljb marked this pull request as ready for review February 4, 2026 18:16
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Feb 4, 2026
nirmaljb and others added 5 commits February 5, 2026 23:55
---
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: na
  - 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
---
---
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: passed
  - 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: passed
  - task: lint_javascript_benchmarks
    status: passed
  - 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
---
…chmark, removed the test to validate for decimal in N in test.native.js

---
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: 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: missing_dependencies
  - task: lint_c_examples
    status: na
  - 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
---
---
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
---
…age.json

---
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
---
@nirmaljb
nirmaljb force-pushed the feat/signrank-quantile branch from 65323b3 to 4551870 Compare February 5, 2026 18:41
…age.json

---
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
---
…age.json

---
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
---
… snippet

---
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: 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
---

@Planeshifter Planeshifter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR! Left round of feedback.

Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/src/main.c Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/src/main.c Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/src/main.c Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/src/main.c Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/src/main.c Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/test/test.native.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/test/test.native.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/test/test.native.js Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/examples/c/example.c Outdated
Comment thread lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/README.md Outdated
@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Apr 20, 2026
@Neerajpathak07
Neerajpathak07 requested a review from a team July 27, 2026 07:21
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jul 27, 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_pkg_readmes
    status: passed
  - 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: 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
---
Planeshifter and others added 2 commits August 28, 2026 23:41
… year

- Replace the recursive `weights()` function with an iterative
  dynamic programming approach that builds a subset-sum table in
  O(n^3) time and O(n^2) space, instead of the previous O(2^n)
  recursive implementation which lacked memoization
- Revert the README copyright year from 2026 back to 2020

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Planeshifter
Planeshifter force-pushed the feat/signrank-quantile branch from 25389d9 to 4d195bd Compare August 29, 2026 05:10
Resolve conflicts in test.factory.js and test.main.js by keeping
develop's isAlmostSameValue assertions and the PR's rename of
test.quantile.js to test.main.js.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Planeshifter
Planeshifter previously approved these changes Aug 29, 2026

@Planeshifter Planeshifter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM after some light clean-up.

@Planeshifter Planeshifter removed Needs Review A pull request which needs code review. Needs Changes Pull request which needs changes before being merged. labels Aug 29, 2026
@Planeshifter
Planeshifter force-pushed the feat/signrank-quantile branch from eda93ad to e80f7fa Compare August 31, 2026 19:10
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/signrank/quantile

4 participants