From 8018118df8822d6a423d6b21419f4e54714c300e Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Thu, 27 Aug 2026 00:44:06 -0500 Subject: [PATCH] feat: add C implementation for `stats/base/dists/f/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_kebab_filenames status: passed --- Co-Authored-By: Claude Opus 5 (1M context) --- .../@stdlib/stats/base/dists/f/cdf/README.md | 99 ++++++++++ .../dists/f/cdf/benchmark/benchmark.native.js | 72 +++++++ .../base/dists/f/cdf/benchmark/c/Makefile | 146 ++++++++++++++ .../base/dists/f/cdf/benchmark/c/benchmark.c | 143 ++++++++++++++ .../stats/base/dists/f/cdf/binding.gyp | 170 +++++++++++++++++ .../base/dists/f/cdf/examples/c/Makefile | 146 ++++++++++++++ .../base/dists/f/cdf/examples/c/example.c | 43 +++++ .../stats/base/dists/f/cdf/include.gypi | 53 ++++++ .../include/stdlib/stats/base/dists/f/cdf.h | 38 ++++ .../stats/base/dists/f/cdf/lib/native.js | 84 ++++++++ .../stats/base/dists/f/cdf/manifest.json | 84 ++++++++ .../stats/base/dists/f/cdf/package.json | 3 + .../stats/base/dists/f/cdf/src/Makefile | 70 +++++++ .../stats/base/dists/f/cdf/src/addon.c | 22 +++ .../@stdlib/stats/base/dists/f/cdf/src/main.c | 59 ++++++ .../base/dists/f/cdf/test/test.native.js | 180 ++++++++++++++++++ 16 files changed, 1412 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/include/stdlib/stats/base/dists/f/cdf.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/f/cdf/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/f/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/f/cdf/README.md index daf186718eb5..8acf0e4021d8 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/f/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/f/cdf/README.md @@ -150,6 +150,105 @@ logEachMap( 'x: %0.4f, d1: %0.4f, d2: %0.4f, F(x;d1,d2): %0.4f', x, d1, d2, cdf + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/f/cdf.h" +``` + +#### stdlib_base_dists_f_cdf( x, d1, d2 ) + +Evaluates the [cumulative distribution function][cdf] (CDF) for an [F][f-distribution] distribution with numerator degrees of freedom `d1` and denominator degrees of freedom `d2` at a value `x`. + +```c +double y = stdlib_base_dists_f_cdf( 2.0, 1.0, 1.0 ); +// returns ~0.608 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **d1**: `[in] double` numerator degrees of freedom. +- **d2**: `[in] double` denominator degrees of freedom. + +```c +double stdlib_base_dists_f_cdf( const double x, const double d1, const double d2 ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/f/cdf.h" +#include "stdlib/constants/float64/eps.h" +#include +#include + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + +int main( void ) { + double d1; + double d2; + double x; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + x = random_uniform( 0.0, 10.0 ); + d1 = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); + d2 = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); + y = stdlib_base_dists_f_cdf( x, d1, d2 ); + printf( "x: %lf, d1: %lf, d2: %lf, F(x;d1,d2): %lf\n", x, d1, d2, y ); + } +} +``` + +
+ + + +
+ + +