Skip to content

feat: add C implementation for stats/base/dists/f/pdf#11201

Open
rautelaKamal wants to merge 1 commit intostdlib-js:developfrom
rautelaKamal:feat/stats-base-dists-f-pdf-c-port
Open

feat: add C implementation for stats/base/dists/f/pdf#11201
rautelaKamal wants to merge 1 commit intostdlib-js:developfrom
rautelaKamal:feat/stats-base-dists-f-pdf-c-port

Conversation

@rautelaKamal
Copy link
Copy Markdown
Contributor

@rautelaKamal rautelaKamal commented Mar 29, 2026

Description

What is the purpose of this pull request?

This pull request:

  • Implements a native C-port for the F Distribution Probability Density Function (@stdlib/stats/base/dists/f/pdf).
  • Configures include.gypi, binding.gyp, and manifest.json dependencies via internal N-API mechanisms (STDLIB_MATH_BASE_NAPI_MODULE_DDD_D).
  • Validates identical sub-epsilon behavior to pure JS implementation across boundaries, limits, and NaN.
  • Introduces robust Boost and Julia test.native.js fixtures to validate the C-port accuracy and benchmarks it.

Related Issues

Does this pull request have any related issues?

This pull request has no 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.

This is a Proof of Concept submission towards my GSoC 2026 application regarding porting distributions and specific math functions to high-performance C native addons.

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


@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. labels Mar 29, 2026
@stdlib-bot
Copy link
Copy Markdown
Contributor

stdlib-bot commented Mar 29, 2026

Coverage Report

Package Statements Branches Functions Lines
array/base/falses $\color{green}85/85$
$\color{green}+100.00%$
$\color{green}3/3$
$\color{green}+100.00%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}85/85$
$\color{green}+100.00%$
array/base/trues $\color{green}85/85$
$\color{green}+100.00%$
$\color{green}3/3$
$\color{green}+100.00%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}85/85$
$\color{green}+100.00%$
array/nulls $\color{green}118/118$
$\color{green}+100.00%$
$\color{green}7/7$
$\color{green}+100.00%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}118/118$
$\color{green}+100.00%$
assert/has-dataview-support $\color{green}141/141$
$\color{green}+100.00%$
$\color{red}12/13$
$\color{green}+92.31%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}141/141$
$\color{green}+100.00%$
blas/base/dgemm $\color{green}834/834$
$\color{green}+100.00%$
$\color{green}118/118$
$\color{green}+100.00%$
$\color{green}8/8$
$\color{green}+100.00%$
$\color{green}834/834$
$\color{green}+100.00%$
blas/base $\color{red}27664/35810$
$\color{green}+77.25%$
$\color{red}498/555$
$\color{green}+89.73%$
$\color{red}12/286$
$\color{green}+4.20%$
$\color{red}27664/35810$
$\color{green}+77.25%$
blas/base/ndarray $\color{red}588/611$
$\color{green}+96.24%$
$\color{green}11/11$
$\color{green}+100.00%$
$\color{red}0/5$
$\color{green}+0.00%$
$\color{red}588/611$
$\color{green}+96.24%$
blas/base/ndarray/gdot $\color{green}106/106$
$\color{green}+100.00%$
$\color{green}3/3$
$\color{green}+100.00%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}106/106$
$\color{green}+100.00%$
blas/base/ndarray $\color{red}588/611$
$\color{green}+96.24%$
$\color{green}11/11$
$\color{green}+100.00%$
$\color{red}0/5$
$\color{green}+0.00%$
$\color{red}588/611$
$\color{green}+96.24%$
blas/ext $\color{red}60383/73083$
$\color{green}+82.62%$
$\color{red}1066/1205$
$\color{green}+88.46%$
$\color{red}20/603$
$\color{green}+3.32%$
$\color{red}60383/73083$
$\color{green}+82.62%$
blas/ext/base $\color{red}57032/68259$
$\color{green}+83.55%$
$\color{red}1027/1166$
$\color{green}+88.08%$
$\color{red}20/580$
$\color{green}+3.45%$
$\color{red}57032/68259$
$\color{green}+83.55%$
blas/ext/base/dindex-of-row $\color{green}531/531$
$\color{green}+100.00%$
$\color{green}52/52$
$\color{green}+100.00%$
$\color{green}4/4$
$\color{green}+100.00%$
$\color{green}531/531$
$\color{green}+100.00%$
blas/ext/base/dindex-of $\color{green}357/357$
$\color{green}+100.00%$
$\color{green}19/19$
$\color{green}+100.00%$
$\color{green}4/4$
$\color{green}+100.00%$
$\color{green}357/357$
$\color{green}+100.00%$
blas/ext/base/dlast-index-of $\color{green}364/364$
$\color{green}+100.00%$
$\color{green}17/17$
$\color{green}+100.00%$
$\color{green}4/4$
$\color{green}+100.00%$
$\color{green}364/364$
$\color{green}+100.00%$
blas/ext/base/gindex-of-row $\color{red}471/555$
$\color{green}+84.86%$
$\color{red}39/40$
$\color{green}+97.50%$
$\color{red}3/4$
$\color{green}+75.00%$
$\color{red}471/555$
$\color{green}+84.86%$
blas/ext/base $\color{red}57197/68430$
$\color{green}+83.58%$
$\color{red}1030/1169$
$\color{green}+88.11%$
$\color{red}20/583$
$\color{green}+3.43%$
$\color{red}57197/68430$
$\color{green}+83.58%$
blas/ext/base/ndarray $\color{red}8325/8909$
$\color{green}+93.44%$
$\color{red}143/145$
$\color{green}+98.62%$
$\color{red}0/72$
$\color{green}+0.00%$
$\color{red}8325/8909$
$\color{green}+93.44%$
blas/ext/base/sindex-of $\color{green}357/357$
$\color{green}+100.00%$
$\color{green}19/19$
$\color{green}+100.00%$
$\color{green}4/4$
$\color{green}+100.00%$
$\color{green}357/357$
$\color{green}+100.00%$
blas/ext/base/slast-index-of $\color{green}364/364$
$\color{green}+100.00%$
$\color{green}17/17$
$\color{green}+100.00%$
$\color{green}4/4$
$\color{green}+100.00%$
$\color{green}364/364$
$\color{green}+100.00%$
blas/ext $\color{red}60650/73360$
$\color{green}+82.67%$
$\color{red}1071/1210$
$\color{green}+88.51%$
$\color{red}20/608$
$\color{green}+3.29%$
$\color{red}60650/73360$
$\color{green}+82.67%$
math/base/special/cos $\color{green}236/236$
$\color{green}+100.00%$
$\color{green}14/14$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}236/236$
$\color{green}+100.00%$
math/base/tools/normhermitepolyf $\color{green}230/230$
$\color{green}+100.00%$
$\color{green}27/27$
$\color{green}+100.00%$
$\color{green}3/3$
$\color{green}+100.00%$
$\color{green}230/230$
$\color{green}+100.00%$
ndarray/base/maybe-broadcast-arrays $\color{green}183/183$
$\color{green}+100.00%$
$\color{green}8/8$
$\color{green}+100.00%$
$\color{green}1/1$
$\color{green}+100.00%$
$\color{green}183/183$
$\color{green}+100.00%$
stats/base/dists/f/pdf $\color{red}599/647$
$\color{green}+0.00%$
$\color{red}62/66$
$\color{green}+0.00%$
$\color{green}6/6$
$\color{green}+0.00%$
$\color{red}599/647$
$\color{green}+0.00%$
stats/incr/wmean $\color{green}174/174$
$\color{green}+100.00%$
$\color{green}7/7$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}174/174$
$\color{green}+100.00%$
stats/ztest2 $\color{green}393/393$
$\color{green}+100.00%$
$\color{green}61/61$
$\color{green}+100.00%$
$\color{green}3/3$
$\color{green}+100.00%$
$\color{green}393/393$
$\color{green}+100.00%$
strided/base/zmap $\color{green}226/226$
$\color{green}+100.00%$
$\color{green}9/9$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}226/226$
$\color{green}+100.00%$
utils/async/try-then $\color{green}199/199$
$\color{green}+100.00%$
$\color{green}21/21$
$\color{green}+100.00%$
$\color{green}3/3$
$\color{green}+100.00%$
$\color{green}199/199$
$\color{green}+100.00%$

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

@rautelaKamal
Copy link
Copy Markdown
Contributor Author

Just a quick heads up regarding the minor coverage drop flagged by Codecov:

The native.js file is showing 0% function coverage because the addon.node binary correctly skips compilation during the CI coverage step, which triggers the expected opts.skip = true fallback inside test.native.js. The math logic is fully tested and verified when the native addon actually builds!

Also, the drop in ibeta_power_terms.js relates to the original pure JavaScript implementations and was untouched in this PR. @Planeshifter

@Neerajpathak07
Copy link
Copy Markdown
Member

@rautelaKamal FYI: I think you have misunderstood what we do for adding native implementation. Here we expect to add the corresponding C files for benchmark, examples and the main implementation alongside the relevant dependencies and documentations.
Take a look at a few of the merged PR's on how this is done.
For eg:- refer to https://github.com/stdlib-js/stdlib/pull/10839/changes

@rautelaKamal
Copy link
Copy Markdown
Contributor Author

@Neerajpathak07 Thank you for catching this and pointing me to the reference PR! I totally misunderstood the scope, I was focused solely on evaluating the N-API/Node.js boundary and completely neglected the standalone C ecosystem deliverables.

I have just pushed an update that adds the benchmark/c/ and examples/c/ directories, the src/Makefile for cleanup, and the full C APIs documentation section in the README.md.

Really appreciate you taking the time to explain the standard.Please let me know if there's anything else I missed!

@Lokeshranjan8
Copy link
Copy Markdown
Contributor

Lokeshranjan8 commented Mar 31, 2026

@rautelaKamal Update your commit message

feat(stats/base/dists/f/pdf): add native C addon for evaluating the PDF

to the following

feat: add C implementation for stats/base/dists/f/pdf

@rautelaKamal rautelaKamal force-pushed the feat/stats-base-dists-f-pdf-c-port branch from 9744905 to 197e55f Compare March 31, 2026 18:19
@rautelaKamal rautelaKamal changed the title feat(stats/base/dists/f/pdf): add native C addon for evaluating the PDF feat: add C implementation for stats/base/dists/f/pdf Apr 4, 2026
@rautelaKamal rautelaKamal force-pushed the feat/stats-base-dists-f-pdf-c-port branch from 8be84d0 to 4bf98b2 Compare April 5, 2026 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Review A pull request which needs code review. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants