From 498b3d9a4ebb546c12a37c84efbdc863b2ea2aa1 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Fri, 2 Jan 2026 18:33:14 +0530 Subject: [PATCH 01/23] mean package core implemented --- .../stats/base/dists/wald/mean/binding.gyp | 170 ++++++++++++++++++ .../stats/base/dists/wald/mean/include.gypi | 53 ++++++ .../stdlib/stats/base/dists/wald/mean.h | 38 ++++ .../stats/base/dists/wald/mean/lib/index.js | 43 +++++ .../stats/base/dists/wald/mean/lib/main.js | 74 ++++++++ .../stats/base/dists/wald/mean/lib/native.js | 67 +++++++ .../stats/base/dists/wald/mean/manifest.json | 76 ++++++++ .../stats/base/dists/wald/mean/package.json | 72 ++++++++ .../stats/base/dists/wald/mean/src/Makefile | 70 ++++++++ .../stats/base/dists/wald/mean/src/addon.c | 23 +++ .../stats/base/dists/wald/mean/src/main.c | 43 +++++ 11 files changed, 729 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/include/stdlib/stats/base/dists/wald/mean.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/binding.gyp new file mode 100644 index 000000000000..f343843f5bd2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings for the add-on: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Set optimization level: + '-O3', + ], + + # C specific flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C flags: + 'cflags': [ + # Generate position-independent code (PIC): + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target + + # Target to copy the add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Specify the target type: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be built before moving to a standard location: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target + ], # end targets +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "distribution", + "dist", + "moments", + "wald", + "inverse gaussian", + "inverse-gaussian", + "continuous", + "mean", + "average", + "avg", + "expected", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c new file mode 100644 index 000000000000..ecf68d4ba6e0 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c @@ -0,0 +1,23 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dists/wald/mean.h" +#include "stdlib/math/base/napi/binary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_wald_mean ) \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c new file mode 100644 index 000000000000..59a0c1f025ee --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dists/wald/mean.h" +#include "stdlib/math/base/assert/is_nan.h" + +/** +* Returns the expected value for a Wald distribution with mean `mu` and standard deviation `sigma`. +* +* @param mu mean +* @param sigma standard deviation +* @return expected value +* +* @example +* double y = stdlib_base_dists_wald_mean( 0.0, 1.0 ); +* // returns NaN +*/ +double stdlib_base_dists_wald_mean( const double mu, const double sigma ) { + if ( + stdlib_base_is_nan( mu ) || + stdlib_base_is_nan( sigma ) || + sigma <= 0.0 || + mu <= 0.0 + ) { + return 0.0/0.0; // NaN + } + return mu; +} From 21c98e85f3687a5e0f1ec51a0dc73aab91dc4df3 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Fri, 2 Jan 2026 18:51:01 +0530 Subject: [PATCH 02/23] fix: correct indentation to use tabs instead of spaces --- lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js | 2 +- .../@stdlib/stats/base/dists/wald/mean/lib/native.js | 2 +- lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c | 2 +- lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js index ac6fb11b0531..cbbc6a55ac16 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js @@ -61,7 +61,7 @@ function mean( mu, sigma ) { isnan( mu ) || isnan( sigma ) || sigma <= 0.0 || - mu <= 0.0 + mu <= 0.0 ) { return NaN; } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js index 74ca00940d6c..0ab697000d15 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js @@ -58,7 +58,7 @@ var addon = require( './../src/addon.node' ); * // returns NaN */ function mean( mu, sigma ) { - return addon( mu, sigma ); + return addon( mu, sigma ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c index ecf68d4ba6e0..921bcaca4890 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/addon.c @@ -20,4 +20,4 @@ #include "stdlib/math/base/napi/binary.h" // cppcheck-suppress shadowFunction -STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_wald_mean ) \ No newline at end of file +STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_wald_mean ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c index 59a0c1f025ee..a61b3a4928d9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c @@ -35,7 +35,7 @@ double stdlib_base_dists_wald_mean( const double mu, const double sigma ) { stdlib_base_is_nan( mu ) || stdlib_base_is_nan( sigma ) || sigma <= 0.0 || - mu <= 0.0 + mu <= 0.0 ) { return 0.0/0.0; // NaN } From e0830f75775ada59fe3da8d6ad6d206c8d52d22b Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sun, 4 Jan 2026 18:08:36 +0530 Subject: [PATCH 03/23] requested changed implemented --- .../stdlib/stats/base/dists/wald/mean.h | 4 ++-- .../stats/base/dists/wald/mean/lib/index.js | 6 +++--- .../stats/base/dists/wald/mean/lib/main.js | 18 +++++++++--------- .../stats/base/dists/wald/mean/lib/native.js | 16 ++++++++-------- .../stats/base/dists/wald/mean/src/main.c | 10 +++++----- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/include/stdlib/stats/base/dists/wald/mean.h b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/include/stdlib/stats/base/dists/wald/mean.h index 8519ccaa6b7e..a8cbf1b4ce7e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/include/stdlib/stats/base/dists/wald/mean.h +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/include/stdlib/stats/base/dists/wald/mean.h @@ -27,9 +27,9 @@ extern "C" { #endif /** -* Returns the expected value for a Wald distribution with mean `mu` and standard deviation `sigma`. +* Returns the expected value for a Wald distribution with mean `mu` and shape parameter `lambda`. */ -double stdlib_base_dists_wald_mean( const double mu, const double sigma ); +double stdlib_base_dists_wald_mean( const double mu, const double lambda ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js index d4f9a1da64e6..f36777558c1d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js @@ -26,11 +26,11 @@ * @example * var mean = require( '@stdlib/stats/base/dists/wald/mean' ); * -* var y = mean( 0.0, 1.0 ); -* // returns NaN -* * y = mean( 4.0, 2.0 ); * // returns 4.0 +* +* var y = mean( 0.0, 1.0 ); +* // returns NaN */ // MODULES // diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js index cbbc6a55ac16..8c634a4ecf38 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js @@ -26,13 +26,17 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); // MAIN // /** -* Returns the expected value for a wald distribution with mean `mu` and standard deviation `sigma`. +* Returns the expected value for a Wald distribution with mean `mu` and shape parameter `lambda`. * * @param {PositiveNumber} mu - mean -* @param {PositiveNumber} sigma - standard deviation +* @param {PositiveNumber} lambda - shape parameter * @returns {number} expected value * * @example +* var y = mean( 5.0, 2.0 ); +* // returns 5.0 +* +* @example * var y = mean( 0.0, 1.0 ); * // returns NaN * @@ -41,10 +45,6 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * // returns NaN * * @example -* var y = mean( 5.0, 2.0 ); -* // returns 5.0 -* -* @example * var y = mean( NaN, 1.0 ); * // returns NaN * @@ -56,11 +56,11 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * var y = mean( 0.0, 0.0 ); * // returns NaN */ -function mean( mu, sigma ) { +function mean( mu, lambda ) { if ( isnan( mu ) || - isnan( sigma ) || - sigma <= 0.0 || + isnan( lambda ) || + lambda <= 0.0 || mu <= 0.0 ) { return NaN; diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js index 0ab697000d15..8bc05a96efcd 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js @@ -26,14 +26,18 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Evaluates the expected value for a Wald distribution with mean `mu` and standard deviation `sigma`. +* Returns the expected value for a Wald distribution with mean `mu` and shape parameter `lambda`. * * @private * @param {PositiveNumber} mu - mean -* @param {PositiveNumber} sigma - standard deviation +* @param {PositiveNumber} lambda - shape parameter * @returns {number} expected value * * @example +* var y = mean( 5.0, 2.0 ); +* // returns 5.0 +* +* @example * var y = mean( 0.0, 1.0 ); * // returns NaN * @@ -42,10 +46,6 @@ var addon = require( './../src/addon.node' ); * // returns NaN * * @example -* var y = mean( 5.0, 2.0 ); -* // returns 5.0 -* -* @example * var y = mean( NaN, 1.0 ); * // returns NaN * @@ -57,8 +57,8 @@ var addon = require( './../src/addon.node' ); * var y = mean( 0.0, 0.0 ); * // returns NaN */ -function mean( mu, sigma ) { - return addon( mu, sigma ); +function mean( mu, lambda ) { + return addon( mu, lambda ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c index a61b3a4928d9..77cac2cac3b1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c @@ -20,21 +20,21 @@ #include "stdlib/math/base/assert/is_nan.h" /** -* Returns the expected value for a Wald distribution with mean `mu` and standard deviation `sigma`. +* Returns the expected value for a Wald distribution with mean `mu` and shape parameter `lambda`. * * @param mu mean -* @param sigma standard deviation +* @param lambda shape parameter * @return expected value * * @example * double y = stdlib_base_dists_wald_mean( 0.0, 1.0 ); * // returns NaN */ -double stdlib_base_dists_wald_mean( const double mu, const double sigma ) { +double stdlib_base_dists_wald_mean( const double mu, const double lambda ) { if ( stdlib_base_is_nan( mu ) || - stdlib_base_is_nan( sigma ) || - sigma <= 0.0 || + stdlib_base_is_nan( lambda ) || + lambda <= 0.0 || mu <= 0.0 ) { return 0.0/0.0; // NaN From 621821052fd928eef43404f5fbf4abfb96cda831 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sun, 4 Jan 2026 19:14:02 +0530 Subject: [PATCH 04/23] tests added --- .../wald/mean/test/fixtures/julia/REQUIRE | 3 + .../wald/mean/test/fixtures/julia/data.json | 1 + .../wald/mean/test/fixtures/julia/runner.jl | 73 ++++++++++ .../stats/base/dists/wald/mean/test/test.js | 122 ++++++++++++++++ .../base/dists/wald/mean/test/test.native.js | 131 ++++++++++++++++++ 5 files changed, 330 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/data.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/runner.jl create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/REQUIRE new file mode 100644 index 000000000000..98be20b58ed3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/REQUIRE @@ -0,0 +1,3 @@ +Distributions 0.23.8 +julia 1.5 +JSON 0.21 diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/data.json new file mode 100644 index 000000000000..cfbe8ef7b6da --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/data.json @@ -0,0 +1 @@ +{"expected":[9.332225166166651,4.889545882546147,8.398178040760154,8.28051688606067,10.037308954804253,2.502718542102402,7.361144462873464,4.6290650686210615,3.876004579200079,6.422275131670353,5.847241707222778,6.366914991757955,6.3136965687091315,1.2616538066411815,4.603872427242848,6.537353892173539,8.152422851677493,1.0464547963763833,2.710612560595008,5.944344069327309,0.6086555872000572,0.9402142643524798,1.8975149191791791,2.5592660212610725,8.411190477424839,1.4511014402516482,4.2799661543123335,2.512582270176002,5.478377943405063,6.625790372383061,8.036417885893009,1.1434235434431035,7.248202965261169,8.544775430784588,6.5271560990783035,1.3854073031905918,3.7908552390293435,1.815739884828775,4.825403589669921,5.960258859303156,3.925089029468621,2.959680175704071,1.7875516365929784,6.213426082693141,8.64994577208829,3.9929816134159095,7.035341816019935,5.139750121604752,6.747818783777024,5.693593444380466,7.05406684061938,4.450504155891876,5.252334634220371,9.944308223267468,9.689955196930264,6.153056956375431,4.9280542385342905,2.7205997321763338,2.249596354937495,6.750055582351145,3.635697451623767,6.020983582313165,2.0717837310856453,8.981456445786328,3.3955035997359415,3.195439266997708,3.840112632688915,9.099141700744402,4.696500733424958,7.94650546435074,5.2091615442465065,7.0753291610803855,2.740360721587835,9.234198915716275,3.6722035577834906,10.427889780083783,4.740324983370824,8.842418004545316,6.979281384206059,4.802591338824032,1.2394947382676298,5.485967425903818,6.57451079630462,6.8115020527796055,9.467064551440531,1.5936804087224317,6.171478312926959,2.0670836797282597,1.8768815259656886,2.357093610486099,8.092423494889843,7.126466335129598,2.039090122605643,1.83883305304474,2.2139656913364543,5.313101099755819,10.313940850710054,6.407997714085795,4.90624429117303,6.326134887572925],"lambda":[2.4381925339491883,2.628465773755839,2.012417715510364,4.908152011660872,5.437712855580483,3.5147627620188313,3.5654756243202126,1.8864035976287563,3.7214821935143028,3.561295494770946,3.99299654368766,4.182714373347759,2.4322312368001797,1.0850379207148493,4.923607937241683,5.331454019181694,2.885192532622818,1.483219707457349,2.9188646901231543,3.6952372936097966,4.044363988019289,2.2253627070979007,0.7157494318796016,2.5543836806138067,3.491759685024702,4.175978377393404,1.1971987046049544,1.4297733585547903,3.3168607368505656,1.7768518171807341,3.050144075381506,3.5717388711090257,2.9973851576862938,4.921262332163632,2.0709001666268954,4.021963050650139,1.8658212960501874,2.626395603412256,3.4583673042203102,2.187448743710048,3.7608721257528988,4.909961938230089,4.309411892351908,4.847204812153579,3.3013301053257162,3.735041861540103,3.9436456488137104,1.0593494505193513,3.5335201403084366,1.815217279102599,4.438149145243953,2.5166107154618116,1.7890831926346662,0.6945042774788941,0.8330606603588548,4.474369071322663,4.365752800064446,3.433469757679817,5.187358162841649,1.444228760121607,1.3943371916314646,3.472040323569132,3.3563074908211323,5.137951285727967,1.6930458678935019,5.340337861356611,0.5945486754970865,2.0903826812135193,4.866339711556141,5.444112989230162,2.95153432830598,5.210912576640788,3.643765833412289,3.450363742570289,1.9534999609813204,3.419278729046406,4.571560172147398,4.138778622086694,0.9524871199264641,2.0320347697315673,2.395740547765334,2.3449989306891252,4.903041379839658,3.949913109763868,3.633227998396955,2.1386778304411327,4.8926733895923045,4.595379354367254,3.563893013691468,1.9479695009488813,2.825428629673149,4.153716960254766,5.034786199791013,3.7156836571853247,1.6200482700114267,1.2675216445740574,4.4435733332893,3.8831446700592065,5.337445608606271,4.497655899808191],"mu":[9.332225166166651,4.889545882546147,8.398178040760154,8.28051688606067,10.037308954804253,2.502718542102402,7.361144462873464,4.6290650686210615,3.876004579200079,6.422275131670353,5.847241707222778,6.366914991757955,6.3136965687091315,1.2616538066411815,4.603872427242848,6.537353892173539,8.152422851677493,1.0464547963763833,2.710612560595008,5.944344069327309,0.6086555872000572,0.9402142643524798,1.8975149191791791,2.5592660212610725,8.411190477424839,1.4511014402516482,4.2799661543123335,2.512582270176002,5.478377943405063,6.625790372383061,8.036417885893009,1.1434235434431035,7.248202965261169,8.544775430784588,6.5271560990783035,1.3854073031905918,3.7908552390293435,1.815739884828775,4.825403589669921,5.960258859303156,3.925089029468621,2.959680175704071,1.7875516365929784,6.213426082693141,8.64994577208829,3.9929816134159095,7.035341816019935,5.139750121604752,6.747818783777024,5.693593444380466,7.05406684061938,4.450504155891876,5.252334634220371,9.944308223267468,9.689955196930264,6.153056956375431,4.9280542385342905,2.7205997321763338,2.249596354937495,6.750055582351145,3.635697451623767,6.020983582313165,2.0717837310856453,8.981456445786328,3.3955035997359415,3.195439266997708,3.840112632688915,9.099141700744402,4.696500733424958,7.94650546435074,5.2091615442465065,7.0753291610803855,2.740360721587835,9.234198915716275,3.6722035577834906,10.427889780083783,4.740324983370824,8.842418004545316,6.979281384206059,4.802591338824032,1.2394947382676298,5.485967425903818,6.57451079630462,6.8115020527796055,9.467064551440531,1.5936804087224317,6.171478312926959,2.0670836797282597,1.8768815259656886,2.357093610486099,8.092423494889843,7.126466335129598,2.039090122605643,1.83883305304474,2.2139656913364543,5.313101099755819,10.313940850710054,6.407997714085795,4.90624429117303,6.326134887572925]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/runner.jl new file mode 100644 index 000000000000..dd137b329ab9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/fixtures/julia/runner.jl @@ -0,0 +1,73 @@ +#!/usr/bin/env julia +# +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import Distributions: mean, InverseGaussian +import JSON + +""" + gen( mu, lambda, name ) + +Generate fixture data and write to file. + +# Arguments + +* `mu`: mean parameter +* `lambda`: shape parameter +* `name::AbstractString`: output filename + +# Examples + +``` julia +julia> mu = rand( 1000 ) .* 10.0 .+ 0.1; +julia> lambda = rand( 1000 ) .* 5.0 .+ 0.1; +julia> gen( mu, lambda, "data.json" ); +``` +""" +function gen( mu, lambda, name ) + z = Array{Float64}( undef, length(mu) ); + for i in eachindex(mu) + z[ i ] = mean( InverseGaussian( mu[i], lambda[i] ) ); + end + + # Store data to be written to file as a collection: + data = Dict([ + ("mu", mu), + ("lambda", lambda), + ("expected", z) + ]); + + # Based on the script directory, create an output filepath: + filepath = joinpath( dir, name ); + + # Write the data to the output filepath as JSON: + outfile = open( filepath, "w" ); + write( outfile, JSON.json(data) ); + write( outfile, "\n" ); + close( outfile ); +end + +# Get the filename: +file = @__FILE__; + +# Extract the directory in which this file resides: +dir = dirname( file ); + +# Generate fixtures: +mu = rand( 100 ) .* 10.0 .+ 0.5; +lambda = rand( 100 ) .* 5.0 .+ 0.5; +gen( mu, lambda, "data.json" ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.js new file mode 100644 index 000000000000..9f9d2d3761c8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.js @@ -0,0 +1,122 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var mean = require( './../lib' ); + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mean, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) { + var y = mean( NaN, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = mean( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = mean( NaN, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a nonpositive `lambda`, the function returns `NaN`', function test( t ) { + var y; + + y = mean( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NaN, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a nonpositive `mu`, the function returns `NaN`', function test( t ) { + var y; + + y = mean( 0.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( -1.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, PINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + + +tape( 'the function returns the expected value of a Wald distribution', function test( t ) { + var expected; + var lambda; + var mu; + var y; + var i; + + expected = data.expected; + mu = data.mu; + lambda = data.lambda; + for ( i = 0; i < mu.length; i++ ) { + y = mean( mu[i], lambda[i] ); + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'mu:'+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] ); + } else { + t.ok( isAlmostSameValue( y, expected[i], 20 ), 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js new file mode 100644 index 000000000000..ad3921dc020d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js @@ -0,0 +1,131 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// VARIABLES // + +var mean = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( mean instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof mean, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, function test( t ) { + var y = mean( NaN, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = mean( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = mean( NaN, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a nonpositive `lambda`, the function returns `NaN`', opts, function test( t ) { + var y; + + y = mean( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NaN, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a nonpositive `mu`, the function returns `NaN`', opts, function test( t ) { + var y; + + y = mean( 0.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( -1.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, PINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = mean( NINF, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + + +tape( 'the function returns the expected value of a Wald distribution', opts, function test( t ) { + var expected; + var lambda; + var mu; + var y; + var i; + + expected = data.expected; + mu = data.mu; + lambda = data.lambda; + for ( i = 0; i < mu.length; i++ ) { + y = mean( mu[i], lambda[i] ); + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'mu:'+mu[i]+', lambda: '+lambda[i]+', y: '+y+', expected: '+expected[i] ); + } else { + t.ok( isAlmostSameValue( y, expected[i], 20 ), 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' ); + } + } + t.end(); +}); From 663a7defd2d3ec55efaafd67515eb9b53017a55d Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sun, 4 Jan 2026 20:38:03 +0530 Subject: [PATCH 05/23] added examples --- .../base/dists/wald/mean/examples/c/Makefile | 146 ++++++++++++++++++ .../base/dists/wald/mean/examples/c/example.c | 41 +++++ .../base/dists/wald/mean/examples/index.js | 32 ++++ 3 files changed, 219 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/index.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c new file mode 100644 index 000000000000..50202907753b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dists/wald/mean.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 lambda; + double mu; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + mu = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); + lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 ); + y = stdlib_base_dists_wald_mean( mu, lambda ); + printf( "µ: %.4f, λ: %.4f, Mean(X;µ,λ): %.4f\n", mu, lambda, y ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/index.js new file mode 100644 index 000000000000..05d0707d539f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/index.js @@ -0,0 +1,32 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var mean = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; +var mu = uniform( 10, EPS, 10.0, opts ); +var lambda = uniform( 10, EPS, 20.0, opts ); + +logEachMap( 'µ: %0.4f, λ: %0.4f, E(X;µ,λ): %0.4f', mu, lambda, mean ); From a0496a6823c281ea4957c2d912a7fd5aab909975 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sun, 4 Jan 2026 20:47:00 +0530 Subject: [PATCH 06/23] defined EPS due to import error in CI --- .../@stdlib/stats/base/dists/wald/mean/examples/c/example.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c index 50202907753b..1a548d998bba 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c @@ -17,10 +17,13 @@ */ #include "stdlib/stats/base/dists/wald/mean.h" -#include "stdlib/constants/float64/eps.h" #include #include +#ifndef STDLIB_CONSTANT_FLOAT64_EPS +#define STDLIB_CONSTANT_FLOAT64_EPS 2.22044604925031308e-16 +#endif + static double random_uniform( const double min, const double max ) { double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); return min + ( v*(max-min) ); @@ -39,3 +42,4 @@ int main( void ) { printf( "µ: %.4f, λ: %.4f, Mean(X;µ,λ): %.4f\n", mu, lambda, y ); } } + From a3ea8f02f43ccebe479071c34e90aa20e3b0d448 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sun, 4 Jan 2026 20:54:40 +0530 Subject: [PATCH 07/23] linting error fixed --- .../@stdlib/stats/base/dists/wald/mean/test/test.js | 5 ++--- .../@stdlib/stats/base/dists/wald/mean/test/test.native.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.js index 9f9d2d3761c8..d71b01199f7d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.js @@ -46,8 +46,8 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', functio t.strictEqual( isnan( y ), true, 'returns expected value' ); y = mean( 1.0, NaN ); t.strictEqual( isnan( y ), true, 'returns expected value' ); - y = mean( NaN, NaN ); - t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = mean( NaN, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -99,7 +99,6 @@ tape( 'if provided a nonpositive `mu`, the function returns `NaN`', function tes t.end(); }); - tape( 'the function returns the expected value of a Wald distribution', function test( t ) { var expected; var lambda; diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js index ad3921dc020d..0628cee9c072 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js @@ -55,8 +55,8 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, f t.strictEqual( isnan( y ), true, 'returns expected value' ); y = mean( 1.0, NaN ); t.strictEqual( isnan( y ), true, 'returns expected value' ); - y = mean( NaN, NaN ); - t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = mean( NaN, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); t.end(); }); From 8b56e02f6a33f0d24f87b322c9a4880ef3bac230 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sun, 4 Jan 2026 21:02:07 +0530 Subject: [PATCH 08/23] linting error fixed --- .../@stdlib/stats/base/dists/wald/mean/test/test.native.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js index 0628cee9c072..20c76ab8ba72 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/test/test.native.js @@ -108,7 +108,6 @@ tape( 'if provided a nonpositive `mu`, the function returns `NaN`', opts, functi t.end(); }); - tape( 'the function returns the expected value of a Wald distribution', opts, function test( t ) { var expected; var lambda; From 5bbc72448560c3b8c378542779e619c6059a563b Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 5 Jan 2026 01:18:02 +0530 Subject: [PATCH 09/23] added docs --- .../stats/base/dists/wald/mean/docs/repl.txt | 40 ++++++++++++ .../dists/wald/mean/docs/types/index.d.ts | 61 +++++++++++++++++++ .../base/dists/wald/mean/docs/types/test.ts | 56 +++++++++++++++++ 3 files changed, 157 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt new file mode 100644 index 000000000000..183dec3fe311 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt @@ -0,0 +1,40 @@ + +{{alias}}( μ, λ ) + Returns the expected value of a Wald distribution with mean `μ` and + shape parameter `λ`. + + If provided `NaN` as any argument, the function returns `NaN`. + + If provided `σ <= 0` or `λ <= 0` the function returns `NaN`. + + Parameters + ---------- + μ: number + Location parameter. + + λ: number + Shape parameter. + + Returns + ------- + out: number + Expected value. + + Examples + -------- + > y = {{alias}}( 4.0, 2.0 ) + 4.0 + > var y = {{alias}}( 0.0, 1.0 ) + NaN + > var y = {{alias}}( 1.0, 0.0 ) + NaN + > y = {{alias}}( NaN, 1.0 ) + NaN + > y = {{alias}}( 0.0, NaN ) + NaN + > y = {{alias}}( 0.0, 0.0 ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts new file mode 100644 index 000000000000..6c0a8dcd449c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts @@ -0,0 +1,61 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the expected value for a Wald distribution with mean `mu` and shape parameter `lambda`. +* +* ## Notes +* +* - If provided `mu <= 0` or `lambda <= 0`, the function returns `NaN`. +* +* @param mu - mean +* @param lambda - shape parameter +* @returns expected value +* +* @example +* var y = mean( 5.0, 2.0 ); +* // returns 5.0 +* +* @example +* var y = mean( 0.0, 1.0 ); +* // returns NaN +* +* @example +* var y = mean( 1.0, 0.0 ); +* // returns NaN +* +* @example +* var y = mean( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = mean( 0.0, NaN ); +* // returns NaN +* +* @example +* var y = mean( 0.0, 0.0 ); +* // returns NaN +*/ +declare function mean( mu: number, lambda: number ): number; + + +// EXPORTS // + +export = mean; diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/test.ts new file mode 100644 index 000000000000..b038cf8caa92 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/test.ts @@ -0,0 +1,56 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import mean = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + mean( 5, 2 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than two numbers... +{ + mean( true, 3 ); // $ExpectError + mean( false, 2 ); // $ExpectError + mean( '5', 1 ); // $ExpectError + mean( [], 1 ); // $ExpectError + mean( {}, 2 ); // $ExpectError + mean( ( x: number ): number => x, 2 ); // $ExpectError + + mean( 9, true ); // $ExpectError + mean( 9, false ); // $ExpectError + mean( 5, '5' ); // $ExpectError + mean( 8, [] ); // $ExpectError + mean( 9, {} ); // $ExpectError + mean( 8, ( x: number ): number => x ); // $ExpectError + + mean( [], true ); // $ExpectError + mean( {}, false ); // $ExpectError + mean( false, '5' ); // $ExpectError + mean( {}, [] ); // $ExpectError + mean( '5', ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + mean(); // $ExpectError + mean( 3 ); // $ExpectError +} From f97623412337d1a4f94492a72e0f4c9c3397160a Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 5 Jan 2026 01:20:31 +0530 Subject: [PATCH 10/23] fixed copyright year --- .../@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts | 2 +- .../@stdlib/stats/base/dists/normal/mean/docs/types/test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts index 59cc87ab5644..65c454ce19ae 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2026 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/normal/mean/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/test.ts index cb5d2e243c81..7b9b8e3f7e1c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2026 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 87680661f9bc7f08430ff64f640ac1b887d2a046 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 5 Jan 2026 01:28:35 +0530 Subject: [PATCH 11/23] linting error fixed --- .../stats/base/dists/wald/mean/docs/types/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts index 6c0a8dcd449c..63aac10eeba7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts @@ -32,15 +32,15 @@ * @example * var y = mean( 5.0, 2.0 ); * // returns 5.0 -* +* * @example * var y = mean( 0.0, 1.0 ); * // returns NaN -* +* * @example * var y = mean( 1.0, 0.0 ); * // returns NaN -* +* * @example * var y = mean( NaN, 1.0 ); * // returns NaN From 5a5139c7ac9d149b1c98a9e6ecb8272642e31946 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 5 Jan 2026 12:25:57 +0530 Subject: [PATCH 12/23] suggestions implemented --- .../@stdlib/stats/base/dists/wald/mean/docs/repl.txt | 2 +- .../@stdlib/stats/base/dists/wald/mean/src/main.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt index 183dec3fe311..99a2c96d78d1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt @@ -5,7 +5,7 @@ If provided `NaN` as any argument, the function returns `NaN`. - If provided `σ <= 0` or `λ <= 0` the function returns `NaN`. + If provided `μ <= 0` or `λ <= 0` the function returns `NaN`. Parameters ---------- diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c index 77cac2cac3b1..580c2746f1e8 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/src/main.c @@ -22,9 +22,9 @@ /** * Returns the expected value for a Wald distribution with mean `mu` and shape parameter `lambda`. * -* @param mu mean +* @param mu mean * @param lambda shape parameter -* @return expected value +* @return expected value * * @example * double y = stdlib_base_dists_wald_mean( 0.0, 1.0 ); From e54875d11658bc50af1eca02d8887f88fd3f7b72 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 5 Jan 2026 16:38:12 +0530 Subject: [PATCH 13/23] benchmark and readme added --- .../stats/base/dists/wald/mean/README.md | 255 ++++++++++++++++++ .../dists/wald/mean/benchmark/benchmark.js | 54 ++++ .../wald/mean/benchmark/benchmark.native.js | 71 +++++ .../base/dists/wald/mean/benchmark/c/Makefile | 146 ++++++++++ .../dists/wald/mean/benchmark/c/benchmark.c | 140 ++++++++++ 5 files changed, 666 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/c/benchmark.c diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md new file mode 100644 index 000000000000..1db9a554ca7a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md @@ -0,0 +1,255 @@ + + +# Mean + +> [Wald][wald-distribution] distribution [expected value][mean]. + + + +
+ +The [expected value][mean] for a [wald][wald-distribution] random variable with mean `μ` and shape parameter `λ > 0` is + + + +```math +\mathbb{E}\left[ X \right] = \mu +``` + + + + + +
+ + + + + +
+ +## Usage + +```javascript +var mean = require( '@stdlib/stats/base/dists/wald/mean' ); +``` + +#### mean( mu, lambda ) + +Returns the [expected value][mean] for a [wald][wald-distribution] distribution with parameters `mu` (mean) and `lambda` (shape parameter). + +```javascript +var y = mean( 2.0, 1.0 ); +// returns 2.0 + +y = mean( 0.0, 1.0 ); +// returns NaN + +y = mean( -1.0, 4.0 ); +// returns NaN +``` + +If provided `NaN` as any argument, the function returns `NaN`. + +```javascript +var y = mean( NaN, 1.0 ); +// returns NaN + +y = mean( 0.0, NaN ); +// returns NaN +``` + +If provided `mu <= 0` or `lambda <= 0`, the function returns `NaN`. + +```javascript +var y = mean( 0.0, 0.0 ); +// returns NaN + +y = mean( 0.0, -1.0 ); +// returns NaN + +y = mean( -1.0, 0.0 ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var mean = require( '@stdlib/stats/base/dists/wald/mean' ); + +var opts = { + 'dtype': 'float64' +}; +var mu = uniform( 10, EPS, 10.0, opts ); +var lambda = uniform( 10, EPS, 20.0, opts ); + +logEachMap( 'µ: %0.4f, λ: %0.4f, E(X;µ,λ): %0.4f', mu, lambda, mean ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/wald/mean.h" +``` + +#### stdlib_base_dists_wald_mean( mu, lambda ) + +Returns the expected value for a [wald][wald-distribution] distribution with mean `mu` and shape parameter `lambda`. + +- **mu**: `[in] double` mean. +- **lambda**: `[in] double` shape parameter. + +```c +double stdlib_base_dists_wald_mean( const double mu, const double lambda ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/wald/mean.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 mu; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + mu = random_uniform( 0.1, 5.0 ); + lambda = random_uniform( 0.1, 20.0 ); + y = stdlib_base_dists_wald_mean( mu, lambda ); + printf( "µ: %.4f, λ: %.4f, Mean(X;µ,λ): %.4f\n", mu, lambda, y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js new file mode 100644 index 000000000000..97cfa5e723bf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var pkg = require( './../package.json' ).name; +var mean = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var lambda; + var mu; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + mu = ( randu()*100.0 ) + EPS; + lambda = ( randu()*20.0 ) + EPS; + y = mean( mu, lambda ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js new file mode 100644 index 000000000000..5b6ac01e86b5 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var mean = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( mean instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { + var lambda; + var len; + var mu; + var y; + var i; + + len = 100; + mu = new Float64Array( len ); + lambda = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + mu[ i ] = uniform( EPS, 100.0 ); + lambda[ i ] = uniform( EPS, 20.0 ); + } + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = mean( mu[ i % len ], lambda[ i % len ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/c/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/c/benchmark.c new file mode 100644 index 000000000000..1a4a2fa23df5 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/c/benchmark.c @@ -0,0 +1,140 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dists/wald/mean.h" +#include +#include +#include +#include +#include + +#define NAME "wald-mean" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [min,max). +* +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number +*/ +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + double lambda[ 100 ]; + double mu[ 100 ]; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + mu[ i ] = random_uniform( 0.1, 10.0 ); + lambda[ i ] = random_uniform( 0.1, 10.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_wald_mean( mu[ i%100 ], lambda[ i%100 ] ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} From 7dfb31ab2b9ea486deb3ff6fa5ca169135469406 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 5 Jan 2026 16:40:52 +0530 Subject: [PATCH 14/23] copyright year fixed --- lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md | 2 +- .../@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts | 2 +- .../@stdlib/stats/base/dists/wald/mean/docs/types/test.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md index 1db9a554ca7a..308930df37da 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2026 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/wald/mean/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts index 63aac10eeba7..12e6f02811dc 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2026 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/wald/mean/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/test.ts index b038cf8caa92..584afe7a8543 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2026 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 1a9d7b2d9f6d28bf1286df92c7c163ae73dcbeb8 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 6 Jan 2026 22:32:10 -0600 Subject: [PATCH 15/23] chore: revert copyright year changes Signed-off-by: Philipp Burckhardt --- .../@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts | 2 +- .../@stdlib/stats/base/dists/normal/mean/docs/types/test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts index 65c454ce19ae..59cc87ab5644 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2026 The Stdlib Authors. +* Copyright (c) 2019 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/normal/mean/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/test.ts index 7b9b8e3f7e1c..cb5d2e243c81 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2026 The Stdlib Authors. +* Copyright (c) 2019 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 d78d7a573afec67d0fdaad82d3a4deb28fd42fd5 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Wed, 7 Jan 2026 12:38:50 +0530 Subject: [PATCH 16/23] comments resolved --- .../stats/base/dists/wald/mean/README.md | 12 ++++++------ .../dists/wald/mean/benchmark/benchmark.js | 12 ++++++++---- .../wald/mean/benchmark/benchmark.native.js | 19 ++++++++----------- .../stats/base/dists/wald/mean/docs/repl.txt | 6 +++--- .../base/dists/wald/mean/examples/c/example.c | 8 ++------ .../stats/base/dists/wald/mean/lib/index.js | 4 ++-- .../stats/base/dists/wald/mean/lib/main.js | 2 +- .../stats/base/dists/wald/mean/lib/native.js | 2 +- 8 files changed, 31 insertions(+), 34 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md index 308930df37da..e194d5bc8d3c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md @@ -26,16 +26,16 @@ limitations under the License.
-The [expected value][mean] for a [wald][wald-distribution] random variable with mean `μ` and shape parameter `λ > 0` is +The [expected value][mean] for a [Wald][wald-distribution] random variable with mean `μ` and shape parameter `λ > 0` is - + ```math \mathbb{E}\left[ X \right] = \mu ``` - @@ -57,7 +57,7 @@ var mean = require( '@stdlib/stats/base/dists/wald/mean' ); #### mean( mu, lambda ) -Returns the [expected value][mean] for a [wald][wald-distribution] distribution with parameters `mu` (mean) and `lambda` (shape parameter). +Returns the [expected value][mean] for a [Wald][wald-distribution] distribution with parameters `mu` (mean) and `lambda` (shape parameter). ```javascript var y = mean( 2.0, 1.0 ); @@ -174,7 +174,7 @@ logEachMap( 'µ: %0.4f, λ: %0.4f, E(X;µ,λ): %0.4f', mu, lambda, mean ); #### stdlib_base_dists_wald_mean( mu, lambda ) -Returns the expected value for a [wald][wald-distribution] distribution with mean `mu` and shape parameter `lambda`. +Returns the expected value for a [Wald][wald-distribution] distribution with mean `mu` and shape parameter `lambda`. - **mu**: `[in] double` mean. - **lambda**: `[in] double` shape parameter. diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js index 97cfa5e723bf..d30218f65218 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var EPS = require( '@stdlib/constants/float64/eps' ); var pkg = require( './../package.json' ).name; @@ -36,11 +36,15 @@ bench( pkg, function benchmark( b ) { var y; var i; + var opts = { + 'dtype': 'float64' + }; + mu = uniform( 100, EPS, 100.0, opts ); + lambda = uniform( 100, EPS, 20.0, opts ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - mu = ( randu()*100.0 ) + EPS; - lambda = ( randu()*20.0 ) + EPS; - y = mean( mu, lambda ); + y = mean( mu[ i % 100 ], lambda[ i % 100 ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js index 5b6ac01e86b5..cfd3bd9e366f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var format = require( '@stdlib/string/format' ); @@ -43,21 +42,19 @@ var opts = { bench( format( '%s::native', pkg ), opts, function benchmark( b ) { var lambda; - var len; var mu; var y; var i; - len = 100; - mu = new Float64Array( len ); - lambda = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - mu[ i ] = uniform( EPS, 100.0 ); - lambda[ i ] = uniform( EPS, 20.0 ); - } + var arrayOpts = { + 'dtype': 'float64' + }; + mu = uniform( 100, EPS, 100.0, arrayOpts ); + lambda = uniform( 100, EPS, 20.0, arrayOpts ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mean( mu[ i % len ], lambda[ i % len ] ); + y = mean( mu[ i % 100 ], lambda[ i % 100 ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt index 99a2c96d78d1..52b0af4f1830 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt @@ -22,11 +22,11 @@ Examples -------- - > y = {{alias}}( 4.0, 2.0 ) + > var y = {{alias}}( 4.0, 2.0 ) 4.0 - > var y = {{alias}}( 0.0, 1.0 ) + > y = {{alias}}( 0.0, 1.0 ) NaN - > var y = {{alias}}( 1.0, 0.0 ) + > y = {{alias}}( 1.0, 0.0 ) NaN > y = {{alias}}( NaN, 1.0 ) NaN diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c index 1a548d998bba..bd1fc1f63b32 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/examples/c/example.c @@ -20,10 +20,6 @@ #include #include -#ifndef STDLIB_CONSTANT_FLOAT64_EPS -#define STDLIB_CONSTANT_FLOAT64_EPS 2.22044604925031308e-16 -#endif - static double random_uniform( const double min, const double max ) { double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); return min + ( v*(max-min) ); @@ -36,8 +32,8 @@ int main( void ) { int i; for ( i = 0; i < 10; i++ ) { - mu = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); - lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 ); + mu = random_uniform( 0.1, 10.0 ); + lambda = random_uniform( 0.1, 20.0 ); y = stdlib_base_dists_wald_mean( mu, lambda ); printf( "µ: %.4f, λ: %.4f, Mean(X;µ,λ): %.4f\n", mu, lambda, y ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js index f36777558c1d..da683e8ec693 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/index.js @@ -26,10 +26,10 @@ * @example * var mean = require( '@stdlib/stats/base/dists/wald/mean' ); * -* y = mean( 4.0, 2.0 ); +* var y = mean( 4.0, 2.0 ); * // returns 4.0 * -* var y = mean( 0.0, 1.0 ); +* y = mean( 0.0, 1.0 ); * // returns NaN */ diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js index 8c634a4ecf38..90babec7c1c7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/main.js @@ -30,7 +30,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); * * @param {PositiveNumber} mu - mean * @param {PositiveNumber} lambda - shape parameter -* @returns {number} expected value +* @returns {PositiveNumber} expected value * * @example * var y = mean( 5.0, 2.0 ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js index 8bc05a96efcd..2aaefd940c31 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/lib/native.js @@ -31,7 +31,7 @@ var addon = require( './../src/addon.node' ); * @private * @param {PositiveNumber} mu - mean * @param {PositiveNumber} lambda - shape parameter -* @returns {number} expected value +* @returns {PositiveNumber} expected value * * @example * var y = mean( 5.0, 2.0 ); From f4dee690130437e2416798c994b6948aef17edbe Mon Sep 17 00:00:00 2001 From: manit2004 Date: Wed, 7 Jan 2026 12:49:13 +0530 Subject: [PATCH 17/23] linting error fixed --- .../stats/base/dists/wald/mean/benchmark/benchmark.js | 4 +--- .../base/dists/wald/mean/benchmark/benchmark.native.js | 8 +++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js index d30218f65218..457d7850c30f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js @@ -32,13 +32,11 @@ var mean = require( './../lib' ); bench( pkg, function benchmark( b ) { var lambda; + var opts = {'dtype': 'float64'}; var mu; var y; var i; - var opts = { - 'dtype': 'float64' - }; mu = uniform( 100, EPS, 100.0, opts ); lambda = uniform( 100, EPS, 20.0, opts ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js index cfd3bd9e366f..7d535d342dcf 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js @@ -41,14 +41,12 @@ var opts = { // MAIN // bench( format( '%s::native', pkg ), opts, function benchmark( b ) { - var lambda; + var arrayOpts = {'dtype': 'float64'}; + var lambda; var mu; var y; var i; - - var arrayOpts = { - 'dtype': 'float64' - }; + mu = uniform( 100, EPS, 100.0, arrayOpts ); lambda = uniform( 100, EPS, 20.0, arrayOpts ); From e2af1d3f6d28686019480c63bbb6f03a97b990f7 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Wed, 7 Jan 2026 12:58:28 +0530 Subject: [PATCH 18/23] linting error fixed --- .../stats/base/dists/wald/mean/benchmark/benchmark.js | 4 +++- .../base/dists/wald/mean/benchmark/benchmark.native.js | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js index 457d7850c30f..40b26778031f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js @@ -32,7 +32,9 @@ var mean = require( './../lib' ); bench( pkg, function benchmark( b ) { var lambda; - var opts = {'dtype': 'float64'}; + var opts = { + 'dtype': 'float64' + }; var mu; var y; var i; diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js index 7d535d342dcf..b646d4e21049 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js @@ -41,12 +41,14 @@ var opts = { // MAIN // bench( format( '%s::native', pkg ), opts, function benchmark( b ) { - var arrayOpts = {'dtype': 'float64'}; + var arrayOpts = { + 'dtype': 'float64' + }; var lambda; var mu; var y; var i; - + mu = uniform( 100, EPS, 100.0, arrayOpts ); lambda = uniform( 100, EPS, 20.0, arrayOpts ); From 042fd0e66fdd7c4822349e38bb9a4f568ac33508 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Wed, 7 Jan 2026 13:10:37 +0530 Subject: [PATCH 19/23] linting error fixed --- .../stats/base/dists/wald/mean/benchmark/benchmark.js | 9 +++++---- .../base/dists/wald/mean/benchmark/benchmark.native.js | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js index 40b26778031f..0d944345fe84 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js @@ -31,14 +31,15 @@ var mean = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var lambda; - var opts = { - 'dtype': 'float64' - }; + var lambda; + var opts; var mu; var y; var i; + opts = { + 'dtype': 'float64' + }; mu = uniform( 100, EPS, 100.0, opts ); lambda = uniform( 100, EPS, 20.0, opts ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js index b646d4e21049..529f081d381c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.native.js @@ -41,14 +41,15 @@ var opts = { // MAIN // bench( format( '%s::native', pkg ), opts, function benchmark( b ) { - var arrayOpts = { - 'dtype': 'float64' - }; - var lambda; + var arrayOpts; + var lambda; var mu; var y; var i; + arrayOpts = { + 'dtype': 'float64' + }; mu = uniform( 100, EPS, 100.0, arrayOpts ); lambda = uniform( 100, EPS, 20.0, arrayOpts ); From bfd004960c5715a4184fe85ec963b4308f2771e7 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Wed, 7 Jan 2026 13:18:55 +0530 Subject: [PATCH 20/23] fix: correct indentation on line 34 --- .../@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js index 0d944345fe84..dd53b851ad54 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/benchmark/benchmark.js @@ -31,7 +31,7 @@ var mean = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var lambda; + var lambda; var opts; var mu; var y; From bc5f5c339d80512662005ea9cc1bc34be87b84e4 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 7 Jan 2026 13:37:36 -0600 Subject: [PATCH 21/23] chore: clean-up sections Signed-off-by: Philipp Burckhardt --- .../stats/base/dists/wald/mean/README.md | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md index e194d5bc8d3c..9406f5035f7d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2026 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. @@ -132,23 +132,9 @@ logEachMap( 'µ: %0.4f, λ: %0.4f, E(X;µ,λ): %0.4f', mu, lambda, mean ); - - -
- -
- - - - - - - - + - +* * *
@@ -162,7 +148,7 @@ logEachMap( 'µ: %0.4f, λ: %0.4f, E(X;µ,λ): %0.4f', mu, lambda, mean ); - +
@@ -174,7 +160,14 @@ logEachMap( 'µ: %0.4f, λ: %0.4f, E(X;µ,λ): %0.4f', mu, lambda, mean ); #### stdlib_base_dists_wald_mean( mu, lambda ) -Returns the expected value for a [Wald][wald-distribution] distribution with mean `mu` and shape parameter `lambda`. +Returns the [expected value][mean] for a [Wald][wald-distribution] distribution with mean `mu` and shape parameter `lambda`. + +```c +double out = stdlib_base_dists_wald_mean( 2.0, 1.0 ); +// returns 2.0 +``` + +The function accepts the following arguments: - **mu**: `[in] double` mean. - **lambda**: `[in] double` shape parameter. @@ -234,6 +227,14 @@ int main( void ) { + + +
+ +
+ + + From c3abeb3f49ce28d7ab6751194773fcb6033626d6 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 7 Jan 2026 13:38:46 -0600 Subject: [PATCH 22/23] chore: revert changes Signed-off-by: Philipp Burckhardt --- lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md index 9406f5035f7d..8c4fc5c3c186 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +Copyright (c) 2026 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. @@ -249,7 +249,7 @@ int main( void ) { [wald-distribution]: https://en.wikipedia.org/wiki/Inverse_Gaussian_distribution -[mean]: https://en.wikipedia.org/wiki/Expected_value +[mean]: https://en.wikipedia.org/wiki/Mean
From cf2bcb004e7afee30f59a7bf5ebe015bd73ca7f1 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 7 Jan 2026 13:40:03 -0600 Subject: [PATCH 23/23] docs: update description Signed-off-by: Philipp Burckhardt --- .../@stdlib/stats/base/dists/wald/mean/docs/repl.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt index 52b0af4f1830..30595320e8e9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt @@ -10,7 +10,7 @@ Parameters ---------- μ: number - Location parameter. + Mean parameter. λ: number Shape parameter.