diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/README.md b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/README.md new file mode 100644 index 000000000000..ec5280e1efce --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/README.md @@ -0,0 +1,239 @@ + + +# Skewness + +> [Anglit][anglit-distribution] distribution [skewness][skewness]. + + + +
+ +The [skewness][skewness] for an [anglit][anglit-distribution] random variable with location parameter `μ` and scale parameter `σ > 0` is + + + +```math +\mathop{\mathrm{skew}}\left( X \right) = 0 +``` + + + +
+ + + + + +
+ +## Usage + +```javascript +var skewness = require( '@stdlib/stats/base/dists/anglit/skewness' ); +``` + +#### skewness( mu, sigma ) + +Returns the [skewness][skewness] for an [anglit][anglit-distribution] distribution with location parameter `mu` and scale parameter `sigma`. + +```javascript +var y = skewness( 2.0, 1.0 ); +// returns 0.0 + +y = skewness( 0.0, 1.0 ); +// returns 0.0 + +y = skewness( -1.0, 4.0 ); +// returns 0.0 +``` + +If provided `NaN` as any argument, the function returns `NaN`. + +```javascript +var y = skewness( NaN, 1.0 ); +// returns NaN + +y = skewness( 0.0, NaN ); +// returns NaN +``` + +If provided `sigma <= 0`, the function returns `NaN`. + +```javascript +var y = skewness( 0.0, 0.0 ); +// returns NaN + +y = skewness( 0.0, -1.0 ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var skewness = require( '@stdlib/stats/base/dists/anglit/skewness' ); + +var opts = { + 'dtype': 'float64' +}; +var mu = uniform( 10, -5.0, 5.0, opts ); +var sigma = uniform( 10, 0.1, 20.0, opts ); + +logEachMap( 'μ: %lf, σ: %lf, skew(X;μ,σ): %lf', mu, sigma, skewness ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/anglit/skewness.h" +``` + +#### stdlib_base_dists_anglit_skewness( mu, sigma ) + +Returns the skewness for an anglit distribution with location parameter `mu` and scale parameter `sigma`. + +```c +double out = stdlib_base_dists_anglit_skewness( 0.0, 1.0 ); +// returns 0.0 +``` + +The function accepts the following arguments: + +- **mu**: `[in] double` location parameter. +- **sigma**: `[in] double` scale parameter. + +```c +double stdlib_base_dists_anglit_skewness( const double mu, const double sigma ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/anglit/skewness.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 mu; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + mu = random_uniform( -5.0, 5.0 ); + sigma = random_uniform( 0.1, 20.0 ); + y = stdlib_base_dists_anglit_skewness( mu, sigma ); + printf( "μ: %lf, σ: %lf, skew(X;μ,σ): %lf\n", mu, sigma, y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/benchmark/benchmark.js new file mode 100644 index 000000000000..6a1f35c57a33 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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 skewness = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var arrayOpts; + var sigma; + var mu; + var y; + var i; + + arrayOpts = { + 'dtype': 'float64' + }; + mu = uniform( 100, -50.0, 50.0, arrayOpts ); + sigma = uniform( 100, EPS, 20.0, arrayOpts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = skewness( mu[ i % mu.length ], sigma[ i % sigma.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/anglit/skewness/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/benchmark/benchmark.native.js new file mode 100644 index 000000000000..b7f8d8357134 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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 EPS = require( '@stdlib/constants/float64/eps' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var skewness = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( skewness instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { + var arrayOpts; + var sigma; + var mu; + var y; + var i; + + arrayOpts = { + 'dtype': 'float64' + }; + mu = uniform( 100, -50.0, 50.0, arrayOpts ); + sigma = uniform( 100, EPS, 20.0, arrayOpts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = skewness( mu[ i % mu.length ], sigma[ i % sigma.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/anglit/skewness/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/benchmark/c/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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/anglit/skewness/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/benchmark/c/benchmark.c new file mode 100644 index 000000000000..860be76744f9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/benchmark/c/benchmark.c @@ -0,0 +1,141 @@ +/** +* @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/anglit/skewness.h" +#include "stdlib/constants/float64/eps.h" +#include +#include +#include +#include +#include + +#define NAME "anglit-skewness" +#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 sigma[ 100 ]; + double mu[ 100 ]; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + mu[ i ] = random_uniform( -10.0, 10.0 ); + sigma[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_anglit_skewness( mu[ i%100 ], 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/anglit/skewness/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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/anglit/skewness/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/docs/repl.txt new file mode 100644 index 000000000000..1e813c4234f3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/docs/repl.txt @@ -0,0 +1,38 @@ + +{{alias}}( μ, σ ) + Returns the skewness of an anglit distribution with location parameter `μ` + and scale parameter `σ`. + + If provided `NaN` as any argument, the function returns `NaN`. + + If provided `σ <= 0`, the function returns `NaN`. + + Parameters + ---------- + μ: number + Location parameter. + + σ: number + Scale parameter. + + Returns + ------- + out: number + Skewness. + + Examples + -------- + > var y = {{alias}}( 0.0, 1.0 ) + 0.0 + > y = {{alias}}( 4.0, 2.0 ) + 0.0 + > 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/anglit/skewness/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/docs/types/index.d.ts new file mode 100644 index 000000000000..f696bbd6f301 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/docs/types/index.d.ts @@ -0,0 +1,57 @@ +/* +* @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 skewness for an anglit distribution with location parameter `mu` and scale parameter `sigma`. +* +* ## Notes +* +* - If provided `sigma <= 0`, the function returns `NaN`. +* +* @param mu - location parameter +* @param sigma - scale parameter +* @returns skewness +* +* @example +* var y = skewness( 0.0, 1.0 ); +* // returns 0.0 +* +* @example +* var y = skewness( 5.0, 2.0 ); +* // returns 0.0 +* +* @example +* var y = skewness( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = skewness( 0.0, NaN ); +* // returns NaN +* +* @example +* var y = skewness( 0.0, 0.0 ); +* // returns NaN +*/ +declare function skewness( mu: number, sigma: number ): number; + + +// EXPORTS // + +export = skewness; diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/docs/types/test.ts new file mode 100644 index 000000000000..9cb5a6d5c502 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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 skewness = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + skewness( 0, 2 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than two numbers... +{ + skewness( true, 3 ); // $ExpectError + skewness( false, 2 ); // $ExpectError + skewness( '5', 1 ); // $ExpectError + skewness( [], 1 ); // $ExpectError + skewness( {}, 2 ); // $ExpectError + skewness( ( x: number ): number => x, 2 ); // $ExpectError + + skewness( 9, true ); // $ExpectError + skewness( 9, false ); // $ExpectError + skewness( 5, '5' ); // $ExpectError + skewness( 8, [] ); // $ExpectError + skewness( 9, {} ); // $ExpectError + skewness( 8, ( x: number ): number => x ); // $ExpectError + + skewness( [], true ); // $ExpectError + skewness( {}, false ); // $ExpectError + skewness( false, '5' ); // $ExpectError + skewness( {}, [] ); // $ExpectError + skewness( '5', ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + skewness(); // $ExpectError + skewness( 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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/anglit/skewness/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/examples/c/example.c new file mode 100644 index 000000000000..f83aec4ae250 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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/anglit/skewness.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 mu; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + mu = random_uniform( -5.0, 5.0 ); + sigma = random_uniform( 0.1, 20.0 ); + y = stdlib_base_dists_anglit_skewness( mu, sigma ); + printf( "μ: %lf, σ: %lf, skew(X;μ,σ): %lf\n", mu, sigma, y ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/examples/index.js new file mode 100644 index 000000000000..a5f64d8089c9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/examples/index.js @@ -0,0 +1,31 @@ +/** +* @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 skewness = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; +var mu = uniform( 10, -5.0, 5.0, opts ); +var sigma = uniform( 10, 0.1, 20.0, opts ); + +logEachMap( 'μ: %lf, σ: %lf, skew(X;μ,σ): %lf', mu, sigma, skewness ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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", + "anglit", + "continuous", + "skewness", + "asymmetry", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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/anglit/skewness/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/src/addon.c new file mode 100644 index 000000000000..40e533ae2e36 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/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/anglit/skewness.h" +#include "stdlib/math/base/napi/binary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_anglit_skewness ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/src/main.c new file mode 100644 index 000000000000..06104db67824 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/src/main.c @@ -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. +*/ + +#include "stdlib/stats/base/dists/anglit/skewness.h" +#include "stdlib/math/base/assert/is_nan.h" + +/** +* Returns the skewness for an anglit distribution with location parameter `mu` and scale parameter `sigma`. +* +* @param mu location parameter +* @param sigma scale parameter +* @return skewness +* +* @example +* double y = stdlib_base_dists_anglit_skewness( 0.0, 1.0 ); +* // returns 0.0 +*/ +double stdlib_base_dists_anglit_skewness( const double mu, const double sigma ) { + if ( + stdlib_base_is_nan( mu ) || + stdlib_base_is_nan( sigma ) || + sigma <= 0.0 + ) { + return 0.0 / 0.0; // NaN + } + return 0.0; +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/fixtures/python/data.json b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/fixtures/python/data.json new file mode 100644 index 000000000000..d90822639541 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/fixtures/python/data.json @@ -0,0 +1 @@ +{"mu":[-1.4188624938085024,-4.64177188303363,-4.89367800766936,-2.0018412226987325,-2.379785366558007,-2.754663788840509,3.2412000807028125,0.8777223461769701,3.0488677689207684,4.564461367922355,-3.5052274356012525,4.832048205916376,4.752181395850929,-3.734911692922184,-4.983297757032351,-4.936113632632738,-1.8080639730360017,3.1242444738840938,-1.1823243441526756,2.4418692725939684,2.5101004173000003,-4.503549156524278,3.8425077400738346,-3.9520416643700784,-0.8560163423205447,4.9930092313126515,-0.2643684864911924,3.8630547495119654,2.4548175711439644,-1.6394978579141242,-3.985231936272781,-3.5373334678588533,-3.1379390448168873,0.32636765269835166,-3.8804233097239136,3.417879151298557,2.8064567331065158,3.795838340893148,2.6326141145441238,-0.2217810302128438,-3.4898617897879216,-3.7758762264524046,1.9128249362350953,4.306059277139584,2.835554295618979,3.5515260391389827,-3.7084967252576186,-2.479392655636911,2.5577264774129125,2.0290991586029463,2.928922335020129,3.451962188079472,4.068379622464665,2.8036816528514947,3.403340568818546,0.8137928925271618,3.263666047179143,-2.1332497349513546,0.4913951736966604,0.6031633656045265,2.2335063360008967,0.5443426246048775,-2.4426667457826365,-4.5079479645603096,-0.06644812885587026,-4.215968763421598,1.8628682460741146,2.9337829349128697,2.1457782208943774,0.8779040605572508,4.98004429779321,3.526588814873893,-4.872049782843234,4.506045067069165,0.8655490541495192,-3.0639827406917473,4.409021102788898,3.1055377080384847,-1.5516000906386918,0.17658348292877601,1.8392098888867983,-1.6585435251068512,0.7862254885745257,0.44828956726699687,3.5211023400068715,-1.4128134141728435,-2.5124614774723564,-2.9668622035600913,3.4236063144716926,-4.616049334482643,2.859579497132396,-3.453714738465168,-4.211929277313196,2.825110703745482,-2.9009166213051474,-3.647485462379889,4.085819008839065,-1.7822637588684942,-3.564141374429697,4.073674952105579],"sigma":[4.3978887989349245,2.264782525053,3.9823436057451422,2.0199252585774343,1.0432950808993258,3.275487119233307,0.4935198821643638,4.594532084996181,4.2455717009618406,0.5693940503634609,1.6454403140045544,2.3007741994643487,0.8288039318134294,3.888222332772863,4.2204341324422625,0.8756797986717035,4.905026147500793,1.564046443532785,1.1781577270641967,1.492942325474352,2.0987595395226037,3.2309774183724844,0.39283064061814477,3.3596879913476516,1.0889826812405607,1.3127337585367493,2.8578420892817715,0.09725108498362721,2.4453535318039643,3.895111554469005,3.452042487736799,1.7128018540368088,1.2478209611215962,2.271838484211897,2.2553932886152452,4.625203778974315,3.828393371526634,0.9810255358024017,2.8247767600062987,3.603985009336138,3.389610358515392,1.0172850345233326,4.787287180090457,2.9408617658993723,2.063130902225915,2.1894385670007908,4.925650612783017,0.9148324914871353,2.6224953252336967,4.670930256320625,0.9380678739717146,4.4722475740503125,1.2925594131981133,3.8632659928903004,2.4537859614897553,1.5276395039532182,3.2091937086063784,2.3046987601627666,2.709023833026736,1.5472025880792935,0.8691533754248087,2.788960642582124,0.34228788116005104,4.173540503415632,1.1704753465408209,2.8091344195099945,2.821132534120335,4.529482589522634,0.6297862987086078,2.3638749160707837,3.4941249361508344,2.5645293469442247,3.309743071988909,1.0879138936411243,4.450766001595327,0.30427818256797245,3.1544752771758553,3.4923044965496723,0.31407022493745496,0.7697841072573064,0.9232910010078071,0.8041261673386063,0.098083765028647,0.9927143114488257,3.913004037109145,0.2324296234624612,2.2789269273911574,3.068614483172391,2.2733547439224258,0.455033197062642,1.5485099848409407,2.4198950382441735,0.8755558627832155,0.26825421256270354,3.163827108544711,1.4136087938365116,3.7376196699608517,4.109708814280007,2.1343370732297244,2.932785632192921],"expected":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/fixtures/python/runner.py b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/fixtures/python/runner.py new file mode 100644 index 000000000000..be459892c66f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/fixtures/python/runner.py @@ -0,0 +1,82 @@ +#!/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 anglit + +# Get the file path: +FILE = os.path.realpath(__file__) + +# Extract the directory in which this file resides: +DIR = os.path.dirname(FILE) + + +def gen(loc, sigma, name): + """Generate fixture data and write to file. + + # Arguments + + * `loc`: location parameter + * `sigma`: scale parameter + * `name::str`: output filename + + # Examples + + ``` python + python> loc = np.random.rand(1000) * 10.0 - 5.0 + python> sigma = np.random.rand(1000) * 5.0 + 0.01 + python> gen(loc, sigma, "data.json") + ``` + """ + # The anglit distribution is symmetric, so its skewness is analytically `0` + # and is invariant to the location and scale parameters. Query SciPy for the + # skewness to validate inputs and keep SciPy-based fixtures. + z = np.array([anglit.stats(loc=m, scale=s, moments="s") for m, s in zip(loc, sigma)]) + + # Store data to be written to file as a dictionary: + data = { + "mu": loc.tolist(), + "sigma": sigma.tolist(), + "expected": z.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) + + # Include trailing newline: + with open(filepath, "a", encoding="utf-8") as outfile: + outfile.write("\n") + + +def main(): + """Generate fixture data.""" + loc = np.random.rand(100) * 10.0 - 5.0 + sigma = np.random.rand(100) * 5.0 + 0.01 + gen(loc, sigma, "data.json") + + +if __name__ == "__main__": + main() diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/test.js new file mode 100644 index 000000000000..ba29ffa2920b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/test.js @@ -0,0 +1,90 @@ +/** +* @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 PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var skewness = require( './../lib' ); + + +// FIXTURES // + +var data = require( './fixtures/python/data.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof skewness, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) { + var y = skewness( NaN, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = skewness( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a nonpositive `sigma`, the function returns `NaN`', function test( t ) { + var y; + + y = skewness( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( NaN, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the skewness of an anglit distribution', function test( t ) { + var expected; + var sigma; + var mu; + var y; + var i; + + expected = data.expected; + mu = data.mu; + sigma = data.sigma; + for ( i = 0; i < mu.length; i++ ) { + y = skewness( mu[i], sigma[i] ); + t.strictEqual( y, expected[i], 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/test.native.js new file mode 100644 index 000000000000..c51884ee9501 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/anglit/skewness/test/test.native.js @@ -0,0 +1,99 @@ +/** +* @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 PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); + + +// FIXTURES // + +var data = require( './fixtures/python/data.json' ); + + +// VARIABLES // + +var skewness = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( skewness instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof skewness, '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 = skewness( NaN, 1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = skewness( 1.0, 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 = skewness( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = skewness( NaN, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the skewness of an anglit distribution', opts, function test( t ) { + var expected; + var sigma; + var mu; + var y; + var i; + + expected = data.expected; + mu = data.mu; + sigma = data.sigma; + for ( i = 0; i < mu.length; i++ ) { + y = skewness( mu[i], sigma[i] ); + t.strictEqual( y, expected[i], 'returns expected value' ); + } + t.end(); +});