From 9db1d50279e4114797b57cfaa9f2a8913772b7fc Mon Sep 17 00:00:00 2001 From: yuvi-mittal Date: Tue, 28 Jan 2025 16:13:38 +0530 Subject: [PATCH 01/11] Add C implementation for @stdlib/stats/base/dists/planck/logcdf --- 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/logcdf/README.md | 97 ++++++++++ .../planck/logcdf/benchmark/benchmark.js | 17 +- .../logcdf/benchmark/benchmark.native.js | 71 ++++++++ .../dists/planck/logcdf/benchmark/c/Makefile | 146 +++++++++++++++ .../planck/logcdf/benchmark/c/benchmark.c | 144 +++++++++++++++ .../base/dists/planck/logcdf/binding.gyp | 170 ++++++++++++++++++ .../dists/planck/logcdf/examples/c/Makefile | 146 +++++++++++++++ .../dists/planck/logcdf/examples/c/example.c | 44 +++++ .../base/dists/planck/logcdf/include.gypi | 53 ++++++ .../stdlib/stats/base/dists/planck/logcdf.h | 38 ++++ .../base/dists/planck/logcdf/lib/native.js | 63 +++++++ .../base/dists/planck/logcdf/manifest.json | 95 ++++++++++ .../base/dists/planck/logcdf/package.json | 3 + .../base/dists/planck/logcdf/src/Makefile | 70 ++++++++ .../base/dists/planck/logcdf/src/addon.c | 23 +++ .../stats/base/dists/planck/logcdf/src/main.c | 49 +++++ .../dists/planck/logcdf/test/test.native.js | 142 +++++++++++++++ 17 files changed, 1366 insertions(+), 5 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md index d14304e5e82c..938d680b85fa 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md @@ -130,6 +130,103 @@ for ( i = 0; i < lambda.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/planck/logcdf.h" +``` + +#### stdlib_base_dists_planck_logcdf( x, lambda ) + +Evaluates the logarithm of cumulative distribution function (logcdf) for an planck distribution. + +```c +double out = stdlib_base_dists_planck_logcdf( 2, 0.5,); +// returns ~-0.2525 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **lambda**: `[in] double` shape parameter. + +```c +double stdlib_base_dists_planck_logcdf +( const double x, const double lambda ); +``` +
+ + + + + +
+ +
+ + + + + +
+ +### Examples +```c +#include "stdlib/stats/base/dists/planck/logcdf.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) ); +} +static int discrete_uniform( const int min, const int max ) { + return min + (rand() % (max - min + 1)); +} + +int main( void ) { + double x; + double lambda; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + x = discrete_uniform( 0, 40.0 ); + lambda = random_uniform( 0.1, 5.0 ); + y = stdlib_base_dists_planck_logcdf( x, lambda ); + printf( "x: %lf, λ: %lf, ln(F(x;λ)): %lf\n", x, lambda, y ); + } +} +``` + +
+ + + +
+ + + + @@ -191,6 +192,7 @@ double stdlib_base_dists_planck_logcdf
### Examples + ```c #include "stdlib/stats/base/dists/planck/logcdf.h" #include @@ -204,17 +206,17 @@ static int discrete_uniform( const int min, const int max ) { } int main( void ) { - double x; - double lambda; - double y; - int i; - - for ( i = 0; i < 25; i++ ) { - x = discrete_uniform( 0, 40.0 ); - lambda = random_uniform( 0.1, 5.0 ); - y = stdlib_base_dists_planck_logcdf( x, lambda ); - printf( "x: %lf, λ: %lf, ln(F(x;λ)): %lf\n", x, lambda, y ); - } + double x; + double lambda; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + x = discrete_uniform( 0, 40.0 ); + lambda = random_uniform( 0.1, 5.0 ); + y = stdlib_base_dists_planck_logcdf( x, lambda ); + printf( "x: %lf, λ: %lf, ln(F(x;λ)): %lf\n", x, lambda, y ); + } } ``` From ec140d760518e8b69f013d0f08786edf4c51451a Mon Sep 17 00:00:00 2001 From: yuvi-mittal Date: Mon, 3 Feb 2025 13:17:44 +0530 Subject: [PATCH 03/11] Refactor random number generation in JS benchmarks --- 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/logcdf/README.md | 2 +- .../planck/logcdf/benchmark/benchmark.js | 7 +- .../logcdf/benchmark/benchmark.native.js | 2 +- .../stdlib/stats/base/dists/planck/logcdf.h | 2 +- .../base/dists/planck/logcdf/lib/native.js | 2 +- .../base/dists/planck/logcdf/manifest.json | 180 +++++++++--------- .../stats/base/dists/planck/logcdf/src/main.c | 2 +- 7 files changed, 99 insertions(+), 98 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md index 8c8e85a161ff..e4c7fda69a18 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md @@ -158,7 +158,7 @@ for ( i = 0; i < lambda.length; i++ ) { #### stdlib_base_dists_planck_logcdf( x, lambda ) -Evaluates the logarithm of cumulative distribution function (logcdf) for an planck distribution. +Evaluates the logarithm of cumulative distribution function (logcdf) for an planck distribution with shape parameter `lambda`. ```c double out = stdlib_base_dists_planck_logcdf( 2, 0.5,); diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js index e92d5f100377..b15596282174 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js @@ -63,12 +63,17 @@ bench( pkg, function benchmark( b ) { bench( pkg+':factory', function benchmark( b ) { var mylogcdf; + var len; var x; var y; var i; - x = discreteUniform( 100, 0, 40 ); + len = 100; mylogcdf = logcdf.factory( 0.3 ); + x = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + x[i] = discreteUniform( 0, 40 ); + } b.tic(); for ( i = 0; i < b.iterations; i++ ) { diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js index 52989b6bb160..abca59025711 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js @@ -52,7 +52,7 @@ bench( pkg+'::native', opts, function benchmark( b ) { x = new Float64Array( len ); for ( i = 0; i < len; i++ ) { x[i] = discreteUniform(0, 40); - lambda[i] = uniform(1.0, 11.0); + lambda[i] = uniform(1.0, 10.0); } b.tic(); diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h index da9c316f80a5..4c0d97eb58c2 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h @@ -27,7 +27,7 @@ extern "C" { #endif /** -* Evaluates the logarithmic cumulative distribution function for an planck distribution with shape parameter 'lambda' at value 'x'. +*Evaluates the logarithm of cumulative distribution function (logcdf) for an planck distribution with shape parameter `lambda`. */ double stdlib_base_dists_planck_logcdf( const double x, const double lambda ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js index d9fd593b7da7..fd4ad4bc3731 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Evaluates the logarithm of the cumulative distribution function (logCDF) for a Planck (discrete exponential) distribution with shape parameter `lambda` at a value `x`. +*Evaluates the logarithm of cumulative distribution function (logcdf) for an planck distribution with shape parameter `lambda`. * * @private * @param {number} x - input value diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/manifest.json b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/manifest.json index 17f0dec20354..3a8ca690ae76 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/manifest.json @@ -1,95 +1,91 @@ { - "options": { + "options": { + "task": "build", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { "task": "build", - "wasm": false + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/binary", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/floor", + "@stdlib/math/base/special/expm1", + "@stdlib/math/base/special/ln", + "@stdlib/constants/float64/ninf", + "@stdlib/constants/float64/pinf" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/floor", + "@stdlib/math/base/special/expm1", + "@stdlib/math/base/special/ln", + "@stdlib/constants/float64/ninf", + "@stdlib/constants/float64/pinf" + ] }, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "task": "build", - "wasm": false, - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/napi/binary", - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/floor", - "@stdlib/math/base/special/expm1", - "@stdlib/math/base/special/ln", - "@stdlib/constants/float64/ninf", - "@stdlib/constants/float64/pi", - "@stdlib/constants/float64/pinf" - - ] - }, - { - "task": "benchmark", - "wasm": false, - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/floor", - "@stdlib/math/base/special/expm1", - "@stdlib/math/base/special/ln", - "@stdlib/constants/float64/ninf", - "@stdlib/constants/float64/pi", - "@stdlib/constants/float64/pinf" - ] - }, - { - "task": "examples", - "wasm": false, - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/assert/is-nan", - "@stdlib/math/base/special/floor", - "@stdlib/math/base/special/expm1", - "@stdlib/math/base/special/ln", - "@stdlib/constants/float64/ninf", - "@stdlib/constants/float64/pi", - "@stdlib/constants/float64/pinf" - ] - } - ] - } + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/floor", + "@stdlib/math/base/special/expm1", + "@stdlib/math/base/special/ln", + "@stdlib/constants/float64/ninf", + "@stdlib/constants/float64/pinf" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c index eb0155cce12c..0a19683f860e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c @@ -25,7 +25,7 @@ #include "stdlib/constants/float64/pinf.h" /** -* Evaluates the logarithm of the cumulative distribution function (logCDF) for a Planck distribution with shape parameter `lambda` at a value `x`. +* Evaluates the logarithm of the cumulative distribution function (logCDF) for a Planck distribution with shape parameter `lambda` . * * @param x input value * @param lambda shape parameter From 03670267a02147c3c9ee2d6f079c2d2e778ac631 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Sat, 15 Feb 2025 22:51:26 +0000 Subject: [PATCH 04/11] chore: update copyright years --- .../@stdlib/stats/base/dists/planck/logcdf/benchmark/c/Makefile | 2 +- .../@stdlib/stats/base/dists/planck/logcdf/binding.gyp | 2 +- .../@stdlib/stats/base/dists/planck/logcdf/examples/c/Makefile | 2 +- .../@stdlib/stats/base/dists/planck/logcdf/include.gypi | 2 +- .../logcdf/include/stdlib/stats/base/dists/planck/logcdf.h | 2 +- .../@stdlib/stats/base/dists/planck/logcdf/src/Makefile | 2 +- .../@stdlib/stats/base/dists/planck/logcdf/src/addon.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/Makefile index f69e9da2b4d3..a4bd7b38fd74 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/binding.gyp index ec3992233442..68a1ca11d160 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/binding.gyp +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/Makefile index 6aed70daf167..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include.gypi index 575cb043c0bf..ecfaf82a3279 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include.gypi +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h index 4c0d97eb58c2..6173b0610478 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/Makefile index bcf18aa46655..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/addon.c index 644d6c7e866e..0bdb12e03e17 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From c2a964fa80344b42050a6264a83641d3f8fca689 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 20 Jun 2025 14:33:57 -0500 Subject: [PATCH 05/11] fix: address review issues in `stats/base/dists/planck/logcdf` C implementation --- .../stats/base/dists/planck/logcdf/benchmark/benchmark.js | 4 ++-- .../base/dists/planck/logcdf/benchmark/benchmark.native.js | 6 +++--- .../logcdf/include/stdlib/stats/base/dists/planck/logcdf.h | 2 +- .../@stdlib/stats/base/dists/planck/logcdf/lib/main.js | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js index b15596282174..a788257cdf62 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js @@ -42,8 +42,8 @@ bench( pkg, function benchmark( b ) { lambda = new Float64Array( len ); x = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - x[i] = discreteUniform(0, 40); - lambda[i] = uniform(1.0, 11.0); + x[i] = discreteUniform( 0, 40 ); + lambda[i] = uniform( 1.0, 11.0 ); } b.tic(); diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js index abca59025711..d76575bb5742 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.native.js @@ -40,7 +40,7 @@ var opts = { // MAIN // -bench( pkg+'::native', opts, function benchmark( b ) { +bench( pkg + '::native', opts, function benchmark( b ) { var lambda; var len; var x; @@ -51,8 +51,8 @@ bench( pkg+'::native', opts, function benchmark( b ) { lambda = new Float64Array( len ); x = new Float64Array( len ); for ( i = 0; i < len; i++ ) { - x[i] = discreteUniform(0, 40); - lambda[i] = uniform(1.0, 10.0); + x[i] = discreteUniform( 0, 40 ); + lambda[i] = uniform( 1.0, 10.0 ); } b.tic(); diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h index 6173b0610478..5c736a2c8516 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h @@ -27,7 +27,7 @@ extern "C" { #endif /** -*Evaluates the logarithm of cumulative distribution function (logcdf) for an planck distribution with shape parameter `lambda`. +* Evaluates the logarithm of the cumulative distribution function (logCDF) for a Planck distribution with shape parameter `lambda`. */ double stdlib_base_dists_planck_logcdf( const double x, const double lambda ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/main.js index 4b3c976d2272..9df88d884593 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/main.js @@ -72,7 +72,7 @@ function logcdf( x, lambda ) { if ( x === PINF ) { return 0.0; } - return ln( -expm1( -lambda * ( floor(x)+1.0 ) ) ); + return ln( -expm1( -lambda * ( floor( x ) + 1.0 ) ) ); } From 3cfcdde8642f3a7345a69da3b70e549ee7fd34bb Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 20 Jun 2025 16:30:50 -0500 Subject: [PATCH 06/11] docs: fix function descriptions in `planck/logcdf` --- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - 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 --- --- .../logcdf/include/stdlib/stats/base/dists/planck/logcdf.h | 2 +- .../@stdlib/stats/base/dists/planck/logcdf/src/main.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h index 5c736a2c8516..e8d45ca98b30 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/include/stdlib/stats/base/dists/planck/logcdf.h @@ -27,7 +27,7 @@ extern "C" { #endif /** -* Evaluates the logarithm of the cumulative distribution function (logCDF) for a Planck distribution with shape parameter `lambda`. +* Evaluates the logarithm of the cumulative distribution function (CDF) for a Planck distribution with shape parameter `lambda`. */ double stdlib_base_dists_planck_logcdf( const double x, const double lambda ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c index 0a19683f860e..67bd9b0701f2 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/src/main.c @@ -25,7 +25,7 @@ #include "stdlib/constants/float64/pinf.h" /** -* Evaluates the logarithm of the cumulative distribution function (logCDF) for a Planck distribution with shape parameter `lambda` . +* Evaluates the logarithm of the cumulative distribution function (CDF) for a Planck distribution with shape parameter `lambda`. * * @param x input value * @param lambda shape parameter From d2361ba882f378b8dfde9fbd73f5bafbcacc44d4 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 20 Jun 2025 16:36:27 -0500 Subject: [PATCH 07/11] docs: fix descriptions in native.js and README for `planck/logcdf` --- 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: na - 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - 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 --- --- .../@stdlib/stats/base/dists/planck/logcdf/README.md | 2 +- .../@stdlib/stats/base/dists/planck/logcdf/lib/native.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md index e4c7fda69a18..6a75e15fafea 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md @@ -20,7 +20,7 @@ limitations under the License. # Logarithm of Cumulative Distribution Function -> Evaluate the logarithm of the [cumulative distribution function][cdf] Planck (discrete exponential) distribution. +> Evaluate the logarithm of the [cumulative distribution function][cdf] for a Planck (discrete exponential) distribution.
diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js index fd4ad4bc3731..4c663a23a57b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -*Evaluates the logarithm of cumulative distribution function (logcdf) for an planck distribution with shape parameter `lambda`. +* Evaluates the logarithm of the cumulative distribution function (CDF) for a Planck distribution with shape parameter `lambda`. * * @private * @param {number} x - input value From 822f4666b545c990dbee80d53375d2bd9ba8d5f7 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 20 Jun 2025 16:41:59 -0500 Subject: [PATCH 08/11] style: fix variable declaration order in `planck/logcdf` examples --- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - 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 --- --- .../@stdlib/stats/base/dists/planck/logcdf/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/index.js index 713087928bc0..5244dfe909eb 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/index.js @@ -25,8 +25,8 @@ var logcdf = require( './../lib' ); var x = discreteUniform( 10, 0, 5 ); var lambda = uniform( 10, 0.1, 5.0 ); -var y; var i; +var y; for ( i = 0; i < lambda.length; i++ ) { y = logcdf( x[ i ], lambda[ i ] ); console.log( 'x: %d, λ: %d, F(x;λ): %d', x[ i ].toFixed( 4 ), lambda[ i ].toFixed( 4 ), y.toFixed( 4 ) ); From d357b96e174144931017322687b765a29ed05f82 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 20 Jun 2025 16:52:36 -0500 Subject: [PATCH 09/11] chore: minor clean-up Signed-off-by: Philipp Burckhardt --- .../@stdlib/stats/base/dists/planck/logcdf/README.md | 6 ++++-- .../stats/base/dists/planck/logcdf/benchmark/c/benchmark.c | 2 +- .../stats/base/dists/planck/logcdf/examples/c/example.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md index 6a75e15fafea..c481fa136ecd 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md @@ -158,7 +158,7 @@ for ( i = 0; i < lambda.length; i++ ) { #### stdlib_base_dists_planck_logcdf( x, lambda ) -Evaluates the logarithm of cumulative distribution function (logcdf) for an planck distribution with shape parameter `lambda`. +Evaluates the logarithm of the [cumulative distribution function][cdf] for a Planck (discrete exponential) distribution with shape parameter `lambda`. ```c double out = stdlib_base_dists_planck_logcdf( 2, 0.5,); @@ -197,17 +197,19 @@ double stdlib_base_dists_planck_logcdf #include "stdlib/stats/base/dists/planck/logcdf.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) ); } + static int discrete_uniform( const int min, const int max ) { return min + (rand() % (max - min + 1)); } int main( void ) { - double x; double lambda; + double x; double y; int i; diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/benchmark.c index 7d3347cad734..7ba8b71bb9bb 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/c/benchmark.c @@ -97,8 +97,8 @@ static int discrete_uniform( const int min, const int max ) { */ static double benchmark( void ) { double elapsed; - double x[ 100 ]; double lambda[ 100 ]; + double x[ 100 ]; double y; double t; int i; diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/example.c index 5c081d81a231..34fbd52a882e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/examples/c/example.c @@ -30,8 +30,8 @@ static int discrete_uniform( const int min, const int max ) { } int main( void ) { - double x; double lambda; + double x; double y; int i; From 7b48b7ac8e6e278b6f4dfdbecce8872dcdb2f993 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 20 Jun 2025 16:53:19 -0500 Subject: [PATCH 10/11] docs: remove trailing comma Signed-off-by: Philipp Burckhardt --- .../@stdlib/stats/base/dists/planck/logcdf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md index c481fa136ecd..80124522d3d5 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/README.md @@ -161,7 +161,7 @@ for ( i = 0; i < lambda.length; i++ ) { Evaluates the logarithm of the [cumulative distribution function][cdf] for a Planck (discrete exponential) distribution with shape parameter `lambda`. ```c -double out = stdlib_base_dists_planck_logcdf( 2, 0.5,); +double out = stdlib_base_dists_planck_logcdf( 2, 0.5 ); // returns ~-0.2525 ``` From 7ef21d3b42aabc4613b443d304cd76a440e5243f Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 20 Jun 2025 16:56:10 -0500 Subject: [PATCH 11/11] bench: revert changes Signed-off-by: Philipp Burckhardt --- .../planck/logcdf/benchmark/benchmark.js | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js index a788257cdf62..fe7102fcfe17 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logcdf/benchmark/benchmark.js @@ -21,9 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var logcdf = require( './../lib' ); @@ -33,22 +32,16 @@ var logcdf = require( './../lib' ); bench( pkg, function benchmark( b ) { var lambda; - var len; var x; var y; var i; - len = 100; - lambda = new Float64Array( len ); - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[i] = discreteUniform( 0, 40 ); - lambda[i] = uniform( 1.0, 11.0 ); - } + x = discreteUniform( 100, 0, 40 ); + lambda = uniform( 100, 0.1, 10.0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = logcdf( x[ i % len ], lambda[ i % len ] ); + y = logcdf( x[ i % x.length ], lambda[ i % lambda.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -63,17 +56,12 @@ bench( pkg, function benchmark( b ) { bench( pkg+':factory', function benchmark( b ) { var mylogcdf; - var len; var x; var y; var i; - len = 100; + x = discreteUniform( 100, 0, 40 ); mylogcdf = logcdf.factory( 0.3 ); - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[i] = discreteUniform( 0, 40 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) {