From 8600f8057a4cef880e808fd8bd1fd52ad8215786 Mon Sep 17 00:00:00 2001 From: saurabhraghuvanshii Date: Wed, 15 Jan 2025 02:52:02 +0530 Subject: [PATCH 01/14] feat: add c implementation for stats/base/dists/levy/quantile --- .../stats/base/dists/levy/quantile/README.md | 99 ++++++++++ .../levy/quantile/benchmark/benchmark.js | 19 +- .../quantile/benchmark/benchmark.native.js | 74 +++++++ .../dists/levy/quantile/benchmark/c/Makefile | 146 ++++++++++++++ .../levy/quantile/benchmark/c/benchmark.c | 143 ++++++++++++++ .../base/dists/levy/quantile/binding.gyp | 170 ++++++++++++++++ .../dists/levy/quantile/examples/c/Makefile | 146 ++++++++++++++ .../dists/levy/quantile/examples/c/example.c | 42 ++++ .../base/dists/levy/quantile/include.gypi | 53 +++++ .../stdlib/stats/base/dists/levy/quantile.h | 38 ++++ .../base/dists/levy/quantile/lib/native.js | 76 ++++++++ .../base/dists/levy/quantile/manifest.json | 89 +++++++++ .../base/dists/levy/quantile/package.json | 3 + .../base/dists/levy/quantile/src/Makefile | 70 +++++++ .../base/dists/levy/quantile/src/addon.c | 23 +++ .../stats/base/dists/levy/quantile/src/main.c | 49 +++++ .../dists/levy/quantile/test/test.native.js | 183 ++++++++++++++++++ 17 files changed, 1418 insertions(+), 5 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/include/stdlib/stats/base/dists/levy/quantile.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/levy/quantile/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/levy/quantile/README.md b/lib/node_modules/@stdlib/stats/base/dists/levy/quantile/README.md index 2b74fe4bd622..31b90c9da326 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/levy/quantile/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/levy/quantile/README.md @@ -145,6 +145,105 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/levy/quantile.h" +``` + +#### stdlib_base_dists_levy_quantile( p, mu, c ) + +Returns the [quantile function][quantile-function] for a [Lévy][levy-distribution] distribution with parameters `mu` (location parameter) and `c` (scale parameter) at a probability `p`. + +```c +double out = stdlib_base_dists_levy_quantile( 1.1, 0.0, 1.0 ); +// returns NaN +``` + +The function accepts the following arguments: + +- **p**: `[in] double` probability. +- **mu**: `[in] double` location parameter. +- **c**: `[in] double` scale parameter. + +```c +double stdlib_base_dists_levy_quantile( const double p, const double mu, const double c ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/levy/quantile.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 p; + double mu; + double c; + double y; + int i; + for ( i = 0; i < 25; i++ ) { + p = random_uniform(); + mu = random_uniform( 0.0, 10.0 ) - 5.0; + c = random_uniform( 0.0, 20.0 ); + y = stdlib_base_dists_levy_quantile( mu, c ); + printf( "p: %lf, µ: %lf, c: %lf, Q(p;µ,c): %lf\n", p, mu, c, y ); + } +} +``` + +
+ + + +
+ + + +