From 7d1f0e26c71c4d5db7e278109221b9c7aa5f2150 Mon Sep 17 00:00:00 2001 From: Bhargav Dabhade Date: Sun, 8 Mar 2026 11:34:15 +0000 Subject: [PATCH] feat: add C implementation of stats/base/dists/lognormal/cdf Signed-off-by: Bhargav Dabhade --- 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../stats/base/dists/lognormal/cdf/README.md | 99 ++++++++++ .../lognormal/cdf/benchmark/benchmark.js | 6 +- .../cdf/benchmark/benchmark.native.js | 72 +++++++ .../dists/lognormal/cdf/benchmark/c/Makefile | 146 ++++++++++++++ .../lognormal/cdf/benchmark/c/benchmark.c | 143 ++++++++++++++ .../base/dists/lognormal/cdf/binding.gyp | 170 ++++++++++++++++ .../dists/lognormal/cdf/examples/c/Makefile | 146 ++++++++++++++ .../dists/lognormal/cdf/examples/c/example.c | 43 ++++ .../base/dists/lognormal/cdf/include.gypi | 53 +++++ .../stdlib/stats/base/dists/lognormal/cdf.h | 38 ++++ .../base/dists/lognormal/cdf/lib/native.js | 69 +++++++ .../base/dists/lognormal/cdf/manifest.json | 84 ++++++++ .../base/dists/lognormal/cdf/package.json | 3 + .../base/dists/lognormal/cdf/src/Makefile | 70 +++++++ .../base/dists/lognormal/cdf/src/addon.c | 22 +++ .../stats/base/dists/lognormal/cdf/src/main.c | 49 +++++ .../dists/lognormal/cdf/test/test.native.js | 184 ++++++++++++++++++ 17 files changed, 1394 insertions(+), 3 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 0c2f8a4c5cfc..4231858302b5 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 @@ -132,6 +132,105 @@ logEachMap( 'x: %0.4f, µ: %0.4f, σ: %0.4f, F(x;µ,σ): %0.4f', x, mu, sigma, c + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/lognormal/cdf.h" +``` + +#### stdlib_base_dists_lognormal_cdf( x, mu, sigma ) + +Evaluates the [cumulative distribution function][cdf] of a [lognormal][lognormal-distribution] distribution with location parameter `mu` and scale parameter `sigma`. + +```c +double y = stdlib_base_dists_lognormal_cdf( 2.0, 0.0, 1.0 ); +// returns ~0.756 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **mu**: `[in] double` location parameter. +- **sigma**: `[in] double` scale parameter. + +```c +double stdlib_base_dists_lognormal_cdf( const double x, const double mu, const double sigma ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/lognormal/cdf.h" +#include "stdlib/constants/float64/eps.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 sigma; + double mu; + double x; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + x = random_uniform( 0.1, 10.0 ); + mu = random_uniform( -5.0, 5.0 ); + sigma = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 ); + y = stdlib_base_dists_lognormal_cdf( x, mu, sigma ); + printf( "x: %lf, μ: %lf, σ: %lf, F(x;μ,σ): %lf\n", x, mu, sigma, y ); + } +} +``` + +
+ + + +
+ + +