diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/README.md b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/README.md new file mode 100644 index 000000000000..390d9d2bf89e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/README.md @@ -0,0 +1,254 @@ + + +# Kurtosis + +> [Wald][wald-distribution] distribution [excess kurtosis][kurtosis]. + + + +
+ +The [excess kurtosis][kurtosis] for a [Wald][wald-distribution] random variable with mean `μ` and shape parameter `λ > 0` is + + + +```math +\mathop{\mathrm{Kurt}}\left( X \right) = \frac{15\mu}{\lambda} +``` + + + + + +
+ + + + + +
+ +## Usage + +```javascript +var kurtosis = require( '@stdlib/stats/base/dists/wald/kurtosis' ); +``` + +#### kurtosis( mu, lambda ) + +Returns the [excess kurtosis][kurtosis] for a [Wald][wald-distribution] distribution with parameters `mu` (mean) and `lambda` (shape parameter). + +```javascript +var y = kurtosis( 2.0, 1.0 ); +// returns 30.0 + +y = kurtosis( 0.0, 1.0 ); +// returns NaN + +y = kurtosis( -1.0, 4.0 ); +// returns NaN +``` + +If provided `NaN` as any argument, the function returns `NaN`. + +```javascript +var y = kurtosis( NaN, 1.0 ); +// returns NaN + +y = kurtosis( 0.0, NaN ); +// returns NaN +``` + +If provided `mu <= 0` or `lambda <= 0`, the function returns `NaN`. + +```javascript +var y = kurtosis( 0.0, 0.0 ); +// returns NaN + +y = kurtosis( 0.0, -1.0 ); +// returns NaN + +y = kurtosis( -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 kurtosis = require( '@stdlib/stats/base/dists/wald/kurtosis' ); + +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, Kurtosis(X;µ,λ): %0.4f', mu, lambda, kurtosis ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/wald/kurtosis.h" +``` + +#### stdlib_base_dists_wald_kurtosis( mu, lambda ) + +Returns the [excess kurtosis][kurtosis] for a [Wald][wald-distribution] distribution with mean `mu` and shape parameter `lambda`. + +```c +double out = stdlib_base_dists_wald_kurtosis( 2.0, 1.0 ); +// returns 30.0 +``` + +The function accepts the following arguments: + +- **mu**: `[in] double` mean. +- **lambda**: `[in] double` shape parameter. + +```c +double stdlib_base_dists_wald_kurtosis( const double mu, const double lambda ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/wald/kurtosis.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_kurtosis( mu, lambda ); + printf( "µ: %.4f, λ: %.4f, Kurtosis(X;µ,λ): %.4f\n", mu, lambda, y ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/benchmark/benchmark.js new file mode 100644 index 000000000000..58f3d82b77bb --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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 kurtosis = 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 = kurtosis( mu[ i % mu.length ], lambda[ i % lambda.length ] ); + 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/kurtosis/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/benchmark/benchmark.native.js new file mode 100644 index 000000000000..c8d4383d125e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/benchmark/benchmark.native.js @@ -0,0 +1,69 @@ +/** +* @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 kurtosis = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( kurtosis 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 = kurtosis( mu[ i % mu.length ], lambda[ i % lambda.length ] ); + 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/kurtosis/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/benchmark/c/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/benchmark/c/benchmark.c new file mode 100644 index 000000000000..09c3acf920a8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis.h" +#include +#include +#include +#include +#include + +#define NAME "wald-kurtosis" +#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_kurtosis( 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 ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/binding.gyp new file mode 100644 index 000000000000..f343843f5bd2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/docs/repl.txt new file mode 100644 index 000000000000..31c66237e289 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/docs/repl.txt @@ -0,0 +1,40 @@ + +{{alias}}( μ, λ ) + Returns the excess kurtosis 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 + Mean parameter. + + λ: number + Shape parameter. + + Returns + ------- + out: number + Excess kurtosis. + + Examples + -------- + > var y = {{alias}}( 4.0, 2.0 ) + 30.0 + > y = {{alias}}( 0.0, 1.0 ) + NaN + > 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/kurtosis/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/docs/types/index.d.ts new file mode 100644 index 000000000000..e28eb9da5f6b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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 excess kurtosis 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 excess kurtosis +* +* @example +* var y = kurtosis( 5.0, 2.0 ); +* // returns 37.5 +* +* @example +* var y = kurtosis( 0.0, 1.0 ); +* // returns NaN +* +* @example +* var y = kurtosis( 1.0, 0.0 ); +* // returns NaN +* +* @example +* var y = kurtosis( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = kurtosis( 0.0, NaN ); +* // returns NaN +* +* @example +* var y = kurtosis( 0.0, 0.0 ); +* // returns NaN +*/ +declare function kurtosis( mu: number, lambda: number ): number; + + +// EXPORTS // + +export = kurtosis; diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/docs/types/test.ts new file mode 100644 index 000000000000..9dd93e5d142a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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 kurtosis = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + kurtosis( 5, 2 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than two numbers... +{ + kurtosis( true, 3 ); // $ExpectError + kurtosis( false, 2 ); // $ExpectError + kurtosis( '5', 1 ); // $ExpectError + kurtosis( [], 1 ); // $ExpectError + kurtosis( {}, 2 ); // $ExpectError + kurtosis( ( x: number ): number => x, 2 ); // $ExpectError + + kurtosis( 9, true ); // $ExpectError + kurtosis( 9, false ); // $ExpectError + kurtosis( 5, '5' ); // $ExpectError + kurtosis( 8, [] ); // $ExpectError + kurtosis( 9, {} ); // $ExpectError + kurtosis( 8, ( x: number ): number => x ); // $ExpectError + + kurtosis( [], true ); // $ExpectError + kurtosis( {}, false ); // $ExpectError + kurtosis( false, '5' ); // $ExpectError + kurtosis( {}, [] ); // $ExpectError + kurtosis( '5', ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + kurtosis(); // $ExpectError + kurtosis( 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/examples/c/example.c new file mode 100644 index 000000000000..8274e65f08c4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis.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, 10.0 ); + lambda = random_uniform( 0.1, 20.0 ); + y = stdlib_base_dists_wald_kurtosis( mu, lambda ); + printf( "µ: %.4f, λ: %.4f, Kurtosis(X;µ,λ): %.4f\n", mu, lambda, y ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/examples/index.js new file mode 100644 index 000000000000..190d738d1cfa --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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 kurtosis = 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, Kurtosis(X;µ,λ): %0.4f', mu, lambda, kurtosis ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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", + "kurtosis", + "excess kurtosis", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/src/addon.c new file mode 100644 index 000000000000..6c18c485ad88 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis.h" +#include "stdlib/math/base/napi/binary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_wald_kurtosis ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/src/main.c new file mode 100644 index 000000000000..179f1c5f1daa --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis.h" +#include "stdlib/math/base/assert/is_nan.h" + +/** +* Returns the excess kurtosis of a Wald distribution with mean `mu` and shape parameter `lambda`. +* +* @param mu mean +* @param lambda shape parameter +* @return excess kurtosis +* +* @example +* double y = stdlib_base_dists_wald_kurtosis( 2.0, 1.0 ); +* // returns 30.0 +*/ +double stdlib_base_dists_wald_kurtosis( const double mu, const double lambda ) { + if ( + stdlib_base_is_nan( mu ) || + stdlib_base_is_nan( lambda ) || + mu <= 0.0 || + lambda <= 0.0 + ) { + return 0.0/0.0; // NaN + } + return 15.0 * mu / lambda; +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/test/fixtures/julia/REQUIRE new file mode 100644 index 000000000000..98be20b58ed3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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/kurtosis/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/test/fixtures/julia/data.json new file mode 100644 index 000000000000..5c72db38a5b5 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/test/fixtures/julia/data.json @@ -0,0 +1 @@ +{"expected":[21.713965249702962,26.40780234000845,183.61182568211646,54.78313658380484,26.16441633794986,94.40532944501133,23.44618955146833,19.061797175411993,63.13285295107122,20.210535424172132,30.38641973186934,14.903446168276911,15.142858044458658,19.548850094962127,11.045365146840403,33.57549253388869,40.532171583016975,55.55743370910954,9.490619966437402,18.45607627995488,88.11789158768566,3.3870648506276053,36.3749356249228,12.451207945648408,18.542132716408922,77.72767569136282,16.13621746229233,31.03714228276024,38.83566402723719,99.27869775835447,13.68485063732703,15.815817562750562,14.6324611126601,25.703507645183244,36.70245284004088,35.00419051508744,42.12475171076584,21.969106136005887,5.122534346241508,96.81160637981337,19.072649556939254,72.15961828919862,42.45216201752851,152.0281178719037,42.66947969925179,18.058804622041418,28.241912420575694,57.31232875458171,48.55678182274236,13.684092388432859,46.83444834487093,52.16817577334687,24.461116887394535,27.266300130020603,41.98580800678281,49.14682488293742,15.06034207358659,3.571464442111775,12.535132968471103,12.698910105909729,17.051962277032764,17.463980454637273,26.361940328979312,49.68206448232837,110.04432843403997,25.717683294863388,100.82113200742316,28.573788357134607,10.225153010331182,56.49627153256127,77.90710988847756,26.23675480021863,39.73356350041856,22.2320120021314,38.52342417677097,19.270307015932122,11.070086298573775,6.281202165189575,75.12305809995571,13.659014669066933,56.916107761281125,137.42451904859197,36.43105049846161,34.681426136553945,11.597753937602077,10.578478900558409,57.93824181949993,31.30055828833333,13.147930631033173,40.37039810160703,5.785912863323165,24.48180843262954,38.529625319660795,73.21401088801811,43.597829511395304,138.57928523226656,8.63574232607563,21.379374770931165,20.40749144355704,12.518872993690938],"lambda":[4.154458383871866,5.209121645281801,0.5175869637752779,1.6675228733950966,4.649774060673657,0.8809090436132095,3.815662129247019,4.020457115350167,0.8366273216784205,2.920058169668083,4.0108939355321205,5.090754338527049,5.026916489849918,3.9244682698754403,4.87614147865132,3.2734148956962446,3.161600584541958,1.4308990128884105,4.401822813875512,3.069678594246356,0.9796374310298163,5.322708028079062,0.9126888557799346,4.610810013495774,2.3519505280238673,1.2421147120228584,3.290107155188441,3.14948547166171,2.0276951508367427,0.9159818304047175,3.8790247202862824,4.301689601254237,3.5994054225706646,3.584709998798521,3.6785537755872566,3.971143951478754,2.106038966840816,4.322794892047339,4.5317992028229845,0.7821963842948366,1.9268501614701274,1.1711401734905693,2.938593364579122,0.680256983960943,2.9475761857940093,3.420545863628659,5.288192170102284,0.6242276228308609,2.375211773585516,3.9601536142078757,0.9211719820932991,0.8402189530701194,4.710037796927744,4.8969332199011575,2.2074096074240823,1.6266675545995204,3.439018283103728,3.9489516410996837,3.6053950107955313,5.432598100530456,4.7279875612375335,4.293868874127982,5.393950287232151,2.5590274212265665,0.538435793788193,2.5693032320173876,0.9867192085505734,4.5371641490313,2.819472659536148,1.8567927605542285,1.3653363152018267,1.365293999809228,3.005549619984395,0.9328598552896701,3.6789732458515703,2.2349004204895193,3.088851388421756,3.7732999606708373,0.8669447869144421,4.053236264731206,2.092201982470546,0.923529932920711,3.16011797599274,3.9884872300051786,3.012097191104013,3.019753878943258,2.0971885669019983,1.9097989672232147,4.791712482037251,2.013768264122504,3.811777168153634,1.2713656693122761,3.3983161078647295,2.0278241888776223,1.9356015212749846,0.7737338956671853,4.140097534324784,3.1615431269752383,5.0352937462001695,4.363058399626363],"mu":[6.013984331915389,9.170763651577428,6.335672491202817,6.090142221988152,8.110574960057686,5.54416723155966,5.9641825031123235,5.1091425390164575,3.521244644958152,3.934395938581336,8.125113775005886,5.057985549344,5.074792187143047,5.114589460682024,3.590584209290541,7.32710115938462,8.543102491308094,5.29980513686521,2.78506849907244,3.77694815269036,5.754905662848283,1.2018904848039975,2.213266558305305,3.827343618394255,2.9073452555364394,6.436445967172218,3.5393256353576437,6.516735246763382,5.249792508503586,6.06249888619295,3.5389249277078023,4.535649196334548,3.511210658297543,6.14264139065884,9.00079643120304,9.267111962693296,5.91442457142448,6.33119598583814,1.5476198044487084,5.048379231204331,2.45000919189677,5.633935192148355,8.316642774449807,6.8945459293866636,8.384769481449034,4.118064630133459,9.956577342080188,2.385062582491556,7.68884265818672,3.612740528613791,2.8761721074727324,2.9221793354572982,7.6808523396463855,8.901416726032878,6.178658397975688,5.329703029910578,3.4528527827240394,0.940236024653764,3.0129403909456194,4.599204994678147,5.374764369366837,4.999202806169762,9.47966637396632,8.47585102356165,3.950120355484728,4.405101787299472,6.632143171969164,8.642931209066607,1.921969290146834,6.993457865331048,7.091293756210517,2.388058926880297,7.961413111953923,1.382623433273767,9.44844312566213,2.8711478168579223,2.2795900955532176,1.5800573255250268,4.341836239788491,3.6908809064771737,7.938666232843973,8.461043790573807,7.675094504299187,9.22176168426755,2.3289041372377812,2.129626846218711,8.100494555350565,3.985184926171269,4.200073554512104,5.4197751004671755,1.4703073699561104,2.075022050928332,8.7290564235864,9.89767614956485,5.625868341769611,7.14823268143571,2.3835210340833264,4.506121024404349,6.850514269425082,3.6413715979319248]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/test/fixtures/julia/runner.jl new file mode 100644 index 000000000000..fab1cf62510b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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: kurtosis, 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 ] = kurtosis( 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/kurtosis/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/test/test.js new file mode 100644 index 000000000000..cde816fef298 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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 kurtosis = 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 kurtosis, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) { + var y = kurtosis( NaN, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = kurtosis( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = kurtosis( 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 = kurtosis( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( 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 = kurtosis( 0.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( -1.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, PINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the excess kurtosis 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 = kurtosis( 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], 1000 ), '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/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/test/test.native.js new file mode 100644 index 000000000000..f6d55a9392dc --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/wald/kurtosis/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 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 kurtosis = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( kurtosis instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof kurtosis, '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 = kurtosis( NaN, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = kurtosis( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = kurtosis( 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 = kurtosis( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( 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 = kurtosis( 0.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( -1.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, PINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the excess kurtosis 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 = kurtosis( 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], 1000 ), 'within tolerance. mu: '+mu[i]+'. lambda: '+lambda[i]+'. y: '+y+'. E: '+expected[ i ]+'.' ); + } + } + t.end(); +});