From ddc6a40001f422ed12d5f2c73b2e1b1508b1ee98 Mon Sep 17 00:00:00 2001 From: saurabhraghuvanshii Date: Fri, 10 Jan 2025 16:58:43 +0530 Subject: [PATCH] feat: add C implementation for /base/dists/lognormal/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_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../stats/base/dists/lognormal/cdf/README.md | 98 ++++++++ .../lognormal/cdf/benchmark/benchmark.js | 20 +- .../cdf/benchmark/benchmark.native.js | 71 ++++++ .../dists/lognormal/cdf/benchmark/c/Makefile | 146 +++++++++++ .../lognormal/cdf/benchmark/c/benchmark.c | 141 +++++++++++ .../base/dists/lognormal/cdf/binding.gyp | 170 +++++++++++++ .../dists/lognormal/cdf/examples/c/Makefile | 146 +++++++++++ .../dists/lognormal/cdf/examples/c/example.c | 40 +++ .../base/dists/lognormal/cdf/include.gypi | 53 ++++ .../stdlib/stats/base/dists/lognormal/cdf.h | 38 +++ .../base/dists/lognormal/cdf/lib/native.js | 63 +++++ .../base/dists/lognormal/cdf/manifest.json | 80 ++++++ .../base/dists/lognormal/cdf/package.json | 3 + .../base/dists/lognormal/cdf/src/Makefile | 70 ++++++ .../base/dists/lognormal/cdf/src/addon.c | 23 ++ .../stats/base/dists/lognormal/cdf/src/main.c | 45 ++++ .../dists/lognormal/cdf/test/test.native.js | 228 ++++++++++++++++++ 17 files changed, 1429 insertions(+), 6 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/include/stdlib/stats/base/dists/lognormal/cdf.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/README.md index d3364f5e128a..3ec5683e355b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/lognormal/cdf/README.md @@ -136,6 +136,104 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/lognormal/cdf.h" +``` + +#### stdlib_base_dists_lognormal_cdf( x, a, b ) + +Evaluates the cumulative distribution function (CDF) for an lognormal distribution. + +```c +double out = stdlib_base_dists_lognormal_cdf( 0.5, 0.0, 2.0 ); +// returns ~0.333 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **a**: `[in] double` minimum support. +- **b**: `[in] double` maximum support. + +```c +double stdlib_base_dists_lognormal_cdf( const double x, const double a, const double b ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/lognormal/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 a; + double b; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + x = random_uniform( -10.0, 10.0 ); + a = random_uniform( -20.0, 0.0 ); + b = random_uniform( a, a+40.0 ); + y = stdlib_base_dists_lognormal_cdf( x, a, b ); + printf( "x: %lf, a: %lf, b: %lf, F(x;a,b): %lf\n", x, a, b, y ); + } +} +``` + +
+ + + +
+ + +