From 28b4ca6a11a5770213c78a04857c16968798d880 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Thu, 15 Jan 2026 23:59:16 +0530 Subject: [PATCH 1/4] feat: add implementation of halfnormal-kurtosis --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../base/dists/halfnormal/kurtosis/README.md | 215 ++++++++++++++++++ .../kurtosis/benchmark/benchmark.js | 53 +++++ .../halfnormal/kurtosis/benchmark/c/Makefile | 146 ++++++++++++ .../kurtosis/benchmark/c/benchmark.c | 138 +++++++++++ .../dists/halfnormal/kurtosis/binding.gyp | 170 ++++++++++++++ .../dists/halfnormal/kurtosis/docs/repl.txt | 34 +++ .../halfnormal/kurtosis/docs/types/index.d.ts | 52 +++++ .../halfnormal/kurtosis/docs/types/test.ts | 42 ++++ .../halfnormal/kurtosis/examples/c/Makefile | 146 ++++++++++++ .../halfnormal/kurtosis/examples/c/example.c | 38 ++++ .../halfnormal/kurtosis/examples/index.js | 32 +++ .../dists/halfnormal/kurtosis/include.gypi | 53 +++++ .../stats/base/dists/halfnormal/kurtosis.h | 38 ++++ .../dists/halfnormal/kurtosis/lib/index.js | 46 ++++ .../dists/halfnormal/kurtosis/lib/main.js | 45 ++++ .../dists/halfnormal/kurtosis/lib/native.js | 62 +++++ .../dists/halfnormal/kurtosis/manifest.json | 79 +++++++ .../dists/halfnormal/kurtosis/package.json | 65 ++++++ .../dists/halfnormal/kurtosis/src/Makefile | 70 ++++++ .../dists/halfnormal/kurtosis/src/addon.c | 22 ++ .../base/dists/halfnormal/kurtosis/src/main.c | 41 ++++ .../kurtosis/test/fixtures/julia/REQUIRE | 3 + .../kurtosis/test/fixtures/julia/data.json | 1 + .../kurtosis/test/fixtures/julia/runner.jl | 65 ++++++ .../dists/halfnormal/kurtosis/test/test.js | 80 +++++++ .../halfnormal/kurtosis/test/test.native.js | 97 ++++++++ 26 files changed, 1833 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/include/stdlib/stats/base/dists/halfnormal/kurtosis.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/data.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/runner.jl create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md new file mode 100644 index 000000000000..ea66124a412e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md @@ -0,0 +1,215 @@ + + +# Kurtosis + +> [Half-normal][halfnormal-distribution] distribution [excess kurtosis][kurtosis]. + +
+ +The [excess kurtosis][kurtosis] of a [half-normal][halfnormal-distribution] distribution with scale `sigma > 0` is + + + +```math +\gamma_2 = \frac{8(\pi-3)}{(\pi-2)^2} +``` + + + + + +
+ + + +
+ +## Usage + +```javascript +var kurtosis = require( '@stdlib/stats/base/dists/halfnormal/kurtosis' ); +``` + +#### kurtosis( sigma ) + +Returns the [excess kurtosis][kurtosis] of a [half-normal][halfnormal-distribution] distribution with scale parameter `sigma`. + +```javascript +var x = kurtosis( 1.0 ); +// returns ~0.869 + +var y = kurtosis( 4.0 ); +// returns ~0.869 +``` + +If provided `sigma <= 0`, the function returns `NaN`. + +```javascript +var x = kurtosis( 0.0 ); +// returns NaN + +var y = kurtosis( -1.0 ); +// returns NaN +``` + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var kurtosis = require( '@stdlib/stats/base/dists/halfnormal/kurtosis' ); + +var sigma; +var y; +var i; + +for ( i = 0; i < 10; i++ ) { + sigma = randu() * 20.0; + y = kurtosis( sigma ); + console.log( 'σ: %lf, Kurt(σ): %lf', sigma, y ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/halfnormal/kurtosis.h" +``` + +#### stdlib_base_dists_halfnormal_kurtosis( sigma ) + +Returns the [excess kurtosis][kurtosis] of a [half-normal][halfnormal-distribution] distribution with scale parameter `sigma`. + +```c +double out = stdlib_base_dists_halfnormal_kurtosis( 1.0 ); +// returns ~0.869 +``` + +The function accepts the following arguments: + +- **sigma**: `[in] double` scale parameter. + +```c +double stdlib_base_dists_halfnormal_kurtosis( const double sigma ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/halfnormal/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 sigma; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + sigma = random_uniform( 0.0, 20.0 ); + y = stdlib_base_dists_halfnormal_kurtosis( sigma ); + printf( "σ: %lf, Kurt(σ): %lf\n", sigma, y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.js new file mode 100644 index 000000000000..05660b9587cf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var kurtosis = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var sigma; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // Generate valid scale parameters: + sigma = ( randu() * 10.0 ) + 0.1; + y = kurtosis( sigma ); + 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/halfnormal/kurtosis/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/c/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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/halfnormal/kurtosis/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/c/benchmark.c new file mode 100644 index 000000000000..bcf0e12c445c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/c/benchmark.c @@ -0,0 +1,138 @@ +/** +* @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/halfnormal/kurtosis.h" +#include +#include +#include +#include +#include + +#define NAME "halfnormal-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 benchmark 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 sigma[ 100 ]; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + sigma[ i ] = random_uniform( 0.1, 10.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_halfnormal_kurtosis( sigma[ 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/halfnormal/kurtosis/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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 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/halfnormal/kurtosis/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/repl.txt new file mode 100644 index 000000000000..2e034e590a32 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/repl.txt @@ -0,0 +1,34 @@ + +{{alias}}( sigma ) + Returns the excess kurtosis of a half-normal distribution with + scale parameter `sigma`. + + If provided `NaN` as any argument, the function returns `NaN`. + + If provided `sigma <= 0`, the function returns `NaN`. + + Parameters + ---------- + + sigma: number + Scale parameter. + + Returns + ------- + out: number + Excess kurtosis. + + Examples + -------- + > var y = {{alias}}( 1.0 ) + ~0.869 + > y = {{alias}}( 4.0 ) + ~0.869 + > y = {{alias}}( NaN ) + NaN + > y = {{alias}}( 0.0 ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/types/index.d.ts new file mode 100644 index 000000000000..b18a37375603 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/types/index.d.ts @@ -0,0 +1,52 @@ +/* +* @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 half-normal distribution with scale parameter `sigma`. +* +* ## Notes +* +* - If provided `sigma <= 0`, the function returns `NaN`. +* +* @param sigma - scale parameter +* @returns excess kurtosis +* +* @example +* var y = kurtosis( 1.0 ); +* // returns ~0.869 +* +* @example +* var y = kurtosis( 3.0 ); +* // returns ~0.869 +* +* @example +* var y = kurtosis( NaN ); +* // returns NaN +* +* @example +* var y = kurtosis( 0.0 ); +* // returns NaN +*/ +declare function kurtosis( sigma: number ): number; + + +// EXPORTS // + +export = kurtosis; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/types/test.ts new file mode 100644 index 000000000000..a4e0a39d0b6e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/docs/types/test.ts @@ -0,0 +1,42 @@ +/* +* @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( 2 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + kurtosis( true ); // $ExpectError + kurtosis( false ); // $ExpectError + kurtosis( '5' ); // $ExpectError + kurtosis( [] ); // $ExpectError + kurtosis( {} ); // $ExpectError + kurtosis( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + kurtosis(); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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/halfnormal/kurtosis/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/c/example.c new file mode 100644 index 000000000000..8dc00dcc8eaf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/c/example.c @@ -0,0 +1,38 @@ +/** +* @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/halfnormal/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 sigma; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + sigma = random_uniform( 0.1, 20.0 ); + y = stdlib_base_dists_halfnormal_kurtosis( sigma ); + printf( "σ: %lf, Kurt(σ): %lf\n", sigma, y ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js new file mode 100644 index 000000000000..3716c8d37f13 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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 randu = require( '@stdlib/random/base/randu' ); +var kurtosis = require( './../lib' ); + +var sigma; +var y; +var i; + +for ( i = 0; i < 10; i++ ) { + sigma = randu() * 20.0; + y = kurtosis( sigma ); + console.log( 'σ: %lf, Kurt(σ): %lf', sigma, y ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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", + "halfnormal", + "half-normal", + "univariate", + "continuous", + "kurtosis", + "excess kurtosis" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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/halfnormal/kurtosis/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/addon.c new file mode 100644 index 000000000000..020e4b783a07 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/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/halfnormal/kurtosis.h" +#include "stdlib/math/base/napi/unary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_dists_halfnormal_kurtosis ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/main.c new file mode 100644 index 000000000000..5fdaa204025a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/main.c @@ -0,0 +1,41 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dists/halfnormal/kurtosis.h" +#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/constants/float64/pi.h" + +/** +* Returns the excess kurtosis of a half-normal distribution with scale parameter `sigma`. +* +* @param sigma scale parameter +* @return excess kurtosis +* +* @example +* double y = stdlib_base_dists_halfnormal_kurtosis( 1.0 ); +* // returns ~0.869 +*/ +double stdlib_base_dists_halfnormal_kurtosis( const double sigma ) { + if ( + stdlib_base_is_nan( sigma ) || + sigma <= 0.0 + ) { + return 0.0 / 0.0; // NaN + } + return ( 8.0 * ( STDLIB_CONSTANT_FLOAT64_PI - 3.0 ) ) / ( ( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) *( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/REQUIRE new file mode 100644 index 000000000000..5a016dc17c07 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/REQUIRE @@ -0,0 +1,3 @@ +Distributions 0.25.123 +julia 1.10.5 +JSON 0.21 diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/data.json new file mode 100644 index 000000000000..62e17bd85a0a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/data.json @@ -0,0 +1 @@ +{"sigma":[2.36319709601774,3.3942462504419573,1.0391557294439813,4.940036749651035,1.9027125856845173,4.955358727145291,2.5397051685159946,2.4959815384296364,3.1105639003879846,2.139250174497646],"expected":[0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/runner.jl new file mode 100644 index 000000000000..daf566bfb1e4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/runner.jl @@ -0,0 +1,65 @@ +#!/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 JSON + +""" + halfnormal_excess_kurtosis() + +Returns the excess kurtosis of a half-normal distribution. +""" +function halfnormal_excess_kurtosis() + return 8 * (pi - 3) / (pi - 2)^2 +end + +""" + gen( sigma, name ) + +Generate fixture data and write to file. + +# Arguments + +* `sigma`: standard deviation +* `name::AbstractString`: output filename +""" +function gen( sigma, name ) + κ = halfnormal_excess_kurtosis() + z = fill( κ, length(sigma) ) + + data = Dict( + "sigma" => sigma, + "expected" => z + ) + + filepath = joinpath( dir, name ) + + open(filepath, "w") do outfile + write(outfile, JSON.json(data)) + write(outfile, "\n") + end +end + +# Get the filename: +file = @__FILE__ + +# Extract the directory in which this file resides: +dir = dirname(file) + +# Generate fixtures: +sigma = rand(10) .* 5.0 +gen(sigma, "data.json") diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js new file mode 100644 index 000000000000..a9b03e4f00ea --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js @@ -0,0 +1,80 @@ +/** +* @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 EPS = require( '@stdlib/constants/float64/eps' ); +var abs = require( '@stdlib/math/base/special/abs' ); +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 `sigma <= 0`, the function returns `NaN`', function test( t ) { + var y; + + y = kurtosis( 0.0 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = kurtosis( -1.0 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = kurtosis( NINF ); + t.equal( isnan( y ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns the excess kurtosis', function test( t ) { + var expected; + var sigma; + var delta; + var tol; + var y; + var i; + + expected = data.expected; + sigma = data.sigma; + for ( i = 0; i < sigma.length; i++ ) { + y = kurtosis( sigma[i] ); + if ( y === expected[i] ) { + t.equal( y, expected[i], 'sigma: '+sigma[i]+'. E: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 1.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. sigma: '+sigma[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js new file mode 100644 index 000000000000..d2473e26d02f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js @@ -0,0 +1,97 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); + + +// 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`, the function returns `NaN`', opts, function test( t ) { + var y = kurtosis( NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a nonpositive `sigma`, the function returns `NaN`', opts, function test( t ) { + var y; + + y = kurtosis( 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = kurtosis( NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the excess kurtosis of a half-normal distribution', opts, function test( t ) { + var expected; + var delta; + var sigma; + var tol; + var y; + var i; + + expected = data.expected; + sigma = data.sigma; + for ( i = 0; i < sigma.length; i++ ) { + y = kurtosis( sigma[i] ); + if ( expected[i] !== null) { + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 1.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. sigma: '+sigma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + } + } + t.end(); +}); From 7cf805c1abcaebd5ecef7fdefb15c0229dbafcf3 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Fri, 16 Jan 2026 15:31:46 +0530 Subject: [PATCH 2/4] fix: addressing comments --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/dists/halfnormal/kurtosis/README.md | 2 +- .../kurtosis/benchmark/benchmark.js | 16 +++-- .../kurtosis/benchmark/benchmark.native.js | 68 +++++++++++++++++++ .../halfnormal/kurtosis/examples/index.js | 2 +- .../dists/halfnormal/kurtosis/lib/main.js | 2 +- .../dists/halfnormal/kurtosis/package.json | 3 + .../base/dists/halfnormal/kurtosis/src/main.c | 2 +- .../halfnormal/kurtosis/test/test.native.js | 2 +- 8 files changed, 87 insertions(+), 10 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md index ea66124a412e..88ea26120a3d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md @@ -94,7 +94,7 @@ var i; for ( i = 0; i < 10; i++ ) { sigma = randu() * 20.0; y = kurtosis( sigma ); - console.log( 'σ: %lf, Kurt(σ): %lf', sigma, y ); + console.log( 'σ: %d, Kurt(σ): %d', sigma, y ); } ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.js index 05660b9587cf..107b148cf9bc 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.js @@ -21,8 +21,10 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/base/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' ); @@ -31,20 +33,24 @@ var kurtosis = require( './../lib' ); bench( pkg, function benchmark( b ) { var sigma; + var len; var y; var i; + len = 100; + sigma = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + sigma[ i ] = uniform( EPS, 10.0 ); + } + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - // Generate valid scale parameters: - sigma = ( randu() * 10.0 ) + 0.1; - y = kurtosis( sigma ); + y = kurtosis( sigma[ i % len ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.native.js new file mode 100644 index 000000000000..a21f882b0380 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/benchmark/benchmark.native.js @@ -0,0 +1,68 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var kurtosis = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( kurtosis instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var sigma; + var len; + var y; + var i; + + len = 100; + sigma = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + sigma[ i ] = uniform( EPS, 10.0 ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = kurtosis( sigma[ i % len ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js index 3716c8d37f13..88bc13312d60 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js @@ -28,5 +28,5 @@ var i; for ( i = 0; i < 10; i++ ) { sigma = randu() * 20.0; y = kurtosis( sigma ); - console.log( 'σ: %lf, Kurt(σ): %lf', sigma, y ); + console.log( 'σ: %d, Kurt(σ): %d', sigma, y ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js index 823a5d3e7ece..4c29394aaf81 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/lib/main.js @@ -18,7 +18,7 @@ 'use strict'; -// VARIABLES // +// MODULES // var PI = require( '@stdlib/constants/float64/pi' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json index 2f3ddb88ae34..b7e625de729d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/package.json @@ -14,11 +14,14 @@ } ], "main": "./lib", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/main.c index 5fdaa204025a..49051811ce07 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/src/main.c @@ -37,5 +37,5 @@ double stdlib_base_dists_halfnormal_kurtosis( const double sigma ) { ) { return 0.0 / 0.0; // NaN } - return ( 8.0 * ( STDLIB_CONSTANT_FLOAT64_PI - 3.0 ) ) / ( ( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) *( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) ); + return ( 8.0 * ( STDLIB_CONSTANT_FLOAT64_PI - 3.0 ) ) / ( ( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) * ( STDLIB_CONSTANT_FLOAT64_PI - 2.0 ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js index d2473e26d02f..d753e603cd98 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js @@ -83,7 +83,7 @@ tape( 'the function returns the excess kurtosis of a half-normal distribution', sigma = data.sigma; for ( i = 0; i < sigma.length; i++ ) { y = kurtosis( sigma[i] ); - if ( expected[i] !== null) { + if ( expected[i] !== null ) { if ( y === expected[i] ) { t.strictEqual( y, expected[i], 'sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { From 8b3fad70f91be6b79b8c971d4ff27f3dad92b616 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Sat, 17 Jan 2026 00:37:49 +0530 Subject: [PATCH 3/4] fix: migrate from julia to scipy for fixtures --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: missing_dependencies - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../kurtosis/test/fixtures/julia/REQUIRE | 3 - .../kurtosis/test/fixtures/julia/data.json | 1 - .../kurtosis/test/fixtures/julia/runner.jl | 65 ---------------- .../kurtosis/test/fixtures/python/data.json | 1 + .../kurtosis/test/fixtures/python/runner.py | 77 +++++++++++++++++++ .../dists/halfnormal/kurtosis/test/test.js | 2 +- .../halfnormal/kurtosis/test/test.native.js | 2 +- 7 files changed, 80 insertions(+), 71 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/REQUIRE delete mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/data.json delete mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/runner.jl create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/data.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/runner.py diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/REQUIRE deleted file mode 100644 index 5a016dc17c07..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/REQUIRE +++ /dev/null @@ -1,3 +0,0 @@ -Distributions 0.25.123 -julia 1.10.5 -JSON 0.21 diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/data.json deleted file mode 100644 index 62e17bd85a0a..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/data.json +++ /dev/null @@ -1 +0,0 @@ -{"sigma":[2.36319709601774,3.3942462504419573,1.0391557294439813,4.940036749651035,1.9027125856845173,4.955358727145291,2.5397051685159946,2.4959815384296364,3.1105639003879846,2.139250174497646],"expected":[0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736,0.8691773036059736]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/runner.jl deleted file mode 100644 index daf566bfb1e4..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/julia/runner.jl +++ /dev/null @@ -1,65 +0,0 @@ -#!/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 JSON - -""" - halfnormal_excess_kurtosis() - -Returns the excess kurtosis of a half-normal distribution. -""" -function halfnormal_excess_kurtosis() - return 8 * (pi - 3) / (pi - 2)^2 -end - -""" - gen( sigma, name ) - -Generate fixture data and write to file. - -# Arguments - -* `sigma`: standard deviation -* `name::AbstractString`: output filename -""" -function gen( sigma, name ) - κ = halfnormal_excess_kurtosis() - z = fill( κ, length(sigma) ) - - data = Dict( - "sigma" => sigma, - "expected" => z - ) - - filepath = joinpath( dir, name ) - - open(filepath, "w") do outfile - write(outfile, JSON.json(data)) - write(outfile, "\n") - end -end - -# Get the filename: -file = @__FILE__ - -# Extract the directory in which this file resides: -dir = dirname(file) - -# Generate fixtures: -sigma = rand(10) .* 5.0 -gen(sigma, "data.json") diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/data.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/data.json new file mode 100644 index 000000000000..d3163a6bf6b0 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/data.json @@ -0,0 +1 @@ +{"sigma": [0.7302459116647342, 1.704961959568525, 4.233820319289189, 2.195888190206079, 4.869675543299393, 3.790130693695706, 4.061519802817745, 1.327292232113126, 2.9981592100860945, 2.6488562400723814], "expected": [0.8691773036059736, 0.8691773036059736, 0.8691773036059736, 0.8691773036059736, 0.8691773036059736, 0.8691773036059736, 0.8691773036059736, 0.8691773036059736, 0.8691773036059736, 0.8691773036059736]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/runner.py b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/runner.py new file mode 100644 index 000000000000..2ddfdf9fda1a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/runner.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python +# +# @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. + +"""Generate fixtures.""" + +import os +import json +import numpy as np +from scipy.stats import halfnorm + + +# Get the file path: +FILE = os.path.realpath(__file__) + +# Extract the directory in which this file resides: +DIR = os.path.dirname(FILE) + + +def gen(sigma, name): + """Generate fixture data and write to file. + + # Arguments + + * `sigma`: scale parameters + * `name::str`: output filename + + # Examples + + ``` python + python> sigma = np.random.rand(10) * 5.0 + python> gen(sigma, "data.json") + ``` + """ + y = np.empty(len(sigma), dtype=float) + + for i in range(len(sigma)): + # SciPy returns excess kurtosis + y[i] = halfnorm.stats(scale=sigma[i], moments="k") + + # Store data to be written to file as a dictionary: + data = { + "sigma": sigma.tolist(), + "expected": y.tolist() + } + + # Based on the script directory, create an output filepath: + filepath = os.path.join(DIR, name) + + # Write the data to the output filepath as JSON: + with open(filepath, "w", encoding="utf-8") as outfile: + json.dump(data, outfile) + outfile.write("\n") + + +def main(): + """Generate fixture data.""" + sigma = np.random.rand(10) * 5.0 + gen(sigma, "data.json") + + +if __name__ == "__main__": + main() diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js index a9b03e4f00ea..5993f6c14270 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js @@ -30,7 +30,7 @@ var kurtosis = require( './../lib' ); // FIXTURES // -var data = require( './fixtures/julia/data.json' ); +var data = require( './fixtures/python/data.json' ); // TESTS // diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js index d753e603cd98..ddff868996a6 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.native.js @@ -31,7 +31,7 @@ var EPS = require( '@stdlib/constants/float64/eps' ); // FIXTURES // -var data = require( './fixtures/julia/data.json' ); +var data = require( './fixtures/python/data.json' ); // VARIABLES // From 0892a5e51fe9daccfc81e7146e006a8a35b70616 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Wed, 21 Jan 2026 23:23:05 -0600 Subject: [PATCH 4/4] chore: minor clean-up --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: missing_dependencies - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../base/dists/halfnormal/kurtosis/README.md | 16 +++++++--------- .../dists/halfnormal/kurtosis/examples/index.js | 16 +++++++--------- .../kurtosis/test/fixtures/python/runner.py | 4 ++-- .../base/dists/halfnormal/kurtosis/test/test.js | 12 +++++++++--- 4 files changed, 25 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md index 88ea26120a3d..9547ce61d3ba 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/README.md @@ -84,18 +84,16 @@ var y = kurtosis( -1.0 ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var kurtosis = require( '@stdlib/stats/base/dists/halfnormal/kurtosis' ); -var sigma; -var y; -var i; +var opts = { + 'dtype': 'float64' +}; +var sigma = uniform( 10, 0.0, 20.0, opts ); -for ( i = 0; i < 10; i++ ) { - sigma = randu() * 20.0; - y = kurtosis( sigma ); - console.log( 'σ: %d, Kurt(σ): %d', sigma, y ); -} +logEachMap( 'σ: %0.4f, Kurt(X;σ): %0.4f', sigma, kurtosis ); ``` diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js index 88bc13312d60..0e2715bdb08d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/examples/index.js @@ -18,15 +18,13 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var kurtosis = require( './../lib' ); -var sigma; -var y; -var i; +var opts = { + 'dtype': 'float64' +}; +var sigma = uniform( 10, 0.0, 20.0, opts ); -for ( i = 0; i < 10; i++ ) { - sigma = randu() * 20.0; - y = kurtosis( sigma ); - console.log( 'σ: %d, Kurt(σ): %d', sigma, y ); -} +logEachMap( 'σ: %0.4f, Kurt(X;σ): %0.4f', sigma, kurtosis ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/runner.py b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/runner.py index 2ddfdf9fda1a..2852c388f20d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/runner.py +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/fixtures/python/runner.py @@ -48,9 +48,9 @@ def gen(sigma, name): """ y = np.empty(len(sigma), dtype=float) - for i in range(len(sigma)): + for i, s in enumerate(sigma): # SciPy returns excess kurtosis - y[i] = halfnorm.stats(scale=sigma[i], moments="k") + y[i] = halfnorm.stats(scale=s, moments="k") # Store data to be written to file as a dictionary: data = { diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js index 5993f6c14270..97083800ca60 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/kurtosis/test/test.js @@ -41,17 +41,23 @@ tape( 'main export is a function', function test( t ) { t.end(); }); +tape( 'if provided `NaN` for `sigma`, the function returns `NaN`', function test( t ) { + var y = kurtosis( NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + t.end(); +}); + tape( 'if provided `sigma <= 0`, the function returns `NaN`', function test( t ) { var y; y = kurtosis( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); y = kurtosis( -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); y = kurtosis( NINF ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); t.end(); });