From e844e7af2d49a8ad66f8fd448fe7bb4ab43f87da Mon Sep 17 00:00:00 2001 From: manit2004 Date: Wed, 7 Jan 2026 12:16:16 +0530 Subject: [PATCH 01/10] incomplete main.js --- .../base/dists/wald/variance/lib/main.js | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/main.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/main.js new file mode 100644 index 000000000000..9137da0fe06b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/main.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); + + +// MAIN // + +/** +* Returns the variance for a Wald distribution with mean `mu` and shape parameter `lambda`. +* +* @param {PositiveNumber} mu - mean +* @param {PositiveNumber} lambda - shape parameter +* @returns {PositiveNumber} variance +* +* @example +* var y = variance( 0.0, 1.0 ); +* // returns 1.0 +* +* @example +* var y = variance( 5.0, 3.0 ); +* // returns 9.0 +* +* @example +* var y = variance( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = variance( 0.0, NaN ); +* // returns NaN +* +* @example +* var y = variance( 0.0, 0.0 ); +* // returns NaN +*/ +function variance( mu, lambda ) { + if ( + isnan( mu ) || + isnan( lambda ) || + mu <= 0.0 || + lambda <= 0.0 + ) { + return NaN; + } + return (mu*mu*mu) / lambda; +} + + +// EXPORTS // + +module.exports = variance; From e0c7dc8aca8b98e5a8a6925078bf21c5d464794d Mon Sep 17 00:00:00 2001 From: manit2004 Date: Tue, 13 Jan 2026 20:57:57 +0530 Subject: [PATCH 02/10] feat: add Wald distribution variance core --- .../base/dists/wald/variance/binding.gyp | 170 ++++++++++++++++++ .../base/dists/wald/variance/include.gypi | 53 ++++++ .../stdlib/stats/base/dists/wald/variance.h | 38 ++++ .../base/dists/wald/variance/lib/index.js | 43 +++++ .../base/dists/wald/variance/lib/main.js | 10 +- .../base/dists/wald/variance/lib/native.js | 63 +++++++ .../base/dists/wald/variance/manifest.json | 76 ++++++++ .../base/dists/wald/variance/package.json | 69 +++++++ .../base/dists/wald/variance/src/Makefile | 70 ++++++++ .../base/dists/wald/variance/src/addon.c | 22 +++ .../stats/base/dists/wald/variance/src/main.c | 43 +++++ 11 files changed, 652 insertions(+), 5 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/include/stdlib/stats/base/dists/wald/variance.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/main.c diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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 which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler 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/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(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 copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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", + "inverse gaussian", + "wald", + "continuous", + "variance", + "spread", + "dispersion", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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/variance/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/addon.c new file mode 100644 index 000000000000..24cb280a264a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/addon.c @@ -0,0 +1,22 @@ +/** +* @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/variance.h" +#include "stdlib/math/base/napi/binary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_wald_variance ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/main.c new file mode 100644 index 000000000000..948cfbce9900 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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/variance.h" +#include "stdlib/math/base/assert/is_nan.h" + +/** +* Returns the variance for a Wald distribution with mean `mu` and shape parameter `lambda`. +* +* @param mu mean +* @param lambda shape parameter +* @return variance +* +* @example +* double y = stdlib_base_dists_wald_variance( 4.0, 3.0 ); +* // returns ~21.33 +*/ +double stdlib_base_dists_wald_variance( const double mu, const double lambda ) { + if ( + stdlib_base_is_nan( mu ) || + stdlib_base_is_nan( lambda ) || + lambda <= 0.0 || + mu <= 0.0 + ) { + return 0.0 / 0.0; // NaN + } + return (mu * mu * mu) / lambda; +} From 1f0e83d11b216d5ab779dfb51cc71d8226edcab4 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sun, 18 Jan 2026 21:46:30 +0530 Subject: [PATCH 03/10] tests & README added, indentation fixed --- .../stats/base/dists/wald/variance/README.md | 256 ++++++++++++++++++ .../stats/base/dists/wald/variance/src/main.c | 2 +- .../wald/variance/test/fixtures/julia/REQUIRE | 3 + .../variance/test/fixtures/julia/data.json | 1 + .../variance/test/fixtures/julia/runner.jl | 73 +++++ .../base/dists/wald/variance/test/test.js | 121 +++++++++ .../dists/wald/variance/test/test.native.js | 130 +++++++++ 7 files changed, 585 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/data.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/runner.jl create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md new file mode 100644 index 000000000000..1033a75d428c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md @@ -0,0 +1,256 @@ + + +# Variance + +> [Wald][wald-distribution] distribution [variance][variance]. + + + +
+ +The [variance][variance] for a [Wald][wald-distribution] random variable with mean `μ` and shape parameter `λ > 0` is + + + +```math +\operatorname{Var}\left[ X \right] = \frac{\mu^{3}}{\lambda} +``` + + + + + +
+ + + + + +
+ +## Usage + +```javascript +var variance = require( '@stdlib/stats/base/dists/wald/variance' ); +``` + +#### variance( mu, lambda ) + +Returns the [variance][variance] for a [Wald][wald-distribution] distribution with parameters `mu` (mean) and `lambda` (shape parameter). + +```javascript +var y = variance( 2.0, 1.0 ); +// returns 8.0 + +y = variance( 0.0, 1.0 ); +// returns NaN + +y = variance( 4.0, -1.0 ); +// returns NaN +``` + +If provided `NaN` as any argument, the function returns `NaN`. + +```javascript +var y = variance( NaN, 1.0 ); +// returns NaN + +y = variance( 0.0, NaN ); +// returns NaN +``` + +If provided `mu <= 0` or `lambda <= 0`, the function returns `NaN`. + +```javascript +var y = variance( 0.0, 0.0 ); +// returns NaN + +y = variance( 0.0, -1.0 ); +// returns NaN + +y = variance( -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 variance = require( '@stdlib/stats/base/dists/wald/variance' ); + +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, Var(X;µ,λ): %0.4f', mu, lambda, variance ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/wald/variance.h" +``` + +#### stdlib_base_dists_wald_variance( mu, lambda ) + +Returns the [variance][variance] for a [Wald][wald-distribution] distribution with mean `mu` and shape parameter `lambda`. + +```c +double out = stdlib_base_dists_wald_variance( 2.0, 1.0 ); +// returns 8.0 +``` + +The function accepts the following arguments: + +- **mu**: `[in] double` mean. +- **lambda**: `[in] double` shape parameter. + +```c +double stdlib_base_dists_wald_variance( const double mu, const double lambda ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/wald/variance.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_variance( mu, lambda ); + printf( "µ: %.4f, λ: %.4f, Var(X;µ,λ): %.4f\n", mu, lambda, y ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/main.c index 948cfbce9900..de8630e5ff09 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/src/main.c @@ -35,7 +35,7 @@ double stdlib_base_dists_wald_variance( const double mu, const double lambda ) { stdlib_base_is_nan( mu ) || stdlib_base_is_nan( lambda ) || lambda <= 0.0 || - mu <= 0.0 + mu <= 0.0 ) { return 0.0 / 0.0; // NaN } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/REQUIRE new file mode 100644 index 000000000000..98be20b58ed3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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/variance/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/data.json new file mode 100644 index 000000000000..73f0f6eceb13 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/data.json @@ -0,0 +1 @@ +{"expected":[8.100951025218672,41.139335895015634,14.964572157085984,0.7464523536991912,0.731454707414437,0.42796724803683306,31.128038277643967,209.64650779641252,4.203412492348386,5.593309634465082,12.081488719195239,16.387991238099925,6.443056316293867,144.28042771457257,19.904263965228772,10.184821371439778,8.900661652533337,12.244417516393426,45.7133372972402,17.218313493524242,8.054006980166575,0.33657471792660165,16.000019247377605,11.892712326399948,1.8115961097537048,85.70734284921495,19.603131402208305,13.155928623707991,0.7219148834830849,95.73491412981456,86.7383642354854,132.34286076528232,140.47773978258743,36.73857295399216,63.93021601491242,6.150585129812031,23.641297414032724,4.112830327160116,6.67030332106242,93.14578064890749,52.72751940225067,23.836026372232844,2.5329394371664136,7.8761865495389785,14.364042354012085,250.69015608221176,284.21390330062746,18.696257807157764,9.210329370346281,23.72098258133183,61.25470048595522,88.7679211279728,49.211975628541985,2.8567131362699185,119.68807162880789,76.49495693467058,1.353654773813254,19.573256387146362,24.039272110134185,16.327173711880583,39.30086673707218,73.47655026810925,27.285039924381262,37.22037149875182,18.857183428315206,0.18638091409459684,54.41914160138177,16.296721411723613,1.9806838461862422,123.26834170096826,10.89222250358138,49.13955921053847,36.380077432014446,29.117661247438033,410.18279060894594,87.78096784479204,0.5107735122914147,95.08756171412942,51.2039422399388,49.23643016159282,8.16116700762801,113.45637635054157,3.882149833588118,4.131615375096664,0.5109460860836711,29.893447928149225,41.62304420003549,5.71399802617943,32.09050070920586,0.8495154104373296,0.03984590173207111,18.857439971714157,0.027183176300847385,20.540564395511595,2.4846608013544884,1.864265062338307,6.003224117673743,294.33120777280317,23.235300789710017,5.153224317795032],"lambda":[1.3544248282209892,1.166910720451576,3.0908015892852245,4.326213305406751,2.4539924582073644,4.428129992712168,2.038361674472204,0.12641030312255044,4.995209307517393,4.988990338432183,2.219248673965915,3.705346653122905,1.8315440237609497,1.1341174404278802,5.048830430469308,3.2383108998245658,4.491859150729754,0.9265857220179989,2.79474686322438,0.1739736676825209,4.3443908963969795,3.765567189499523,2.9472021016701104,4.000227535487621,2.029090835315715,1.1832014845198946,4.140248830473532,2.025078469892419,0.4794160361321885,0.7667484991533212,1.624622037673531,0.4305025626787966,0.7383588026190023,4.2479880814370095,2.3303246847418047,3.725733290945104,3.399664220738699,3.337260837531535,3.0245131412681565,1.3613525774907593,2.333676777325773,3.6457210794606687,3.7213232322085594,1.1007553201305105,4.937211761631916,0.5223078946022696,0.5240652378049847,4.5949878969006,4.310052971919864,4.565519309208742,1.8228496420444729,1.8534518460197384,2.021574025784214,2.5507041870655285,1.2615136362591717,0.6318632125480932,3.4237771233348617,4.146138624389654,4.212177791902156,4.729187373267945,4.161781272602025,0.20118511974695322,4.874935881558281,4.298492943883961,1.0251731761546434,3.325165303592326,2.6332537418769806,1.5166803361197538,4.989433942962941,0.8238986914984163,2.5480727160993006,1.2376617955512077,2.2795993907796426,1.6160485687943027,0.17910404496477508,1.1628796334508262,2.071824421750541,1.0854166266947218,0.36589591617860284,1.1827317682714877,1.9957594734814643,0.7911651799772889,4.568674485330625,4.768391985874628,3.568793970922643,0.7958068754951507,2.1804983684804538,0.2178277267487471,2.499153316870899,4.29701535011367,3.983879631744944,2.025679834420671,4.905914350188668,3.4646621501757617,3.3708710476824533,2.4223626796677067,0.4575695828365677,0.41807946203868396,3.938827360548727,2.146291705004581],"mu":[2.2221001958321014,3.6343908922686605,3.5895924565388526,1.4780983770861824,1.2153094856503524,1.237495510113781,3.9885128811590027,2.981421427464969,2.758789517015834,3.0331496737109798,2.9930144064384496,3.930533684848007,2.2766857877222426,5.469594750253574,4.649207921565832,3.2069386567139047,3.41939658800922,2.247025035796927,5.036495711396514,1.441533402208374,3.270747104095314,1.0821911148066672,3.612796291422397,3.623446635471017,1.543313977664821,4.663288083424374,4.329628477202467,2.9866737732974626,0.7021008801544577,4.187046289430107,5.203807099199652,3.8479145553246488,4.6984901705415485,5.383960407106704,5.30120016110774,2.840377511185512,4.315546267138358,2.394291268696442,2.722285602796101,5.023941822428645,4.973849974392646,4.429340820783494,2.1123898240819217,2.0543239486204854,4.139229221151465,5.077944582796802,5.300826106196564,4.41244887651883,3.4112948323837937,4.766588046056188,4.815374729669445,5.479561245907208,4.633617172647182,1.9386924052418721,5.324934536961027,3.642659903034331,1.6672643664354614,4.3294789700648515,4.660966725146633,4.2582633005381485,5.468822065464226,2.4542278002302904,5.104632726985141,5.428739144002224,2.6838486431006543,0.8525860566998074,5.232968642593267,2.9129392843374364,2.145962584357391,4.6656102408145035,3.027676295687273,3.932581639444694,4.360879138970429,3.610247417852317,4.188201903956029,4.673530089111892,1.019045960666538,4.690725947798338,2.6559526023870705,3.8760640043614085,2.534857139555993,4.477463195215929,2.6078793955490327,2.70083018108048,1.2217026552178036,2.876037640059463,4.4939668940081585,1.0756832723255227,4.312440649578052,1.5397352610087656,0.541456147961802,3.367837896740773,0.5109048842360848,4.144044605504164,2.0308121317635672,1.6529089928759506,1.400491792392597,4.973915260678394,4.506490034244852,2.2280380236014476]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/fixtures/julia/runner.jl new file mode 100644 index 000000000000..73f8738b0479 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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: var, 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 ) .* 5.0 .+ 0.5; +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 ] = var( 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 ) .* 5.0 .+ 0.5; +lambda = rand( 100 ) .* 5.0 .+ 0.1; +gen( mu, lambda, "data.json" ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.js new file mode 100644 index 000000000000..c8c914f8770f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.js @@ -0,0 +1,121 @@ +/** +* @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 variance = 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 variance, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) { + var y = variance( NaN, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = variance( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = variance( NaN, NaN ); + 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 = variance( 0.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( -1.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, PINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, 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 = variance( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NaN, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the variance 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 = variance( 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/variance/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.native.js new file mode 100644 index 000000000000..dd62cb8014d7 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.native.js @@ -0,0 +1,130 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); + + +// VARIABLES // + +var variance = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( variance instanceof Error ) +}; + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof variance, '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 = variance( NaN, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = variance( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = variance( NaN, NaN ); + 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 = variance( 0.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( -1.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, PINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, 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 = variance( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = variance( NaN, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the variance 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 = variance( 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 d7f6bc9db7ca7a7dfe1b12e3db18936484a89efc Mon Sep 17 00:00:00 2001 From: manit2004 Date: Sun, 18 Jan 2026 21:54:40 +0530 Subject: [PATCH 04/10] errors fixed --- .../@stdlib/stats/base/dists/wald/variance/README.md | 3 ++- .../@stdlib/stats/base/dists/wald/variance/test/test.js | 4 ++-- .../stats/base/dists/wald/variance/test/test.native.js | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md index 1033a75d428c..3b16c04e391c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md @@ -253,4 +253,5 @@ int main( void ) { - \ No newline at end of file + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.js index c8c914f8770f..7e8beb938cfd 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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 = variance( 1.0, NaN ); t.strictEqual( isnan( y ), true, 'returns expected value' ); - y = variance( NaN, NaN ); - t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = variance( NaN, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.native.js index dd62cb8014d7..910861918abf 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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 = variance( 1.0, NaN ); t.strictEqual( isnan( y ), true, 'returns expected value' ); - y = variance( NaN, NaN ); - t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = variance( NaN, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); t.end(); }); From 13a67c609460111081ffbd9e05a09be201bc5af5 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 19 Jan 2026 02:32:54 +0530 Subject: [PATCH 05/10] benchmark added --- .../wald/variance/benchmark/benchmark.js | 59 +++++++ .../variance/benchmark/benchmark.native.js | 70 +++++++++ .../dists/wald/variance/benchmark/c/Makefile | 146 ++++++++++++++++++ .../wald/variance/benchmark/c/benchmark.c | 140 +++++++++++++++++ 4 files changed, 415 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/benchmark.c diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js new file mode 100644 index 000000000000..f7bf6b2f0429 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js @@ -0,0 +1,59 @@ +/** +* @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 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; +var variance = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + 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 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = variance( mu[ i % 100 ], lambda[ i % 100 ] ); + 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/variance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js new file mode 100644 index 000000000000..d6705aadc6ee --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +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' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var variance = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( variance instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { + 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 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = variance( mu[ i % 100 ], lambda[ i % 100 ] ); + 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/variance/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# 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. +# 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/variance/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/benchmark.c new file mode 100644 index 000000000000..14b56e7ffb2d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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/variance.h" +#include +#include +#include +#include +#include + +#define NAME "wald-variance" +#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, 50.0 ); + lambda[ i ] = random_uniform( 1.0, 20.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_wald_variance( 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 9bf59a59200409589bc7aa93914073271323cde6 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 19 Jan 2026 02:40:16 +0530 Subject: [PATCH 06/10] errors fixed --- .../stats/base/dists/normal/variance/benchmark/c/Makefile | 2 +- .../base/dists/wald/variance/benchmark/benchmark.native.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/normal/variance/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/normal/variance/benchmark/c/Makefile index a4bd7b38fd74..979768abbcec 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/normal/variance/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/normal/variance/benchmark/c/Makefile @@ -1,7 +1,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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js index d6705aadc6ee..7dcb97cba1e4 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js @@ -67,4 +67,3 @@ bench( format( '%s::native', pkg ), opts, function benchmark( b ) { b.pass( 'benchmark finished' ); b.end(); }); - From 0c3351834d6f686d6f4bfdd328072f96fa6f6a98 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 19 Jan 2026 04:23:19 +0530 Subject: [PATCH 07/10] docs & examples added --- .../base/dists/wald/variance/docs/repl.txt | 40 +++++ .../dists/wald/variance/docs/types/index.d.ts | 61 ++++++++ .../dists/wald/variance/docs/types/test.ts | 56 +++++++ .../dists/wald/variance/examples/c/Makefile | 146 ++++++++++++++++++ .../dists/wald/variance/examples/c/example.c | 40 +++++ .../dists/wald/variance/examples/index.js | 32 ++++ 6 files changed, 375 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/index.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/repl.txt new file mode 100644 index 000000000000..68967b5bae6a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/repl.txt @@ -0,0 +1,40 @@ + +{{alias}}( μ, λ ) + Returns the variance 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 + Variance. + + Examples + -------- + > var y = {{alias}}( 2.0, 1.0 ) + 8.0 + > y = {{alias}}( 4.0, 2.0 ) + 32.0 + > y = {{alias}}( NaN, 1.0 ) + NaN + > y = {{alias}}( 1.0, NaN ) + NaN + > y = {{alias}}( 0.0, 1.0 ) + NaN + > y = {{alias}}( 1.0, 0.0 ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/types/index.d.ts new file mode 100644 index 000000000000..eb2c4ca6f78b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/types/index.d.ts @@ -0,0 +1,61 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the variance 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 variance +* +* @example +* var y = variance( 2.0, 1.0 ); +* // returns 8.0 +* +* @example +* var y = variance( 4.0, 2.0 ); +* // returns 32.0 +* +* @example +* var y = variance( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = variance( 1.0, NaN ); +* // returns NaN +* +* @example +* var y = variance( 0.0, 1.0 ); +* // returns NaN +* +* @example +* var y = variance( 1.0, 0.0 ); +* // returns NaN +*/ +declare function variance( mu: number, lambda: number ): number; + + +// EXPORTS // + +export = variance; diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/types/test.ts new file mode 100644 index 000000000000..ff18c30d0198 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/types/test.ts @@ -0,0 +1,56 @@ +/* +* @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 variance = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + variance( 2, 1 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than two numbers... +{ + variance( true, 3 ); // $ExpectError + variance( false, 2 ); // $ExpectError + variance( '5', 1 ); // $ExpectError + variance( [], 1 ); // $ExpectError + variance( {}, 2 ); // $ExpectError + variance( ( x: number ): number => x, 2 ); // $ExpectError + + variance( 9, true ); // $ExpectError + variance( 9, false ); // $ExpectError + variance( 5, '5' ); // $ExpectError + variance( 8, [] ); // $ExpectError + variance( 9, {} ); // $ExpectError + variance( 8, ( x: number ): number => x ); // $ExpectError + + variance( [], true ); // $ExpectError + variance( {}, false ); // $ExpectError + variance( false, '5' ); // $ExpectError + variance( {}, [] ); // $ExpectError + variance( '5', ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + variance(); // $ExpectError + variance( 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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/variance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/example.c new file mode 100644 index 000000000000..301cb071a5a1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/example.c @@ -0,0 +1,40 @@ +/** +* @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/variance.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 < 25; i++ ) { + mu = random_uniform( 0.1, 10.0 ); + lambda = random_uniform( 0.1, 20.0 ); + y = stdlib_base_dists_wald_variance( mu, lambda ); + printf( "µ: %lf, λ: %lf, Var(X;µ,λ): %lf\n", mu, lambda, y ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/index.js new file mode 100644 index 000000000000..f0a5164862df --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/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 variance = 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, Var(X;µ,λ): %0.4f', mu, lambda, variance ); From b4dd3f29d3b0c2f4be0e9cde05330dfd4e6e1437 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Mon, 19 Jan 2026 04:25:10 +0530 Subject: [PATCH 08/10] copyright year fixed --- .../@stdlib/stats/base/dists/wald/variance/benchmark/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/Makefile index a4bd7b38fd74..979768abbcec 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/Makefile @@ -1,7 +1,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. From 9987a19788956a147e5d1f8f64761f9726b074f3 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Thu, 22 Jan 2026 23:44:31 +0530 Subject: [PATCH 09/10] all requested changes resolved --- .../base/dists/normal/variance/benchmark/c/Makefile | 2 +- .../@stdlib/stats/base/dists/wald/variance/README.md | 10 +++------- .../base/dists/wald/variance/benchmark/benchmark.js | 10 ++++------ .../dists/wald/variance/benchmark/benchmark.native.js | 10 ++++------ .../base/dists/wald/variance/benchmark/c/benchmark.c | 9 +++++---- .../stats/base/dists/wald/variance/docs/repl.txt | 2 +- .../base/dists/wald/variance/examples/c/example.c | 5 +++-- .../@stdlib/stats/base/dists/wald/variance/lib/main.js | 2 +- .../stats/base/dists/wald/variance/manifest.json | 6 ++++-- 9 files changed, 26 insertions(+), 30 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/normal/variance/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/normal/variance/benchmark/c/Makefile index 979768abbcec..a4bd7b38fd74 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/normal/variance/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/normal/variance/benchmark/c/Makefile @@ -1,7 +1,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. diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md index 3b16c04e391c..f9c2e7be5eff 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/README.md @@ -34,11 +34,6 @@ The [variance][variance] for a [Wald][wald-distribution] random variable with me \operatorname{Var}\left[ X \right] = \frac{\mu^{3}}{\lambda} ``` - - @@ -196,6 +191,7 @@ double stdlib_base_dists_wald_variance( const double mu, const double lambda ); ```c #include "stdlib/stats/base/dists/wald/variance.h" +#include "stdlib/constants/float64/eps.h" #include #include @@ -211,8 +207,8 @@ int main( void ) { int i; for ( i = 0; i < 10; i++ ) { - mu = random_uniform( 0.1, 5.0 ); - lambda = random_uniform( 0.1, 20.0 ); + mu = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 5.0 ); + lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 ); y = stdlib_base_dists_wald_variance( mu, lambda ); printf( "µ: %.4f, λ: %.4f, Var(X;µ,λ): %.4f\n", mu, lambda, y ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js index f7bf6b2f0429..4f4dc1224eb3 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js @@ -37,15 +37,13 @@ bench( pkg, function benchmark( b ) { var y; var i; - opts = { - 'dtype': 'float64' - }; - mu = uniform( 100, EPS, 100.0, opts ); - lambda = uniform( 100, EPS, 20.0, opts ); + len = 100; + mu = uniform( len, EPS, 100.0 ); + lambda = uniform( len, EPS, 20.0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = variance( mu[ i % 100 ], lambda[ i % 100 ] ); + y = variance( mu[ i%len ], lambda[ i%len ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js index 7dcb97cba1e4..366475d6f7c6 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js @@ -47,15 +47,13 @@ bench( format( '%s::native', pkg ), opts, function benchmark( b ) { var y; var i; - arrayOpts = { - 'dtype': 'float64' - }; - mu = uniform( 100, EPS, 100.0, arrayOpts ); - lambda = uniform( 100, EPS, 20.0, arrayOpts ); + len = 100; + mu = uniform( len, EPS, 100.0 ); + lambda = uniform( len, EPS, 20.0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = variance( mu[ i % 100 ], lambda[ i % 100 ] ); + y = variance( mu[ i%len ], lambda[ i%len ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/benchmark.c index 14b56e7ffb2d..cc1a50d05fa7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/c/benchmark.c @@ -17,6 +17,7 @@ */ #include "stdlib/stats/base/dists/wald/variance.h" +#include "stdlib/constants/float64/eps.h" #include #include #include @@ -92,21 +93,21 @@ static double random_uniform( const double min, const double max ) { * @return elapsed time in seconds */ static double benchmark( void ) { - double elapsed; double lambda[ 100 ]; double mu[ 100 ]; + double elapsed; double y; double t; int i; for ( i = 0; i < 100; i++ ) { - mu[ i ] = random_uniform( 0.1, 50.0 ); - lambda[ i ] = random_uniform( 1.0, 20.0 ); + mu[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 100.0 ); + lambda[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 ); } t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_dists_wald_variance( mu[ i % 100 ], lambda[ i % 100 ] ); + y = stdlib_base_dists_wald_variance( mu[ i%100 ], lambda[ i%100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/repl.txt index 68967b5bae6a..8803d535f4d9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/repl.txt @@ -10,7 +10,7 @@ Parameters ---------- μ: number - Location parameter. + Mean. λ: number Shape parameter. diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/example.c index 301cb071a5a1..37c548066992 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/examples/c/example.c @@ -17,6 +17,7 @@ */ #include "stdlib/stats/base/dists/wald/variance.h" +#include "stdlib/constants/float64/eps.h" #include #include @@ -32,8 +33,8 @@ int main( void ) { int i; for ( i = 0; i < 25; i++ ) { - mu = random_uniform( 0.1, 10.0 ); - lambda = random_uniform( 0.1, 20.0 ); + mu = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); + lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 ); y = stdlib_base_dists_wald_variance( mu, lambda ); printf( "µ: %lf, λ: %lf, Var(X;µ,λ): %lf\n", mu, lambda, y ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/main.js index 073d6ab1e17d..5dcf9532772f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/lib/main.js @@ -61,7 +61,7 @@ function variance( mu, lambda ) { ) { return NaN; } - return (mu*mu*mu) / lambda; + return (mu * mu * mu) / lambda; } diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/manifest.json b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/manifest.json index db80b71a4aa4..86be782a5d98 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/manifest.json @@ -54,7 +54,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-nan" + "@stdlib/math/base/assert/is-nan", + "@stdlib/constants/float64/eps" ] }, { @@ -69,7 +70,8 @@ "libraries": [], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-nan" + "@stdlib/math/base/assert/is-nan", + "@stdlib/constants/float64/eps" ] } ] From f1ff737c15b2b6d80e3a9b796631534e70b46690 Mon Sep 17 00:00:00 2001 From: manit2004 Date: Thu, 22 Jan 2026 23:53:31 +0530 Subject: [PATCH 10/10] unused var removed and decalred len --- .../stats/base/dists/wald/variance/benchmark/benchmark.js | 2 +- .../base/dists/wald/variance/benchmark/benchmark.native.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js index 4f4dc1224eb3..860471c9da07 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.js @@ -32,7 +32,7 @@ var variance = require( './../lib' ); bench( pkg, function benchmark( b ) { var lambda; - var opts; + var len; var mu; var y; var i; diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js index 366475d6f7c6..9a7aea56b5d1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/variance/benchmark/benchmark.native.js @@ -41,8 +41,8 @@ var opts = { // MAIN // bench( format( '%s::native', pkg ), opts, function benchmark( b ) { - var arrayOpts; var lambda; + var len; var mu; var y; var i;