From 4eacb9568fbc50573d9461a40f1c256f03f5eedb Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Tue, 13 Jan 2026 18:04:48 +0530 Subject: [PATCH 1/9] feat: add implementation of halfnormal/quantile --- 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/quantile/README.md | 271 ++++++++++++++++++ .../quantile/benchmark/benchmark.js | 93 ++++++ .../quantile/benchmark/benchmark.native.js | 71 +++++ .../halfnormal/quantile/benchmark/c/Makefile | 146 ++++++++++ .../quantile/benchmark/c/benchmark.c | 141 +++++++++ .../dists/halfnormal/quantile/binding.gyp | 170 +++++++++++ .../dists/halfnormal/quantile/docs/repl.txt | 81 ++++++ .../halfnormal/quantile/docs/types/index.d.ts | 100 +++++++ .../halfnormal/quantile/docs/types/test.ts | 98 +++++++ .../halfnormal/quantile/examples/c/Makefile | 146 ++++++++++ .../halfnormal/quantile/examples/c/example.c | 40 +++ .../halfnormal/quantile/examples/index.js | 34 +++ .../dists/halfnormal/quantile/include.gypi | 53 ++++ .../stats/base/dists/halfnormal/quantile.h | 38 +++ .../dists/halfnormal/quantile/lib/factory.js | 80 ++++++ .../dists/halfnormal/quantile/lib/index.js | 54 ++++ .../dists/halfnormal/quantile/lib/main.js | 93 ++++++ .../dists/halfnormal/quantile/lib/native.js | 75 +++++ .../dists/halfnormal/quantile/manifest.json | 84 ++++++ .../dists/halfnormal/quantile/package.json | 68 +++++ .../dists/halfnormal/quantile/src/Makefile | 70 +++++ .../dists/halfnormal/quantile/src/addon.c | 22 ++ .../base/dists/halfnormal/quantile/src/main.c | 52 ++++ .../quantile/test/fixtures/julia/REQUIRE | 0 .../quantile/test/fixtures/julia/data.json | 1 + .../quantile/test/fixtures/julia/runner.jl | 64 +++++ .../halfnormal/quantile/test/test.factory.js | 108 +++++++ .../dists/halfnormal/quantile/test/test.js | 38 +++ .../halfnormal/quantile/test/test.native.js | 104 +++++++ .../halfnormal/quantile/test/test.quantile.js | 95 ++++++ 30 files changed, 2490 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/include/stdlib/stats/base/dists/halfnormal/quantile.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/data.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/runner.jl create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md new file mode 100644 index 000000000000..0aabe538192d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md @@ -0,0 +1,271 @@ + + +# Quantile Function + +> [Half-normal][halfnormal-distribution] distribution [quantile function][quantile-function]. + +
+ +The [quantile function][quantile-function] for a [half-normal][halfnormal-distribution] random variable is + + + +```math +Q(p;\sigma) = \sigma\sqrt{2}\,\mathop{\mathrm{erf}}^{-1}(p) +``` + + + + + +for `0 <= p < 1`, where `σ > 0` is the scale parameter. + +
+ + + +
+ +## Usage + +```javascript +var quantile = require( '@stdlib/stats/base/dists/halfnormal/quantile' ); +``` + +#### quantile( p, sigma ) + +Evaluates the [quantile function][quantile-function] for a [half-normal][halfnormal-distribution] distribution with scale parameter `sigma`. + +```javascript +var y = quantile( 0.5, 1.0 ); +// returns ~0.674 + +y = quantile( 0.8, 2.0 ); +// returns ~2.563 +``` + +If provided a probability `p` outside the interval `[0,1]`, the function returns `NaN`. + +```javascript +var y = quantile( 1.9, 1.0 ); +// returns NaN + +y = quantile( -0.1, 1.0 ); +// returns NaN +``` + +If provided `NaN` as any argument, the function returns `NaN`. + +```javascript +var y = quantile( NaN, 1.0 ); +// returns NaN + +y = quantile( 0.0, NaN ); +// returns NaN +``` + +If provided `sigma < 0`, the function returns `NaN`. + +```javascript +var y = quantile( 0.4, -1.0 ); +// returns NaN +``` + +If provided `sigma = 0`, the function evaluates the [quantile function][quantile-function] of a [degenerate distribution][degenerate-distribution] centered at `0`. + +```javascript +var y = quantile( 0.3, 0.0 ); +// returns 0.0 + +y = quantile( 0.9, 0.0 ); +// returns 0.0 +``` + +#### quantile.factory( sigma ) + +Returns a function for evaluating the [quantile function][quantile-function] of a [half-normal][halfnormal-distribution] distribution with parameter `sigma`. + +```javascript +var myquantile = quantile.factory( 4.0 ); + +var y = myquantile( 0.2 ); +// returns ~1.013 + +y = myquantile( 0.8 ); +// returns ~5.126 +``` + +
+ + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var quantile = require( '@stdlib/stats/base/dists/halfnormal/quantile' ); + +var opts = { + 'dtype': 'float64' +}; +var sigma = uniform( 10, 0.0, 20.0, opts ); +var p = uniform( 10, 0.0, 1.0, opts ); + +logEachMap( 'p: %lf, σ: %lf, Q(p;σ): %lf', p, sigma, quantile ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/halfnormal/quantile.h" +``` + +#### stdlib_base_dists_halfnormal_quantile( p, sigma ) + +Evaluates the [quantile function][quantile-function] for a [half-normal][halfnormal-distribution] distribution with parameter `sigma` (scale). + +```c +double y = stdlib_base_dists_halfnormal_quantile( 0.8, 1.0 ); +// returns ~1.282 +``` + +The function accepts the following arguments: + +- **p**: `[in] double` probability. +- **sigma**: `[in] double` scale parameter. + +```c +double stdlib_base_dists_halfnormal_quantile( const double p, const double sigma ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/halfnormal/quantile.h" +#include "stdlib/constants/float64/eps.h" +#include +#include + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v*(max-min) ); +} + +int main( void ) { + double sigma; + double p; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + p = random_uniform( 0.0, 1.0 ); + sigma = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 ); + y = stdlib_base_dists_halfnormal_quantile( p, sigma ); + printf( "p:%lf, σ: %lf, Q(p;σ): %lf\n", p, sigma, y ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.js new file mode 100644 index 000000000000..2815ef3fd5c8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.js @@ -0,0 +1,93 @@ +/** +* @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 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 quantile = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var sigma; + var len; + var p; + var y; + var i; + + len = 100; + p = new Float64Array( len ); + sigma = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + p[ i ] = uniform( 0.0, 1.0 ); + sigma[ i ] = uniform( EPS, 20.0 ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = quantile( p[ i % len ], 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(); +}); + +bench( pkg+':factory', function benchmark( b ) { + var myquantile; + var sigma; + var len; + var p; + var y; + var i; + + sigma = 4.0; + myquantile = quantile.factory( sigma ); + len = 100; + p = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + p[ i ] = uniform( 0.0, 1.0 ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = myquantile( p[ 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/quantile/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.native.js new file mode 100644 index 000000000000..6e7ed876ec0a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.native.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var Float64Array = require( '@stdlib/array/float64' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +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; + + +// VARIABLES // + +var quantile = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( quantile instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var sigma; + var len; + var p; + var y; + var i; + + len = 100; + p = new Float64Array( len ); + sigma = new Float64Array( len ); + for ( i = 0; i < len; i++ ) { + p[ i ] = uniform( 0.0, 1.0 ); + sigma[ i ] = uniform( EPS, 20.0 ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = quantile( p[ i % len ], 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/quantile/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/benchmark.c new file mode 100644 index 000000000000..50195b410ece --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/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/halfnormal/quantile.h" +#include "stdlib/constants/float64/eps.h" +#include +#include +#include +#include +#include + +#define NAME "halfnormal-quantile" +#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 p[ 100 ]; + double sigma[ 100 ]; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + p[ i ] = random_uniform( 0.0, 1.0 ); + sigma[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_halfnormal_quantile( p[ 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/halfnormal/quantile/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/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/quantile/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/repl.txt new file mode 100644 index 000000000000..3a54c869fe9a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/repl.txt @@ -0,0 +1,81 @@ +{{alias}}( p, σ ) + Evaluates the quantile function for a Half-Normal distribution with scale + parameter `σ` at a probability `p`. + + If `p < 0` or `p > 1`, the function returns `NaN`. + + If provided `NaN` as any argument, the function returns `NaN`. + + If provided `σ < 0`, the function returns `NaN`. + + If `σ = 0`, the function returns `0`. + + If `p = 1`, the function returns `+∞`. + + Parameters + ---------- + p: number + Input probability. + + σ: number + Scale parameter. + + Returns + ------- + out: number + Evaluated quantile function. + + Examples + -------- + > var y = {{alias}}( 0.8, 1.0 ) + ~1.2816 + + > y = {{alias}}( 0.5, 2.0 ) + ~1.3490 + + > y = {{alias}}( 0.5, 4.0 ) + ~2.6980 + + > y = {{alias}}( 1.1, 1.0 ) + NaN + + > y = {{alias}}( -0.2, 1.0 ) + NaN + + > y = {{alias}}( NaN, 1.0 ) + NaN + + > y = {{alias}}( 0.0, NaN ) + NaN + + // Negative scale parameter: + > y = {{alias}}( 0.5, -1.0 ) + NaN + + +{{alias}}.factory( σ ) + Returns a function for evaluating the quantile function of a Half-Normal + distribution with scale parameter `σ`. + + Parameters + ---------- + σ: number + Scale parameter. + + Returns + ------- + quantile: Function + Quantile function. + + Examples + -------- + > var myQuantile = {{alias}}.factory( 2.0 ); + + > var y = myQuantile( 0.5 ) + ~1.3490 + + > y = myQuantile( 0.8 ) + ~2.5631 + + See Also + -------- diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/index.d.ts new file mode 100644 index 000000000000..c29b0bd79da0 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/index.d.ts @@ -0,0 +1,100 @@ +/* +* @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 + +/** +* Evaluates the quantile function for a half-normal distribution. +* +* @param p - cumulative probability +* @returns evaluated quantile +*/ +type Unary = ( p: number ) => number; + +/** +* Interface for the quantile function of a half-normal distribution. +*/ +interface Quantile { + /** + * Evaluates the quantile function for a half-normal distribution with scale parameter `sigma`. + * + * ## Notes + * + * - If `sigma < 0`, the function returns `NaN`. + * - If `p < 0` or `p > 1`, the function returns `NaN`. + * - If `sigma = 0`, the function returns `0`. + * - If `p = 1`, the function returns `+Infinity`. + * + * @param p - cumulative probability + * @param sigma - scale parameter + * @returns evaluated quantile + * + * @example + * var y = quantile( 0.8, 1.0 ); + * // returns ~1.2816 + * + * @example + * var y = quantile( 0.5, 2.0 ); + * // returns ~1.3490 + * + * @example + * var y = quantile( 1.1, 1.0 ); + * // returns NaN + * + * @example + * // Negative scale parameter: + * var y = quantile( 0.5, -1.0 ); + * // returns NaN + */ + ( p: number, sigma: number ): number; + + /** + * Returns a function for evaluating the quantile function for a half-normal distribution with scale parameter `sigma`. + * + * @param sigma - scale parameter + * @returns quantile function + * + * @example + * var myquantile = quantile.factory( 2.0 ); + * var y = myquantile( 0.5 ); + * // returns ~1.3490 + */ + factory( sigma: number ): Unary; +} + +/** +* Half-normal distribution quantile function. +* +* @param p - cumulative probability +* @param sigma - scale parameter +* @returns evaluated quantile +* +* @example +* var y = quantile( 0.8, 1.0 ); +* // returns ~1.2816 +* +* var myquantile = quantile.factory( 1.0 ); +* var y = myquantile( 0.8 ); +* // returns ~1.2816 +*/ +declare var quantile: Quantile; + + +// EXPORTS // + +export = quantile; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/test.ts new file mode 100644 index 000000000000..6eec785bf355 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/test.ts @@ -0,0 +1,98 @@ +/* +* @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 quantile = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + quantile( 0.2, 4 ); // $ExpectType number + quantile( 0.8, 8 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than two numbers... +{ + quantile( true, 6 ); // $ExpectError + quantile( false, 4 ); // $ExpectError + quantile( '5', 2 ); // $ExpectError + quantile( [], 2 ); // $ExpectError + quantile( {}, 4 ); // $ExpectError + quantile( ( x: number ): number => x, 4 ); // $ExpectError + + quantile( 0.2, true ); // $ExpectError + quantile( 0.8, false ); // $ExpectError + quantile( 0.5, '5' ); // $ExpectError + quantile( 0.8, [] ); // $ExpectError + quantile( 0.9, {} ); // $ExpectError + quantile( 0.8, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + quantile(); // $ExpectError + quantile( 0.2 ); // $ExpectError + quantile( 0.2, 4, 1 ); // $ExpectError +} + +// Attached to main export is a `factory` method which returns a function... +{ + quantile.factory( 4 ); // $ExpectType Unary +} + +// The `factory` method returns a function which returns a number... +{ + const fcn = quantile.factory( 4 ); + fcn( 0.5 ); // $ExpectType number +} + +// The compiler throws an error if the function returned by the `factory` method is provided invalid arguments... +{ + const fcn = quantile.factory( 4 ); + fcn( true ); // $ExpectError + fcn( false ); // $ExpectError + fcn( '5' ); // $ExpectError + fcn( [] ); // $ExpectError + fcn( {} ); // $ExpectError + fcn( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function returned by the `factory` method is provided an unsupported number of arguments... +{ + const fcn = quantile.factory( 4 ); + fcn(); // $ExpectError + fcn( 2, 0 ); // $ExpectError + fcn( 2, 0, 1 ); // $ExpectError +} + +// The compiler throws an error if the `factory` method is provided values other than one number... +{ + quantile.factory( true ); // $ExpectError + quantile.factory( false ); // $ExpectError + quantile.factory( '5' ); // $ExpectError + quantile.factory( [] ); // $ExpectError + quantile.factory( {} ); // $ExpectError + quantile.factory( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `factory` method is provided an unsupported number of arguments... +{ + quantile.factory(); // $ExpectError + quantile.factory( 0, 4 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/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/quantile/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/c/example.c new file mode 100644 index 000000000000..5deff2a54239 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/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/halfnormal/quantile.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 p; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + p = random_uniform( 0.0, 1.0 ); + sigma = random_uniform( 0.0, 10.0 ); + y = stdlib_base_dists_halfnormal_quantile( p, sigma ); + printf( "p: %lf, σ: %lf, Q(p;σ): %lf\n", p, sigma, y ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/index.js new file mode 100644 index 000000000000..95e4060a12a3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/index.js @@ -0,0 +1,34 @@ +/** +* @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 quantile = require( './../lib' ); + +var i; +var p; +var sigma; +var y; + +for ( i = 0; i < 25; i++ ) { + p = randu(); // p in [0,1) + sigma = randu() * 3.0; // sigma >= 0 + y = quantile( p, sigma ); + console.log( 'p: %lf, σ: %lf, Q(p;σ): %lf', p, sigma, y ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/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': [ + ' + */ + function quantile( p ) { + if ( isnan( p ) || p < 0.0 || p > 1.0 ) { + return NaN; + } + if ( p === 1.0 ) { + return PINF; + } + return sigma * SQRT2 * erfinv( p ); + } +} + + +// EXPORTS // + +module.exports = factory; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js new file mode 100644 index 000000000000..e0fd755c376d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Halfnormal distribution quantile function. +* +* @module @stdlib/stats/base/dists/halfnormal/quantile +* +* @example +* var quantile = require( '@stdlib/stats/base/dists/halfnormal/quantile' ); +* +* var y = quantile( 0.8, 1.0 ); +* // returns ~1.282 +* +* var myQuantile = quantile.factory( 1.0 ); +* y = myQuantile( 0.5 ); +* // returns ~0.674 +* +* y = myQuantile( 0.7 ); +* // returns ~1.036 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var factory = require( './factory.js' ); + + +// MAIN // + +setReadOnly( main, 'factory', factory ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/main.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/main.js new file mode 100644 index 000000000000..5b58c79258e4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/main.js @@ -0,0 +1,93 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var erfinv = require( '@stdlib/math/base/special/erfinv' ); +var SQRT2 = require( '@stdlib/constants/float64/sqrt-two' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); + + +// MAIN // + +/** +* Evaluates the quantile function for a Half-Normal distribution with scale parameter `sigma` at a probability `p`. +* +* @param {Probability} p - cumulative probability +* @param {NonNegativeNumber} sigma - scale parameter +* @returns {number} evaluated quantile function +* +* @example +* var y = quantile( 0.8, 1.0 ); +* // returns ~1.2816 +* +* @example +* var y = quantile( 0.5, 2.0 ); +* // returns ~1.3490 +* +* @example +* var y = quantile( 0.5, 4.0 ); +* // returns ~2.6980 +* +* @example +* var y = quantile( 1.1, 1.0 ); +* // returns NaN +* +* @example +* var y = quantile( -0.2, 1.0 ); +* // returns NaN +* +* @example +* var y = quantile( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = quantile( 0.0, NaN ); +* // returns NaN +* +* @example +* // Negative scale parameter: +* var y = quantile( 0.5, -1.0 ); +* // returns NaN +*/ +function quantile( p, sigma ) { + if ( + isnan( sigma ) || + isnan( p ) || + sigma < 0.0 || + p < 0.0 || + p > 1.0 + ) { + return NaN; + } + if ( sigma === 0.0 ) { + return 0.0; + } + if ( p === 1.0 ) { + return PINF; + } + return sigma * SQRT2 * erfinv( p ); +} + + +// EXPORTS // + +module.exports = quantile; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/native.js new file mode 100644 index 000000000000..4255bbd7b1fa --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/native.js @@ -0,0 +1,75 @@ +/** +* @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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Evaluates the quantile function for a Half-Normal distribution with scale parameter `sigma` at a probability `p`. +* +* @param {Probability} p - cumulative probability +* @param {NonNegativeNumber} sigma - scale parameter +* @returns {number} evaluated quantile function +* +* @example +* var y = quantile( 0.8, 1.0 ); +* // returns ~1.2816 +* +* @example +* var y = quantile( 0.5, 2.0 ); +* // returns ~1.3490 +* +* @example +* var y = quantile( 0.5, 4.0 ); +* // returns ~2.6980 +* +* @example +* var y = quantile( 1.1, 1.0 ); +* // returns NaN +* +* @example +* var y = quantile( -0.2, 1.0 ); +* // returns NaN +* +* @example +* var y = quantile( NaN, 1.0 ); +* // returns NaN +* +* @example +* var y = quantile( 0.0, NaN ); +* // returns NaN +* +* @example +* // Negative scale parameter: +* var y = quantile( 0.5, -1.0 ); +* // returns NaN +*/ +function quantile( p, sigma ) { + return addon( p, sigma ); +} + + +// EXPORTS // + +module.exports = quantile; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/manifest.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/manifest.json new file mode 100644 index 000000000000..833d05bf1a41 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/manifest.json @@ -0,0 +1,84 @@ +{ + "options": { + "task": "build", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/binary", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/erfinv", + "@stdlib/constants/float64/sqrt-two" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/constants/float64/eps", + "@stdlib/math/base/special/erfinv", + "@stdlib/constants/float64/sqrt-two" + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/constants/float64/eps", + "@stdlib/math/base/special/erfinv", + "@stdlib/constants/float64/sqrt-two" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/package.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/package.json new file mode 100644 index 000000000000..f569963257e6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/stats/base/dists/halfnormal/quantile", + "version": "0.0.0", + "description": "Half-normal distribution quantile function.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "distribution", + "dist", + "probability", + "cdf", + "inverse", + "half-normal", + "univariate", + "continuous" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/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/quantile/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/addon.c new file mode 100644 index 000000000000..3e0f61fd98ed --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/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/quantile.h" +#include "stdlib/math/base/napi/binary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_halfnormal_quantile ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/main.c new file mode 100644 index 000000000000..094e4a450184 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/main.c @@ -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. +*/ + +#include "stdlib/stats/base/dists/halfnormal/quantile.h" +#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/special/erfinv.h" +#include "stdlib/constants/float64/sqrt_two.h" + +/** +* Evaluates the quantile function for a Half-normal distribution with cumulative probability p and scale `sigma`. +* +* @param p probability +* @param sigma scale parameter +* @return evaluated quantile +* +* @example +* double y = stdlib_base_dists_halfnormal_quantile( 0.8, 1.0 ); +* // returns ~1.282 +*/ +double stdlib_base_dists_halfnormal_quantile( const double p, const double sigma ) { + if ( + stdlib_base_is_nan( p ) || + stdlib_base_is_nan( sigma ) || + sigma < 0.0 || + p < 0.0 || + p > 1.0 + ) { + return 0.0 / 0.0; // NaN + } + if( sigma == 0.0 ){ + return 0.0; + } + if( p == 1.0 ){ + return 1.0 / 0.0; // +infinity + } + return sigma * STDLIB_CONSTANT_FLOAT64_SQRT2 * stdlib_base_erfinv( p ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/REQUIRE new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/data.json new file mode 100644 index 000000000000..8eec56801a4c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/data.json @@ -0,0 +1 @@ +{"sigma":[3.752372343198736,0.5952487736546558,3.3856198354728,1.3195086901125626,0.33660791776355947,3.0698228295251733,2.8333822017156756,0.842096233317226,0.9014208323745504,0.9645360412814957],"expected":[4.115703132034415,0.4368820501703096,3.423273300043822,0.6971282572460012,0.27955804839293547,0.6442160951563007,2.626768194061231,0.24752155341315513,0.04330086356582894,1.155323910174928],"p":[0.7272829554760867,0.5370199818842734,0.6880417602571298,0.40272560115812794,0.5937525368951077,0.1662187547190921,0.6461143084421898,0.23119242465068246,0.038312635981986976,0.7690061785566936]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/runner.jl new file mode 100644 index 000000000000..8f5dfec5906d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/runner.jl @@ -0,0 +1,64 @@ +#!/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. + +using Distributions +using SpecialFunctions # for erfinv +using JSON + +""" + gen(p, sigma, name) + +Generate Half-Normal quantile fixture data. + +# Arguments +- `p`: probability values (0 ≤ p ≤ 1) +- `sigma`: scale parameters (σ ≥ 0) +- `name`: output filename +""" +function gen(p, sigma, name) + z = Array{Float64}(undef, length(p)) + for i in eachindex(p) + # Half-normal quantile: + # Q(p) = sigma * sqrt(2) * erfinv(p) + z[i] = sigma[i] * sqrt(2.0) * erfinv(p[i]) + end + + data = Dict( + "p" => p, + "sigma" => sigma, + "expected" => z + ) + + filepath = joinpath(dir, name) + open(filepath, "w") do f + write(f, JSON.json(data)) + write(f, "\n") + end +end + +# Directory of this script +file = @__FILE__ +dir = dirname(file) + +# Generate random test values +N = 10 +p = rand(N) # in (0,1) +sigma = rand(N) .* 5.0 # σ in [0,5) + +# Write a single data file +gen(p, sigma, "data.json") diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js new file mode 100644 index 000000000000..5a1b554d175b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js @@ -0,0 +1,108 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var factory = require( './../lib/factory.js' ); + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); +var p = data.p; +var sigma = data.sigma; +var expected = data.expected; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'factory returns a function', function test( t ) { + var q = factory( 1.0 ); + t.strictEqual( typeof q, 'function', 'returns expected value' ); + t.end(); +}); + +tape( 'if sigma is NaN or < 0, returned function always returns NaN', function test( t ) { + var q; + + q = factory( NaN ); + t.ok( isnan( q( 0.5 ) ), 'sigma NaN' ); + + q = factory( -1.0 ); + t.ok( isnan( q( 0.5 ) ), 'sigma < 0' ); + + t.end(); +}); + +tape( 'if sigma = 0, quantile always returns 0', function test( t ) { + var q = factory( 0.0 ); + t.strictEqual( q( 0.0 ), 0.0 ); + t.strictEqual( q( 0.5 ), 0.0 ); + t.strictEqual( q( 1.0 ), 0.0 ); + t.end(); +}); + +tape( 'if p < 0, p > 1, or p is NaN, quantile returns NaN', function test( t ) { + var q = factory( 1.0 ); + + t.ok( isnan( q( -0.1 ) ), 'p < 0' ); + t.ok( isnan( q( 1.1 ) ), 'p > 1' ); + t.ok( isnan( q( NaN ) ), 'p NaN' ); + + t.end(); +}); + +tape( 'p = 1 returns +Infinity', function test( t ) { + var q = factory( 1.0 ); + t.strictEqual( q( 1.0 ), PINF, 'returns +Infinity' ); + t.end(); +}); + +tape( 'the factory evaluates the half-normal quantile correctly', function test( t ) { + var delta; + var tol; + var q; + var i; + + for ( i = 0; i < p.length; i++ ) { + q = factory( sigma[i] ); + if ( expected[i] !== null ) { + if ( q( p[i] ) === expected[i] ) { + t.strictEqual( q( p[i] ), expected[i], 'exact match' ); + } else { + delta = abs( q( p[i] ) - expected[i] ); + tol = 40.0 * EPS * abs( expected[i] ); + t.ok(delta <= tol, 'p: '+p[i]+', sigma: '+sigma[i]+', q: '+q(p[i])+', expected: '+expected[i]); + } + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.js new file mode 100644 index 000000000000..ea2a910239b6 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.js @@ -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. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var quantile = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof quantile, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a factory method for generating `quantile` functions', function test( t ) { + t.strictEqual( typeof quantile.factory, 'function', 'exports a factory method' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js new file mode 100644 index 000000000000..f321a2cd8bef --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js @@ -0,0 +1,104 @@ +/** +* @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 PINF = require( '@stdlib/constants/float64/pinf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); + + +// VARIABLES // + +var quantile = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( quantile instanceof Error ) +}; + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); +var p = data.p; +var sigma = data.sigma; +var expected = data.expected; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if any argument is NaN, the function returns NaN', opts, function test( t ) { + t.ok( isnan( quantile( NaN, 1.0 ) ), 'p NaN' ); + t.ok( isnan( quantile( 0.5, NaN ) ), 'sigma NaN' ); + t.end(); +}); + +tape( 'if p is outside [0,1], the function returns NaN', opts, function test( t ) { + t.ok( isnan( quantile( -0.1, 1.0 ) ), 'p < 0' ); + t.ok( isnan( quantile( 1.1, 1.0 ) ), 'p > 1' ); + t.end(); +}); + +tape( 'if sigma < 0, the function returns NaN', opts, function test( t ) { + t.ok( isnan( quantile( 0.5, -1.0 ) ), 'negative sigma' ); + t.end(); +}); + +tape( 'if sigma = 0, the quantile is 0 for all p', opts, function test( t ) { + t.strictEqual( quantile( 0.0, 0.0 ), 0.0 ); + t.strictEqual( quantile( 0.5, 0.0 ), 0.0 ); + t.strictEqual( quantile( 1.0, 0.0 ), 0.0 ); + t.end(); +}); + +tape( 'p = 1 returns +Infinity', opts, function test( t ) { + t.strictEqual( quantile( 1.0, 1.0 ), PINF ); + t.end(); +}); + +tape( 'the native function evaluates the half-normal quantile correctly', opts, function test( t ) { + var delta; + var tol; + var y; + var i; + + for ( i = 0; i < p.length; i++ ) { + y = quantile( p[i], sigma[i] ); + if ( expected[i] !== null ) { + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'exact match' ); + } else { + delta = abs( y - expected[i] ); + tol = 40.0 * EPS * abs( expected[i] ); + t.ok(delta <= tol, 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i]); + } + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js new file mode 100644 index 000000000000..a5907775251f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js @@ -0,0 +1,95 @@ +/** +* @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 abs = require( '@stdlib/math/base/special/abs' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var quantile = require( './../lib' ); + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); +var p = data.p; +var sigma = data.sigma; +var expected = data.expected; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if any argument is NaN, the function returns NaN', function test( t ) { + t.ok( isnan( quantile( NaN, 1.0 ) ), 'p NaN' ); + t.ok( isnan( quantile( 0.5, NaN ) ), 'sigma NaN' ); + t.end(); +}); + +tape( 'if p is outside [0,1], the function returns NaN', function test( t ) { + t.ok( isnan( quantile( -0.1, 1.0 ) ), 'p < 0' ); + t.ok( isnan( quantile( 1.1, 1.0 ) ), 'p > 1' ); + t.end(); +}); + +tape( 'if sigma < 0, the function returns NaN', function test( t ) { + t.ok( isnan( quantile( 0.5, -1.0 ) ), 'negative sigma' ); + t.end(); +}); + +tape( 'if sigma = 0, the quantile is 0 for all p', function test( t ) { + t.strictEqual( quantile( 0.0, 0.0 ), 0.0 ); + t.strictEqual( quantile( 0.5, 0.0 ), 0.0 ); + t.strictEqual( quantile( 1.0, 0.0 ), 0.0 ); + t.end(); +}); + +tape( 'p = 1 returns +Infinity', function test( t ) { + t.strictEqual( quantile( 1.0, 1.0 ), PINF ); + t.end(); +}); + +tape( 'the function evaluates the half-normal quantile correctly', function test( t ) { + var delta; + var tol; + var y; + var i; + + for ( i = 0; i < p.length; i++ ) { + y = quantile( p[i], sigma[i] ); + if ( expected[i] !== null ) { + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'exact match' ); + } else { + delta = abs( y - expected[i] ); + tol = 40.0 * EPS * abs( expected[i] ); + t.ok(delta <= tol, 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i]); + } + } + } + t.end(); +}); From 17da207e1181d16025ea24cc8a6e373074602cc8 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Tue, 13 Jan 2026 18:10:32 +0530 Subject: [PATCH 2/9] fix: changed wrong variable names in test files --- 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: na - 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 --- --- .../stats/base/dists/halfnormal/quantile/test/test.native.js | 2 +- .../stats/base/dists/halfnormal/quantile/test/test.quantile.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js index f321a2cd8bef..f76fa9a748e2 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js @@ -49,7 +49,7 @@ var expected = data.expected; tape( 'main export is a function', function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.strictEqual( typeof quantile, 'function', 'main export is a function' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js index a5907775251f..d7adb981ea54 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js @@ -40,7 +40,7 @@ var expected = data.expected; tape( 'main export is a function', function test( t ) { t.ok( true, __filename ); - t.strictEqual( typeof factory, 'function', 'main export is a function' ); + t.strictEqual( typeof quantile, 'function', 'main export is a function' ); t.end(); }); From 76453beb962dfe9418782b1673ec0e2ccc856e0d Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Tue, 13 Jan 2026 23:05:25 +0530 Subject: [PATCH 3/9] fix: addresses review 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: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - 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: 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: passed - task: lint_license_headers status: passed --- --- .../stats/base/dists/halfnormal/quantile/README.md | 12 ++++++------ .../dists/halfnormal/quantile/docs/types/index.d.ts | 8 ++++---- .../base/dists/halfnormal/quantile/lib/factory.js | 4 ++-- .../base/dists/halfnormal/quantile/lib/index.js | 2 +- .../stats/base/dists/halfnormal/quantile/src/main.c | 4 ++-- .../dists/halfnormal/quantile/test/test.factory.js | 2 +- .../dists/halfnormal/quantile/test/test.native.js | 2 +- .../dists/halfnormal/quantile/test/test.quantile.js | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md index 0aabe538192d..9c20e78973fc 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md @@ -24,16 +24,16 @@ limitations under the License.
-The [quantile function][quantile-function] for a [half-normal][halfnormal-distribution] random variable is +The [quantile function][quantile-function] for a [Half-normal][halfnormal-distribution] random variable is - + ```math Q(p;\sigma) = \sigma\sqrt{2}\,\mathop{\mathrm{erf}}^{-1}(p) ``` @@ -55,7 +55,7 @@ var quantile = require( '@stdlib/stats/base/dists/halfnormal/quantile' ); #### quantile( p, sigma ) -Evaluates the [quantile function][quantile-function] for a [half-normal][halfnormal-distribution] distribution with scale parameter `sigma`. +Evaluates the [quantile function][quantile-function] for a [Half-normal][halfnormal-distribution] distribution with scale parameter `sigma`. ```javascript var y = quantile( 0.5, 1.0 ); @@ -104,7 +104,7 @@ y = quantile( 0.9, 0.0 ); #### quantile.factory( sigma ) -Returns a function for evaluating the [quantile function][quantile-function] of a [half-normal][halfnormal-distribution] distribution with parameter `sigma`. +Returns a function for evaluating the [quantile function][quantile-function] of a [Half-normal][halfnormal-distribution] distribution with parameter `sigma`. ```javascript var myquantile = quantile.factory( 4.0 ); @@ -172,7 +172,7 @@ logEachMap( 'p: %lf, σ: %lf, Q(p;σ): %lf', p, sigma, quantile ); #### stdlib_base_dists_halfnormal_quantile( p, sigma ) -Evaluates the [quantile function][quantile-function] for a [half-normal][halfnormal-distribution] distribution with parameter `sigma` (scale). +Evaluates the [quantile function][quantile-function] for a [Half-normal][halfnormal-distribution] distribution with parameter `sigma` (scale). ```c double y = stdlib_base_dists_halfnormal_quantile( 0.8, 1.0 ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/index.d.ts index c29b0bd79da0..e9bc4b5266d9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/docs/types/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /** -* Evaluates the quantile function for a half-normal distribution. +* Evaluates the quantile function for a Half-normal distribution. * * @param p - cumulative probability * @returns evaluated quantile @@ -27,11 +27,11 @@ type Unary = ( p: number ) => number; /** -* Interface for the quantile function of a half-normal distribution. +* Interface for the quantile function of a Half-normal distribution. */ interface Quantile { /** - * Evaluates the quantile function for a half-normal distribution with scale parameter `sigma`. + * Evaluates the quantile function for a Half-normal distribution with scale parameter `sigma`. * * ## Notes * @@ -64,7 +64,7 @@ interface Quantile { ( p: number, sigma: number ): number; /** - * Returns a function for evaluating the quantile function for a half-normal distribution with scale parameter `sigma`. + * Returns a function for evaluating the quantile function for a Half-normal distribution with scale parameter `sigma`. * * @param sigma - scale parameter * @returns quantile function diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js index 2f927907ce35..9f5a1629f119 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js @@ -30,7 +30,7 @@ var PINF = require( '@stdlib/constants/float64/pinf' ); // MAIN // /** -* Returns a function for evaluating the quantile function for a half-normal distribution with scale parameter `sigma`. +* Returns a function for evaluating the quantile function for a Half-normal distribution with scale parameter `sigma`. * * @param {NonNegativeNumber} sigma - scale parameter * @returns {Function} quantile function @@ -53,7 +53,7 @@ function factory( sigma ) { return quantile; /** - * Evaluates the quantile function for a half-normal distribution. + * Evaluates the quantile function for a Half-normal distribution. * * @private * @param {Probability} p - input value diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js index e0fd755c376d..ab5461df0d39 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Halfnormal distribution quantile function. +* Half-normal distribution quantile function. * * @module @stdlib/stats/base/dists/halfnormal/quantile * diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/main.c index 094e4a450184..75646bd5b8d2 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/src/main.c @@ -42,10 +42,10 @@ double stdlib_base_dists_halfnormal_quantile( const double p, const double sigma ) { return 0.0 / 0.0; // NaN } - if( sigma == 0.0 ){ + if ( sigma == 0.0 ) { return 0.0; } - if( p == 1.0 ){ + if ( p == 1.0 ) { return 1.0 / 0.0; // +infinity } return sigma * STDLIB_CONSTANT_FLOAT64_SQRT2 * stdlib_base_erfinv( p ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js index 5a1b554d175b..0f0961ac02a2 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js @@ -86,7 +86,7 @@ tape( 'p = 1 returns +Infinity', function test( t ) { t.end(); }); -tape( 'the factory evaluates the half-normal quantile correctly', function test( t ) { +tape( 'the factory evaluates the Half-normal quantile correctly', function test( t ) { var delta; var tol; var q; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js index f76fa9a748e2..c2d45671affc 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js @@ -82,7 +82,7 @@ tape( 'p = 1 returns +Infinity', opts, function test( t ) { t.end(); }); -tape( 'the native function evaluates the half-normal quantile correctly', opts, function test( t ) { +tape( 'the native function evaluates the Half-normal quantile correctly', opts, function test( t ) { var delta; var tol; var y; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js index d7adb981ea54..2245271a4122 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js @@ -73,7 +73,7 @@ tape( 'p = 1 returns +Infinity', function test( t ) { t.end(); }); -tape( 'the function evaluates the half-normal quantile correctly', function test( t ) { +tape( 'the function evaluates the Half-normal quantile correctly', function test( t ) { var delta; var tol; var y; From 56fcf300ebd1e147297342037954067ca13d9091 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Tue, 13 Jan 2026 23:14:08 +0530 Subject: [PATCH 4/9] fix: copyright year fix --- 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - 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 --- --- .../stats/base/dists/halfnormal/quantile/benchmark/c/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/Makefile index a4bd7b38fd74..979768abbcec 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2025 The Stdlib Authors. +# Copyright (c) 2026 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. From 96e103e8e01adbe5166abd52219573a49e9de396 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Fri, 23 Jan 2026 17:32:59 +0530 Subject: [PATCH 5/9] fix: migrate from julia to python fixtures and minor style changes --- 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: passed - 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: 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: na - task: lint_license_headers status: passed --- --- .../base/dists/halfnormal/quantile/README.md | 8 +- .../quantile/benchmark/c/benchmark.c | 2 +- .../halfnormal/quantile/examples/index.js | 27 ++++--- .../stats/base/dists/halfnormal/quantile.h | 2 +- .../dists/halfnormal/quantile/lib/factory.js | 6 +- .../dists/halfnormal/quantile/lib/native.js | 1 + .../quantile/test/fixtures/julia/REQUIRE | 0 .../quantile/test/fixtures/julia/data.json | 1 - .../quantile/test/fixtures/julia/runner.jl | 64 --------------- .../quantile/test/fixtures/python/data.json | 1 + .../quantile/test/fixtures/python/runner.py | 80 +++++++++++++++++++ .../halfnormal/quantile/test/test.factory.js | 17 ++-- .../halfnormal/quantile/test/test.native.js | 13 +-- .../halfnormal/quantile/test/test.quantile.js | 13 +-- 14 files changed, 120 insertions(+), 115 deletions(-) delete mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/REQUIRE delete mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/data.json delete mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/runner.jl create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/data.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md index 9c20e78973fc..8bc627389413 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/README.md @@ -32,10 +32,6 @@ The [quantile function][quantile-function] for a [Half-normal][halfnormal-distri Q(p;\sigma) = \sigma\sqrt{2}\,\mathop{\mathrm{erf}}^{-1}(p) ``` - @@ -104,7 +100,7 @@ y = quantile( 0.9, 0.0 ); #### quantile.factory( sigma ) -Returns a function for evaluating the [quantile function][quantile-function] of a [Half-normal][halfnormal-distribution] distribution with parameter `sigma`. +Returns a function for evaluating the [quantile function][quantile-function] of a [Half-normal][halfnormal-distribution] distribution with scale parameter `sigma`. ```javascript var myquantile = quantile.factory( 4.0 ); @@ -172,7 +168,7 @@ logEachMap( 'p: %lf, σ: %lf, Q(p;σ): %lf', p, sigma, quantile ); #### stdlib_base_dists_halfnormal_quantile( p, sigma ) -Evaluates the [quantile function][quantile-function] for a [Half-normal][halfnormal-distribution] distribution with parameter `sigma` (scale). +Evaluates the [quantile function][quantile-function] for a [Half-normal][halfnormal-distribution] distribution with scale parameter `sigma` (scale). ```c double y = stdlib_base_dists_halfnormal_quantile( 0.8, 1.0 ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/benchmark.c index 50195b410ece..d8d4a3b4957b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/c/benchmark.c @@ -93,9 +93,9 @@ static double random_uniform( const double min, const double max ) { * @return elapsed time in seconds */ static double benchmark( void ) { - double elapsed; double p[ 100 ]; double sigma[ 100 ]; + double elapsed; double y; double t; int i; diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/index.js index 95e4060a12a3..e4c2878cb493 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/examples/index.js @@ -18,17 +18,20 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); +// MODULES // + +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var quantile = require( './../lib' ); -var i; -var p; -var sigma; -var y; - -for ( i = 0; i < 25; i++ ) { - p = randu(); // p in [0,1) - sigma = randu() * 3.0; // sigma >= 0 - y = quantile( p, sigma ); - console.log( 'p: %lf, σ: %lf, Q(p;σ): %lf', p, sigma, y ); -} + +// MAIN // + +var opts = { + 'dtype': 'float64' +}; + +var p = uniform( 25, 0.0, 1.0, opts ); +var sigma = uniform( 25, 0.0, 3.0, opts ); + +logEachMap( 'p: %lf, σ: %lf, Q(p;σ): %lf', p, sigma, quantile ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/include/stdlib/stats/base/dists/halfnormal/quantile.h b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/include/stdlib/stats/base/dists/halfnormal/quantile.h index 8220ed1c3569..487d2046da23 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/include/stdlib/stats/base/dists/halfnormal/quantile.h +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/include/stdlib/stats/base/dists/halfnormal/quantile.h @@ -27,7 +27,7 @@ extern "C" { #endif /** -* Evaluates the quantile function for a Half-Normal distribution with cumulative probability `p` and scale `sigma`. +* Evaluates the quantile function for a Half-Normal distribution with cumulative probability `p` and scale parameter `sigma`. */ double stdlib_base_dists_halfnormal_quantile( const double p, const double sigma ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js index 9f5a1629f119..4b808d093bfc 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/factory.js @@ -44,19 +44,21 @@ var PINF = require( '@stdlib/constants/float64/pinf' ); * // returns ~1.282 */ function factory( sigma ) { + var C; if ( isnan( sigma ) || sigma < 0.0 ) { return constantFunction( NaN ); } if ( sigma === 0.0 ) { return constantFunction( 0.0 ); } + C = sigma * SQRT2; return quantile; /** * Evaluates the quantile function for a Half-normal distribution. * * @private - * @param {Probability} p - input value + * @param {Probability} p - cumulative probability * @returns {number} evaluated quantile function * * @example @@ -70,7 +72,7 @@ function factory( sigma ) { if ( p === 1.0 ) { return PINF; } - return sigma * SQRT2 * erfinv( p ); + return C * erfinv( p ); } } diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/native.js index 4255bbd7b1fa..e00c213995d4 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/lib/native.js @@ -28,6 +28,7 @@ var addon = require( './../src/addon.node' ); /** * Evaluates the quantile function for a Half-Normal distribution with scale parameter `sigma` at a probability `p`. * +* @private * @param {Probability} p - cumulative probability * @param {NonNegativeNumber} sigma - scale parameter * @returns {number} evaluated quantile function diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/REQUIRE deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/data.json deleted file mode 100644 index 8eec56801a4c..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/data.json +++ /dev/null @@ -1 +0,0 @@ -{"sigma":[3.752372343198736,0.5952487736546558,3.3856198354728,1.3195086901125626,0.33660791776355947,3.0698228295251733,2.8333822017156756,0.842096233317226,0.9014208323745504,0.9645360412814957],"expected":[4.115703132034415,0.4368820501703096,3.423273300043822,0.6971282572460012,0.27955804839293547,0.6442160951563007,2.626768194061231,0.24752155341315513,0.04330086356582894,1.155323910174928],"p":[0.7272829554760867,0.5370199818842734,0.6880417602571298,0.40272560115812794,0.5937525368951077,0.1662187547190921,0.6461143084421898,0.23119242465068246,0.038312635981986976,0.7690061785566936]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/runner.jl deleted file mode 100644 index 8f5dfec5906d..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/julia/runner.jl +++ /dev/null @@ -1,64 +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. - -using Distributions -using SpecialFunctions # for erfinv -using JSON - -""" - gen(p, sigma, name) - -Generate Half-Normal quantile fixture data. - -# Arguments -- `p`: probability values (0 ≤ p ≤ 1) -- `sigma`: scale parameters (σ ≥ 0) -- `name`: output filename -""" -function gen(p, sigma, name) - z = Array{Float64}(undef, length(p)) - for i in eachindex(p) - # Half-normal quantile: - # Q(p) = sigma * sqrt(2) * erfinv(p) - z[i] = sigma[i] * sqrt(2.0) * erfinv(p[i]) - end - - data = Dict( - "p" => p, - "sigma" => sigma, - "expected" => z - ) - - filepath = joinpath(dir, name) - open(filepath, "w") do f - write(f, JSON.json(data)) - write(f, "\n") - end -end - -# Directory of this script -file = @__FILE__ -dir = dirname(file) - -# Generate random test values -N = 10 -p = rand(N) # in (0,1) -sigma = rand(N) .* 5.0 # σ in [0,5) - -# Write a single data file -gen(p, sigma, "data.json") diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/data.json b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/data.json new file mode 100644 index 000000000000..2c75ffb4b07d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/data.json @@ -0,0 +1 @@ +{"p": [0.9774893766311928, 0.3303611508495079, 0.8131521683757337, 0.6693264455728574, 0.3685658595631208, 0.26035691800918415, 0.6591743418377072, 0.637147796808677, 0.3423370738469663, 0.24685816886607803], "sigma": [3.033632737920289, 3.2664388791085726, 2.2676544546611432, 0.7448037297348742, 4.17093786683222, 1.4259184016029536, 1.8265179135368266, 4.417846025457937, 1.3142239404712563, 4.252133347147264], "expected": [6.921656759847963, 1.3936056319137575, 2.993216852835478, 0.7245138419078899, 2.000837529764881, 0.47386981031578596, 1.7398224792397319, 4.019991146929366, 0.5823880100553026, 1.3372930558009646]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py new file mode 100644 index 000000000000..756ccc1d1708 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py @@ -0,0 +1,80 @@ +#!/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(p, sigma, name): + """Generate fixture data and write to file. + + # Arguments + + * `p`: probability values (0 ≤ p ≤ 1) + * `sigma`: scale parameters (σ ≥ 0) + * `name::str`: output filename + + # Examples + + ``` python + python> p = np.random.rand(10) + python> sigma = np.random.rand(10) * 5.0 + python> gen(p, sigma, './data.json') + ``` + """ + # Compute half-normal quantiles using SciPy: + y = halfnorm.ppf(p, scale=sigma) + + # Store data to be written to file as a dictionary: + data = { + "p": p.tolist(), + "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.""" + # Generate random test values: + N = 10 + p = np.random.rand(N) # in (0,1) + sigma = np.random.rand(N) * 5.0 # σ in [0,5) + + gen(p, sigma, "data.json") + + +if __name__ == "__main__": + main() diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js index 0f0961ac02a2..f68179f67489 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js @@ -22,15 +22,14 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); var PINF = require( '@stdlib/constants/float64/pinf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var factory = require( './../lib/factory.js' ); // FIXTURES // -var data = require( './fixtures/julia/data.json' ); +var data = require( './fixtures/python/data.json' ); var p = data.p; var sigma = data.sigma; var expected = data.expected; @@ -87,20 +86,18 @@ tape( 'p = 1 returns +Infinity', function test( t ) { }); tape( 'the factory evaluates the Half-normal quantile correctly', function test( t ) { - var delta; - var tol; + var y; var q; var i; for ( i = 0; i < p.length; i++ ) { q = factory( sigma[i] ); if ( expected[i] !== null ) { - if ( q( p[i] ) === expected[i] ) { - t.strictEqual( q( p[i] ), expected[i], 'exact match' ); + y = q( p[i] ); + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( q( p[i] ) - expected[i] ); - tol = 40.0 * EPS * abs( expected[i] ); - t.ok(delta <= tol, 'p: '+p[i]+', sigma: '+sigma[i]+', q: '+q(p[i])+', expected: '+expected[i]); + t.ok( isAlmostSameValue( y, expected[ i ], 40.0 ), 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); } } } diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js index c2d45671affc..71f5c42d878b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js @@ -24,9 +24,8 @@ 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 isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var PINF = require( '@stdlib/constants/float64/pinf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); // VARIABLES // @@ -39,7 +38,7 @@ var opts = { // FIXTURES // -var data = require( './fixtures/julia/data.json' ); +var data = require( './fixtures/python/data.json' ); var p = data.p; var sigma = data.sigma; var expected = data.expected; @@ -83,8 +82,6 @@ tape( 'p = 1 returns +Infinity', opts, function test( t ) { }); tape( 'the native function evaluates the Half-normal quantile correctly', opts, function test( t ) { - var delta; - var tol; var y; var i; @@ -92,11 +89,9 @@ tape( 'the native function evaluates the Half-normal quantile correctly', opts, y = quantile( p[i], sigma[i] ); if ( expected[i] !== null ) { if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'exact match' ); + t.strictEqual( y, expected[i], 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = 40.0 * EPS * abs( expected[i] ); - t.ok(delta <= tol, 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i]); + t.ok( isAlmostSameValue( y, expected[ i ], 40.0 ), 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); } } } diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js index 2245271a4122..25bbe289f928 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js @@ -22,15 +22,14 @@ var tape = require( 'tape' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var abs = require( '@stdlib/math/base/special/abs' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var PINF = require( '@stdlib/constants/float64/pinf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var quantile = require( './../lib' ); // FIXTURES // -var data = require( './fixtures/julia/data.json' ); +var data = require( './fixtures/python/data.json' ); var p = data.p; var sigma = data.sigma; var expected = data.expected; @@ -74,8 +73,6 @@ tape( 'p = 1 returns +Infinity', function test( t ) { }); tape( 'the function evaluates the Half-normal quantile correctly', function test( t ) { - var delta; - var tol; var y; var i; @@ -83,11 +80,9 @@ tape( 'the function evaluates the Half-normal quantile correctly', function test y = quantile( p[i], sigma[i] ); if ( expected[i] !== null ) { if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'exact match' ); + t.strictEqual( y, expected[i], 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); } else { - delta = abs( y - expected[i] ); - tol = 40.0 * EPS * abs( expected[i] ); - t.ok(delta <= tol, 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i]); + t.ok( isAlmostSameValue( y, expected[ i ], 40.0 ), 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); } } } From 5e852362e8cdc9596152e6ea9ce5cf1c454f5d46 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Fri, 23 Jan 2026 17:53:35 +0530 Subject: [PATCH 6/9] fix: pylint lint fix --- 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: na - 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 --- --- .../halfnormal/quantile/test/fixtures/python/runner.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py index 756ccc1d1708..6e861961fd48 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py @@ -69,9 +69,9 @@ def gen(p, sigma, name): def main(): """Generate fixture data.""" # Generate random test values: - N = 10 - p = np.random.rand(N) # in (0,1) - sigma = np.random.rand(N) * 5.0 # σ in [0,5) + n = 10 + p = np.random.rand(n) # in (0,1) + sigma = np.random.rand(n) * 5.0 # σ in [0,5) gen(p, sigma, "data.json") From bfd2be471105113d753eed2557de3651e9010d0e Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Fri, 23 Jan 2026 18:41:17 +0530 Subject: [PATCH 7/9] fix: using random/array/uniform , format and addressing remaining testfile 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: 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: passed - task: lint_python status: passed - 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 --- --- .../quantile/benchmark/benchmark.js | 20 ++++++------------- .../quantile/benchmark/benchmark.native.js | 15 +++++--------- .../quantile/test/fixtures/python/runner.py | 2 +- .../halfnormal/quantile/test/test.factory.js | 9 ++++++--- .../halfnormal/quantile/test/test.native.js | 9 ++++++--- .../halfnormal/quantile/test/test.quantile.js | 9 ++++++--- 6 files changed, 30 insertions(+), 34 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.js index 2815ef3fd5c8..6525141cbc1e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.js @@ -21,10 +21,9 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var EPS = require( '@stdlib/constants/float64/eps' ); +var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var quantile = require( './../lib' ); @@ -39,12 +38,8 @@ bench( pkg, function benchmark( b ) { var i; len = 100; - p = new Float64Array( len ); - sigma = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - p[ i ] = uniform( 0.0, 1.0 ); - sigma[ i ] = uniform( EPS, 20.0 ); - } + p = uniform( 100, 0.0, 1.0 ); + sigma = uniform( 100, 0.0, 20.0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { @@ -61,7 +56,7 @@ bench( pkg, function benchmark( b ) { b.end(); }); -bench( pkg+':factory', function benchmark( b ) { +bench( format( '%s::factory', pkg ), function benchmark( b ) { var myquantile; var sigma; var len; @@ -72,10 +67,7 @@ bench( pkg+':factory', function benchmark( b ) { sigma = 4.0; myquantile = quantile.factory( sigma ); len = 100; - p = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - p[ i ] = uniform( 0.0, 1.0 ); - } + p = uniform( 100, 0.0, 1.0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.native.js index 6e7ed876ec0a..1e4fdacbb84d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/benchmark/benchmark.native.js @@ -22,11 +22,10 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); +var uniform = require( '@stdlib/random/array/uniform' ); var tryRequire = require( '@stdlib/utils/try-require' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var format = require( '@stdlib/string/format' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var pkg = require( './../package.json' ).name; @@ -40,7 +39,7 @@ var opts = { // MAIN // -bench( pkg+'::native', opts, function benchmark( b ) { +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { var sigma; var len; var p; @@ -48,12 +47,8 @@ bench( pkg+'::native', opts, function benchmark( b ) { var i; len = 100; - p = new Float64Array( len ); - sigma = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - p[ i ] = uniform( 0.0, 1.0 ); - sigma[ i ] = uniform( EPS, 20.0 ); - } + p = uniform( 100, 0.0, 1.0 ); + sigma = uniform( 100, 0.0, 20.0 ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py index 6e861961fd48..f55d5b02fe0b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/fixtures/python/runner.py @@ -71,7 +71,7 @@ def main(): # Generate random test values: n = 10 p = np.random.rand(n) # in (0,1) - sigma = np.random.rand(n) * 5.0 # σ in [0,5) + sigma = np.random.rand(n) * 5.0 # σ in [0,5) gen(p, sigma, "data.json") diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js index f68179f67489..b40716ba99c0 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js @@ -30,9 +30,6 @@ var factory = require( './../lib/factory.js' ); // FIXTURES // var data = require( './fixtures/python/data.json' ); -var p = data.p; -var sigma = data.sigma; -var expected = data.expected; // TESTS // @@ -86,10 +83,16 @@ tape( 'p = 1 returns +Infinity', function test( t ) { }); tape( 'the factory evaluates the Half-normal quantile correctly', function test( t ) { + var expected; + var sigma; var y; var q; var i; + var p; + p = data.p; + sigma = data.sigma; + expected = data.expected; for ( i = 0; i < p.length; i++ ) { q = factory( sigma[i] ); if ( expected[i] !== null ) { diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js index 71f5c42d878b..6d1530883d55 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js @@ -39,9 +39,6 @@ var opts = { // FIXTURES // var data = require( './fixtures/python/data.json' ); -var p = data.p; -var sigma = data.sigma; -var expected = data.expected; // TESTS // @@ -82,9 +79,15 @@ tape( 'p = 1 returns +Infinity', opts, function test( t ) { }); tape( 'the native function evaluates the Half-normal quantile correctly', opts, function test( t ) { + var expected; + var sigma; var y; var i; + var p; + p = data.p; + sigma = data.sigma; + expected = data.expected; for ( i = 0; i < p.length; i++ ) { y = quantile( p[i], sigma[i] ); if ( expected[i] !== null ) { diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js index 25bbe289f928..77451f2e1570 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js @@ -30,9 +30,6 @@ var quantile = require( './../lib' ); // FIXTURES // var data = require( './fixtures/python/data.json' ); -var p = data.p; -var sigma = data.sigma; -var expected = data.expected; // TESTS // @@ -73,9 +70,15 @@ tape( 'p = 1 returns +Infinity', function test( t ) { }); tape( 'the function evaluates the Half-normal quantile correctly', function test( t ) { + var expected; + var sigma; var y; var i; + var p; + p = data.p; + sigma = data.sigma; + expected = data.expected; for ( i = 0; i < p.length; i++ ) { y = quantile( p[i], sigma[i] ); if ( expected[i] !== null ) { From 163cafbb569641daf4f10b09f110f4dae864a8c5 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Sun, 25 Jan 2026 17:00:24 +0530 Subject: [PATCH 8/9] 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: 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: na - 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 --- --- .../halfnormal/quantile/test/test.factory.js | 30 ++++++++----------- .../halfnormal/quantile/test/test.native.js | 28 ++++++++--------- .../halfnormal/quantile/test/test.quantile.js | 28 ++++++++--------- 3 files changed, 37 insertions(+), 49 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js index b40716ba99c0..46aceb4a852b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js @@ -46,43 +46,43 @@ tape( 'factory returns a function', function test( t ) { t.end(); }); -tape( 'if sigma is NaN or < 0, returned function always returns NaN', function test( t ) { +tape( 'if sigma is NaN or sigma < 0, returned function always returns NaN', function test( t ) { var q; q = factory( NaN ); - t.ok( isnan( q( 0.5 ) ), 'sigma NaN' ); + t.ok( isnan( q( 0.5 ) ), 'returns expected value' ); q = factory( -1.0 ); - t.ok( isnan( q( 0.5 ) ), 'sigma < 0' ); + t.ok( isnan( q( 0.5 ) ), 'returns expected value' ); t.end(); }); tape( 'if sigma = 0, quantile always returns 0', function test( t ) { var q = factory( 0.0 ); - t.strictEqual( q( 0.0 ), 0.0 ); - t.strictEqual( q( 0.5 ), 0.0 ); - t.strictEqual( q( 1.0 ), 0.0 ); + t.strictEqual( q( 0.0 ), 0.0, 'returns expected value' ); + t.strictEqual( q( 0.5 ), 0.0, 'returns expected value' ); + t.strictEqual( q( 1.0 ), 0.0, 'returns expected value' ); t.end(); }); tape( 'if p < 0, p > 1, or p is NaN, quantile returns NaN', function test( t ) { var q = factory( 1.0 ); - t.ok( isnan( q( -0.1 ) ), 'p < 0' ); - t.ok( isnan( q( 1.1 ) ), 'p > 1' ); - t.ok( isnan( q( NaN ) ), 'p NaN' ); + t.ok( isnan( q( -0.1 ) ), 'returns expected value' ); + t.ok( isnan( q( 1.1 ) ), 'returns expected value' ); + t.ok( isnan( q( NaN ) ), 'returns expected value' ); t.end(); }); -tape( 'p = 1 returns +Infinity', function test( t ) { +tape( 'if p = 1, the function returns positive infinity', function test( t ) { var q = factory( 1.0 ); - t.strictEqual( q( 1.0 ), PINF, 'returns +Infinity' ); + t.strictEqual( q( 1.0 ), PINF, 'returns expected value' ); t.end(); }); -tape( 'the factory evaluates the Half-normal quantile correctly', function test( t ) { +tape( 'the factory evaluates the half-normal quantile', function test( t ) { var expected; var sigma; var y; @@ -97,11 +97,7 @@ tape( 'the factory evaluates the Half-normal quantile correctly', function test( q = factory( sigma[i] ); if ( expected[i] !== null ) { y = q( p[i] ); - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); - } else { - t.ok( isAlmostSameValue( y, expected[ i ], 40.0 ), 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 40.0 ), true, 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); } } t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js index 6d1530883d55..03f9ff47b9cf 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js @@ -50,35 +50,35 @@ tape( 'main export is a function', function test( t ) { }); tape( 'if any argument is NaN, the function returns NaN', opts, function test( t ) { - t.ok( isnan( quantile( NaN, 1.0 ) ), 'p NaN' ); - t.ok( isnan( quantile( 0.5, NaN ) ), 'sigma NaN' ); + t.ok( isnan( quantile( NaN, 1.0 ) ), 'returns expected value' ); + t.ok( isnan( quantile( 0.5, NaN ) ), 'returns expected value' ); t.end(); }); tape( 'if p is outside [0,1], the function returns NaN', opts, function test( t ) { - t.ok( isnan( quantile( -0.1, 1.0 ) ), 'p < 0' ); - t.ok( isnan( quantile( 1.1, 1.0 ) ), 'p > 1' ); + t.ok( isnan( quantile( -0.1, 1.0 ) ), 'returns expected value' ); + t.ok( isnan( quantile( 1.1, 1.0 ) ), 'returns expected value' ); t.end(); }); tape( 'if sigma < 0, the function returns NaN', opts, function test( t ) { - t.ok( isnan( quantile( 0.5, -1.0 ) ), 'negative sigma' ); + t.ok( isnan( quantile( 0.5, -1.0 ) ), 'returns expected value' ); t.end(); }); tape( 'if sigma = 0, the quantile is 0 for all p', opts, function test( t ) { - t.strictEqual( quantile( 0.0, 0.0 ), 0.0 ); - t.strictEqual( quantile( 0.5, 0.0 ), 0.0 ); - t.strictEqual( quantile( 1.0, 0.0 ), 0.0 ); + t.strictEqual( quantile( 0.0, 0.0 ), 0.0, 'returns expected value' ); + t.strictEqual( quantile( 0.5, 0.0 ), 0.0, 'returns expected value' ); + t.strictEqual( quantile( 1.0, 0.0 ), 0.0, 'returns expected value' ); t.end(); }); -tape( 'p = 1 returns +Infinity', opts, function test( t ) { - t.strictEqual( quantile( 1.0, 1.0 ), PINF ); +tape( 'if p = 1, the function returns positive infinity', opts, function test( t ) { + t.strictEqual( quantile( 1.0, 1.0 ), PINF, 'returns expected value' ); t.end(); }); -tape( 'the native function evaluates the Half-normal quantile correctly', opts, function test( t ) { +tape( 'the native function evaluates the half-normal quantile', opts, function test( t ) { var expected; var sigma; var y; @@ -91,11 +91,7 @@ tape( 'the native function evaluates the Half-normal quantile correctly', opts, for ( i = 0; i < p.length; i++ ) { y = quantile( p[i], sigma[i] ); if ( expected[i] !== null ) { - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); - } else { - t.ok( isAlmostSameValue( y, expected[ i ], 40.0 ), 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 40.0 ), true, 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); } } t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js index 77451f2e1570..a96bf947b775 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js @@ -41,35 +41,35 @@ tape( 'main export is a function', function test( t ) { }); tape( 'if any argument is NaN, the function returns NaN', function test( t ) { - t.ok( isnan( quantile( NaN, 1.0 ) ), 'p NaN' ); - t.ok( isnan( quantile( 0.5, NaN ) ), 'sigma NaN' ); + t.ok( isnan( quantile( NaN, 1.0 ) ), 'returns expected value' ); + t.ok( isnan( quantile( 0.5, NaN ) ), 'returns expected value' ); t.end(); }); tape( 'if p is outside [0,1], the function returns NaN', function test( t ) { - t.ok( isnan( quantile( -0.1, 1.0 ) ), 'p < 0' ); - t.ok( isnan( quantile( 1.1, 1.0 ) ), 'p > 1' ); + t.ok( isnan( quantile( -0.1, 1.0 ) ), 'returns expected value' ); + t.ok( isnan( quantile( 1.1, 1.0 ) ), 'returns expected value' ); t.end(); }); tape( 'if sigma < 0, the function returns NaN', function test( t ) { - t.ok( isnan( quantile( 0.5, -1.0 ) ), 'negative sigma' ); + t.ok( isnan( quantile( 0.5, -1.0 ) ), 'returns expected value' ); t.end(); }); tape( 'if sigma = 0, the quantile is 0 for all p', function test( t ) { - t.strictEqual( quantile( 0.0, 0.0 ), 0.0 ); - t.strictEqual( quantile( 0.5, 0.0 ), 0.0 ); - t.strictEqual( quantile( 1.0, 0.0 ), 0.0 ); + t.strictEqual( quantile( 0.0, 0.0 ), 0.0, 'returns expected value' ); + t.strictEqual( quantile( 0.5, 0.0 ), 0.0, 'returns expected value' ); + t.strictEqual( quantile( 1.0, 0.0 ), 0.0, 'returns expected value' ); t.end(); }); -tape( 'p = 1 returns +Infinity', function test( t ) { - t.strictEqual( quantile( 1.0, 1.0 ), PINF ); +tape( 'if p = 1, the function returns positive infinity', function test( t ) { + t.strictEqual( quantile( 1.0, 1.0 ), PINF, 'returns expected value' ); t.end(); }); -tape( 'the function evaluates the Half-normal quantile correctly', function test( t ) { +tape( 'the function evaluates the half-normal quantile', function test( t ) { var expected; var sigma; var y; @@ -82,11 +82,7 @@ tape( 'the function evaluates the Half-normal quantile correctly', function test for ( i = 0; i < p.length; i++ ) { y = quantile( p[i], sigma[i] ); if ( expected[i] !== null ) { - if ( y === expected[i] ) { - t.strictEqual( y, expected[i], 'p: '+p[i]+', sigma: '+sigma[i]+', y: '+y+', expected: '+expected[i] ); - } else { - t.ok( isAlmostSameValue( y, expected[ i ], 40.0 ), 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); - } + t.strictEqual( isAlmostSameValue( y, expected[ i ], 40.0 ), true, 'within tolerance. p: '+p[ i ]+'. sigma: '+sigma[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'.' ); } } t.end(); From a94a01f42077f75f309ab98b651affb4b9f3d011 Mon Sep 17 00:00:00 2001 From: Om-A-osc Date: Thu, 29 Jan 2026 00:46:37 +0530 Subject: [PATCH 9/9] fix: addressing t.strictEqual in test files --- 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: na - 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 --- --- .../dists/halfnormal/quantile/test/test.factory.js | 10 +++++----- .../base/dists/halfnormal/quantile/test/test.native.js | 10 +++++----- .../dists/halfnormal/quantile/test/test.quantile.js | 10 +++++----- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js index 46aceb4a852b..bd57c3dd41cc 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.factory.js @@ -50,10 +50,10 @@ tape( 'if sigma is NaN or sigma < 0, returned function always returns NaN', func var q; q = factory( NaN ); - t.ok( isnan( q( 0.5 ) ), 'returns expected value' ); + t.strictEqual( isnan( q( 0.5 ) ), true, 'returns expected value' ); q = factory( -1.0 ); - t.ok( isnan( q( 0.5 ) ), 'returns expected value' ); + t.strictEqual( isnan( q( 0.5 ) ), true, 'returns expected value' ); t.end(); }); @@ -69,9 +69,9 @@ tape( 'if sigma = 0, quantile always returns 0', function test( t ) { tape( 'if p < 0, p > 1, or p is NaN, quantile returns NaN', function test( t ) { var q = factory( 1.0 ); - t.ok( isnan( q( -0.1 ) ), 'returns expected value' ); - t.ok( isnan( q( 1.1 ) ), 'returns expected value' ); - t.ok( isnan( q( NaN ) ), 'returns expected value' ); + t.strictEqual( isnan( q( -0.1 ) ), true, 'returns expected value' ); + t.strictEqual( isnan( q( 1.1 ) ), true, 'returns expected value' ); + t.strictEqual( isnan( q( NaN ) ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js index 03f9ff47b9cf..e118a381b5f1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.native.js @@ -50,19 +50,19 @@ tape( 'main export is a function', function test( t ) { }); tape( 'if any argument is NaN, the function returns NaN', opts, function test( t ) { - t.ok( isnan( quantile( NaN, 1.0 ) ), 'returns expected value' ); - t.ok( isnan( quantile( 0.5, NaN ) ), 'returns expected value' ); + t.strictEqual( isnan( quantile( NaN, 1.0 ) ), true, 'returns expected value' ); + t.strictEqual( isnan( quantile( 0.5, NaN ) ), true, 'returns expected value' ); t.end(); }); tape( 'if p is outside [0,1], the function returns NaN', opts, function test( t ) { - t.ok( isnan( quantile( -0.1, 1.0 ) ), 'returns expected value' ); - t.ok( isnan( quantile( 1.1, 1.0 ) ), 'returns expected value' ); + t.strictEqual( isnan( quantile( -0.1, 1.0 ) ), true, 'returns expected value' ); + t.strictEqual( isnan( quantile( 1.1, 1.0 ) ), true, 'returns expected value' ); t.end(); }); tape( 'if sigma < 0, the function returns NaN', opts, function test( t ) { - t.ok( isnan( quantile( 0.5, -1.0 ) ), 'returns expected value' ); + t.strictEqual( isnan( quantile( 0.5, -1.0 ) ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js index a96bf947b775..e2e5e9d420c1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js +++ b/lib/node_modules/@stdlib/stats/base/dists/halfnormal/quantile/test/test.quantile.js @@ -41,19 +41,19 @@ tape( 'main export is a function', function test( t ) { }); tape( 'if any argument is NaN, the function returns NaN', function test( t ) { - t.ok( isnan( quantile( NaN, 1.0 ) ), 'returns expected value' ); - t.ok( isnan( quantile( 0.5, NaN ) ), 'returns expected value' ); + t.strictEqual( isnan( quantile( NaN, 1.0 ) ), true, 'returns expected value' ); + t.strictEqual( isnan( quantile( 0.5, NaN ) ), true, 'returns expected value' ); t.end(); }); tape( 'if p is outside [0,1], the function returns NaN', function test( t ) { - t.ok( isnan( quantile( -0.1, 1.0 ) ), 'returns expected value' ); - t.ok( isnan( quantile( 1.1, 1.0 ) ), 'returns expected value' ); + t.strictEqual( isnan( quantile( -0.1, 1.0 ) ), true, 'returns expected value' ); + t.strictEqual( isnan( quantile( 1.1, 1.0 ) ), true, 'returns expected value' ); t.end(); }); tape( 'if sigma < 0, the function returns NaN', function test( t ) { - t.ok( isnan( quantile( 0.5, -1.0 ) ), 'returns expected value' ); + t.strictEqual( isnan( quantile( 0.5, -1.0 ) ), true, 'returns expected value' ); t.end(); });