From e9ed095569e348560f63e8f1178985dcbefa353f Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Wed, 1 Jan 2025 21:22:13 +0000 Subject: [PATCH] feat: add C implementation for stats/base/dists/poisson/cdf --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na --- --- .../stats/base/dists/poisson/cdf/README.md | 95 +++++++++ .../dists/poisson/cdf/benchmark/benchmark.js | 14 +- .../poisson/cdf/benchmark/benchmark.native.js | 71 +++++++ .../dists/poisson/cdf/benchmark/c/Makefile | 146 ++++++++++++++ .../dists/poisson/cdf/benchmark/c/benchmark.c | 141 +++++++++++++ .../stats/base/dists/poisson/cdf/binding.gyp | 170 ++++++++++++++++ .../dists/poisson/cdf/examples/c/Makefile | 146 ++++++++++++++ .../dists/poisson/cdf/examples/c/example.c | 40 ++++ .../stats/base/dists/poisson/cdf/include.gypi | 53 +++++ .../stdlib/stats/base/dists/poisson/cdf.h | 38 ++++ .../base/dists/poisson/cdf/lib/native.js | 68 +++++++ .../base/dists/poisson/cdf/manifest.json | 85 ++++++++ .../stats/base/dists/poisson/cdf/package.json | 3 + .../stats/base/dists/poisson/cdf/src/Makefile | 70 +++++++ .../stats/base/dists/poisson/cdf/src/addon.c | 23 +++ .../stats/base/dists/poisson/cdf/src/main.c | 54 +++++ .../dists/poisson/cdf/test/test.native.js | 189 ++++++++++++++++++ 17 files changed, 1403 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/include/stdlib/stats/base/dists/poisson/cdf.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md index 11c1fa3661ab..abf5011f7762 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/poisson/cdf/README.md @@ -142,6 +142,101 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/poisson/cdf.h" +``` + +#### stdlib_base_dists_poisson_cdf( x, lambda ) + +Evaluates the [cumulative distribution function][cdf] for a [Poisson][poisson-distribution] distribution with mean parameter `lambda`. + +```c +double out = stdlib_base_dists_poisson_cdf( 2.0, 0.5 ); +// returns ~0.986 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **lambda**: `[in] double` mean parameter. + +```c +double stdlib_base_dists_poisson_cdf( const double x, const double lambda ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/poisson/cdf.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 lambda; + double x; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + x = random_uniform( 0.0, 10.0 ); + lambda = random_uniform( 0.0, 10.0 ); + y = stdlib_base_dists_poisson_cdf( x, lambda ); + printf( "x: %lf, λ: %lf, F(x;λ): %lf\n", x, lambda, y ); + } +} +``` + +
+ + + +
+ + +