From 16f0017c5a9c6ceddf24a790dbff9a2afcc1b90d Mon Sep 17 00:00:00 2001 From: yuvi-mittal Date: Sun, 26 Jan 2025 15:24:33 +0530 Subject: [PATCH 1/8] Add C implementation for @stdlib/stats/base/dists/planck/entropy --- 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/entropy/README.md | 91 ++++++++++ .../planck/entropy/benchmark/benchmark.js | 13 +- .../entropy/benchmark/benchmark.native.js | 68 +++++++ .../dists/planck/entropy/benchmark/c/Makefile | 146 +++++++++++++++ .../planck/entropy/benchmark/c/benchmark.c | 139 ++++++++++++++ .../base/dists/planck/entropy/binding.gyp | 170 ++++++++++++++++++ .../dists/planck/entropy/examples/c/Makefile | 146 +++++++++++++++ .../dists/planck/entropy/examples/c/example.c | 38 ++++ .../base/dists/planck/entropy/include.gypi | 53 ++++++ .../stdlib/stats/base/dists/planck/entropy.h | 38 ++++ .../base/dists/planck/entropy/lib/native.js | 58 ++++++ .../base/dists/planck/entropy/manifest.json | 88 +++++++++ .../base/dists/planck/entropy/package.json | 3 + .../base/dists/planck/entropy/src/Makefile | 70 ++++++++ .../base/dists/planck/entropy/src/addon.c | 23 +++ .../base/dists/planck/entropy/src/main.c | 45 +++++ .../dists/planck/entropy/test/test.native.js | 92 ++++++++++ 17 files changed, 1278 insertions(+), 3 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/include/stdlib/stats/base/dists/planck/entropy.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/entropy/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/README.md index f00b69fe23d3..40fdb0fedde9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/entropy/README.md @@ -120,6 +120,97 @@ for ( i = 0; i < lambda.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/planck/entropy.h" +``` + +#### stdlib_base_dists_planck_entropy( lambda ) + +Evaluates the entropy for planck distribution. + +```c +double out = stdlib_base_dists_planck_entropy( 1.5 ); +// returns ~0.6833 +``` + +The function accepts the following arguments: + +- **lambda**: `[in] double` shape parameter + +```c +double stdlib_base_dists_planck_entropy( const double lambda ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/planck/entropy.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 y; + int i; + + for ( i = 0; i < 25; i++ ) { + lambda = random_uniform( 0.1, 5.0 ); + y = stdlib_base_dists_planck_entropy( lambda ); + printf( "λ: %lf, H(X;λ): %lf\n", lambda, y ); + } +} +``` + +
+ + + +
+ + +