Skip to content

feat: add C implementation for @stdlib/stats/base/dists/chi/kurtosis#10837

Open
rautelaKamal wants to merge 9 commits intostdlib-js:developfrom
rautelaKamal:feat-chi-kurtosis-c
Open

feat: add C implementation for @stdlib/stats/base/dists/chi/kurtosis#10837
rautelaKamal wants to merge 9 commits intostdlib-js:developfrom
rautelaKamal:feat-chi-kurtosis-c

Conversation

@rautelaKamal
Copy link
Contributor

Description

This pull request adds a native C implementation for @stdlib/stats/base/dists/chi/kurtosis, resolving issue #3491.

The excess kurtosis of a chi distribution with degrees of freedom k is:

kurtosis = (2 / sigma2) * (1 - mu * sigma * g1 - sigma2)

where mu = mean(k), sigma2 = variance(k), sigma = sqrt(sigma2), and g1 = skewness(k).

Changes

  • Adds src/main.c implementing the kurtosis formula in C
  • Adds src/addon.c N-API wrapper using STDLIB_MATH_BASE_NAPI_MODULE_D_D
  • Adds include/stdlib/stats/base/dists/chi/kurtosis.h header
  • Adds build files (binding.gyp, include.gypi, src/Makefile)
  • Adds manifest.json with required C library dependencies (mean, variance, skewness, sqrt, is-nan)
  • Updates lib/index.js to load native addon with pure-JS fallback
  • Adds lib/native.js native addon loader
  • Adds test/test.native.js for native addon testing
  • Adds test/test.main.js for JS fallback coverage (100% coverage)
  • Adds native benchmarks and C examples

Related Issues

Ref: #3491

Checklist

- Add C source file (src/main.c) implementing excess kurtosis formula
- Add N-API addon wrapper (src/addon.c)
- Add C header file (include/stdlib/stats/base/dists/chi/kurtosis.h)
- Add build files (binding.gyp, include.gypi, src/Makefile)
- Add manifest.json with required C dependencies
- Update lib/index.js to load native addon with JS fallback
- Add lib/native.js for native addon loading
- Add test/test.native.js for native addon tests
- Add test/test.main.js for JS fallback path coverage (100% coverage)
- Add benchmark/benchmark.native.js and benchmark/c/
- Add examples/c/

Closes stdlib-js#3491
@stdlib-bot stdlib-bot added the Statistics Issue or pull request related to statistical functionality. label Mar 9, 2026
@stdlib-bot
Copy link
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

@stdlib-bot stdlib-bot added Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Mar 9, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Mar 9, 2026

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/chi/kurtosis $\color{green}180/180$
$\color{green}+100.00%$
$\color{green}10/10$
$\color{green}+100.00%$
$\color{green}2/2$
$\color{green}+100.00%$
$\color{green}180/180$
$\color{green}+100.00%$

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

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

2 participants