From 96afef0db223e2682bf7263de61dd6867ee71436 Mon Sep 17 00:00:00 2001 From: yuvi-mittal Date: Fri, 24 Jan 2025 16:47:41 +0530 Subject: [PATCH 1/4] feat: add C implementation of lib/node_modules/@stdlib/stats/base/dists/planck/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/planck/cdf/README.md | 96 +++++ .../dists/planck/cdf/benchmark/benchmark.js | 11 +- .../planck/cdf/benchmark/benchmark.native.js | 71 ++++ .../dists/planck/cdf/benchmark/c/Makefile | 146 +++++++ .../dists/planck/cdf/benchmark/c/benchmark.c | 140 +++++++ .../stats/base/dists/planck/cdf/binding.gyp | 170 +++++++++ .../base/dists/planck/cdf/examples/c/Makefile | 146 +++++++ .../dists/planck/cdf/examples/c/example.c | 42 +++ .../stats/base/dists/planck/cdf/include.gypi | 53 +++ .../stdlib/stats/base/dists/planck/cdf.h | 46 +++ .../stats/base/dists/planck/cdf/lib/native.js | 68 ++++ .../stats/base/dists/planck/cdf/manifest.json | 85 +++++ .../stats/base/dists/planck/cdf/package.json | 3 + .../stats/base/dists/planck/cdf/src/Makefile | 70 ++++ .../stats/base/dists/planck/cdf/src/addon.c | 23 ++ .../stats/base/dists/planck/cdf/src/main.c | 51 +++ .../base/dists/planck/cdf/test/test.native.js | 356 ++++++++++++++++++ 17 files changed, 1575 insertions(+), 2 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/include/stdlib/stats/base/dists/planck/cdf.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/cdf/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/cdf/README.md index 877f402c385b..2eed828b58b1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/cdf/README.md @@ -120,6 +120,102 @@ for ( i = 0; i < lambda.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/planck/cdf.h" +``` + +#### stdlib_base_dists_planck_cdf( x, lambda) + +Evaluates the cumulative distribution function (CDF) for an planck distribution. + +```c +double out = stdlib_base_dists_planck_cdf( 2.0, .5); +// returns ~0.7769 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **lambda**: `[in] double` minimum support. + +```c +double stdlib_base_dists_planck_cdf( const double x, const double lambda); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/planck/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 x; + double lambda; + double y; + int i; + + for (i = 0; i < 25; i++) { + x = random_uniform(-10.0, 10.0); + lambda = random_uniform(0.1, 5.0); + y = stdlib_base_dists_planck_cdf(x, lambda); + printf("x: %lf, lambda: %lf, F(x; lambda): %lf\n", x, lambda, y); + } + + return 0; +} +``` + +
+ + + +
+ + +