From 79dbff5b9cb63db9e18fa5b53d357268aaca691c Mon Sep 17 00:00:00 2001 From: Neeraj Date: Tue, 28 Jul 2026 17:05:52 +0530 Subject: [PATCH] feat: add stats/base/dists/log-logistic/stdev --- 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_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - 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/log-logistic/stdev/README.md | 257 ++++++++++++++++++ .../log-logistic/stdev/benchmark/benchmark.js | 59 ++++ .../stdev/benchmark/benchmark.native.js | 69 +++++ .../log-logistic/stdev/benchmark/c/Makefile | 146 ++++++++++ .../stdev/benchmark/c/benchmark.c | 140 ++++++++++ .../base/dists/log-logistic/stdev/binding.gyp | 170 ++++++++++++ .../dists/log-logistic/stdev/docs/repl.txt | 44 +++ .../log-logistic/stdev/docs/types/index.d.ts | 66 +++++ .../log-logistic/stdev/docs/types/test.ts | 56 ++++ .../log-logistic/stdev/examples/c/Makefile | 146 ++++++++++ .../log-logistic/stdev/examples/c/example.c | 40 +++ .../log-logistic/stdev/examples/index.js | 31 +++ .../dists/log-logistic/stdev/include.gypi | 53 ++++ .../stats/base/dists/log-logistic/stdev.h | 38 +++ .../dists/log-logistic/stdev/lib/index.js | 43 +++ .../base/dists/log-logistic/stdev/lib/main.js | 87 ++++++ .../dists/log-logistic/stdev/lib/native.js | 71 +++++ .../dists/log-logistic/stdev/manifest.json | 86 ++++++ .../dists/log-logistic/stdev/package.json | 71 +++++ .../dists/log-logistic/stdev/src/Makefile | 70 +++++ .../base/dists/log-logistic/stdev/src/addon.c | 22 ++ .../base/dists/log-logistic/stdev/src/main.c | 52 ++++ .../stdev/test/fixtures/julia/REQUIRE | 3 + .../stdev/test/fixtures/julia/data.json | 1 + .../stdev/test/fixtures/julia/runner.jl | 72 +++++ .../dists/log-logistic/stdev/test/test.js | 118 ++++++++ .../log-logistic/stdev/test/test.native.js | 127 +++++++++ 27 files changed, 2138 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/include/stdlib/stats/base/dists/log-logistic/stdev.h create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/REQUIRE create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/data.json create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/runner.jl create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/README.md b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/README.md new file mode 100644 index 000000000000..a6e5ad82981d --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/README.md @@ -0,0 +1,257 @@ + + +# Standard Deviation + +> [Log-logistic][log-logistic-distribution] distribution [standard deviation][standard-deviation]. + +
+ +The [standard deviation][standard-deviation] for a [log-logistic][log-logistic-distribution] random variable with scale `α > 0` and shape `β > 2` is + + + +```math +\sigma = \alpha \sqrt{ \frac{2b}{\sin 2b} - \frac{b^2}{\sin^2 b} }, \quad b = \frac{\pi}{\beta} +``` + + + +where `b = π/β`. + +
+ + + + + +
+ +## Usage + +```javascript +var stdev = require( '@stdlib/stats/base/dists/log-logistic/stdev' ); +``` + +#### stdev( alpha, beta ) + +Returns the [standard deviation][standard-deviation] of a [log-logistic][log-logistic-distribution] distribution with scale parameter `alpha` and shape parameter `beta`. + +```javascript +var y = stdev( 1.0, 3.0 ); +// returns ~0.978 + +y = stdev( 4.0, 3.0 ); +// returns ~3.911 + +y = stdev( 2.0, 5.0 ); +// returns ~0.845 +``` + +If provided `NaN` as any argument, the function returns `NaN`. + +```javascript +var y = stdev( NaN, 3.0 ); +// returns NaN + +y = stdev( 1.0, NaN ); +// returns NaN +``` + +If provided `alpha <= 0`, the function returns `NaN`. + +```javascript +var y = stdev( 0.0, 3.0 ); +// returns NaN + +y = stdev( -1.0, 3.0 ); +// returns NaN +``` + +If provided `beta <= 2`, the function returns `NaN`. + +```javascript +var y = stdev( 2.0, 2.0 ); +// returns NaN + +y = stdev( 2.0, 1.5 ); +// returns NaN +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var stdev = require( '@stdlib/stats/base/dists/log-logistic/stdev' ); + +var opts = { + 'dtype': 'float64' +}; +var alpha = uniform( 10, 0.1, 10.0, opts ); +var beta = uniform( 10, 2.1, 10.0, opts ); + +logEachMap( 'α: %0.4f, β: %0.4f, SD(X;α,β): %0.4f', alpha, beta, stdev ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/log-logistic/stdev.h" +``` + +#### stdlib_base_dists_log_logistic_stdev( alpha, beta ) + +Returns the standard deviation of a log-logistic distribution with scale parameter `alpha` and shape parameter `beta`. + +```c +double out = stdlib_base_dists_log_logistic_stdev( 1.0, 3.0 ); +// returns ~0.978 +``` + +The function accepts the following arguments: + +- **alpha**: `[in] double` scale parameter. +- **beta**: `[in] double` shape parameter. + +```c +double stdlib_base_dists_log_logistic_stdev( const double alpha, const double beta ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/log-logistic/stdev.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 alpha; + double beta; + double v; + int i; + + for ( i = 0; i < 25; i++ ) { + alpha = random_uniform( 0.1, 10.0 ); + beta = random_uniform( 2.1, 10.0 ); + v = stdlib_base_dists_log_logistic_stdev( alpha, beta ); + printf( "α: %lf, β: %lf, SD(X;α,β): %lf\n", alpha, beta, v ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/benchmark.js new file mode 100644 index 000000000000..6e57c6538373 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/benchmark.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var pkg = require( './../package.json' ).name; +var stdev = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var alpha; + var beta; + var opts; + var y; + var i; + + opts = { + 'dtype': 'float64' + }; + alpha = uniform( 100, EPS, 10.0, opts ); + beta = uniform( 100, 2.1, 10.0, opts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = stdev( alpha[ i % alpha.length ], beta[ i % beta.length ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/benchmark.native.js new file mode 100644 index 000000000000..47a478e3474e --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/benchmark.native.js @@ -0,0 +1,69 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +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; + + +// VARIABLES // + +var stdev = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( stdev instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native', pkg ), opts, function benchmark( b ) { + var arrayOpts; + var alpha; + var beta; + var y; + var i; + + arrayOpts = { + 'dtype': 'float64' + }; + alpha = uniform( 100, EPS, 10.0, arrayOpts ); + beta = uniform( 100, 2.1, 10.0, arrayOpts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = stdev( alpha[ i % alpha.length ], beta[ i % beta.length ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/c/Makefile new file mode 100644 index 000000000000..979768abbcec --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/c/benchmark.c new file mode 100644 index 000000000000..c82a88c33e0c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/benchmark/c/benchmark.c @@ -0,0 +1,140 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dists/log-logistic/stdev.h" +#include "stdlib/constants/float64/eps.h" +#include +#include +#include +#include +#include + +#define NAME "log-logistic-stdev" +#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 ); + 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 alpha[ 100 ]; + double beta[ 100 ]; + double elapsed; + double y; + double t; + int i; + + for ( i = 0; i < 100; i++ ) { + alpha[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 ); + beta[ i ] = random_uniform( 2.1, 10.0 ); + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + y = stdlib_base_dists_log_logistic_stdev( alpha[ i % 100 ], beta[ 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; + + 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/log-logistic/stdev/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/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/log-logistic/stdev/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/repl.txt new file mode 100644 index 000000000000..fbe80dbb8b81 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/repl.txt @@ -0,0 +1,44 @@ + +{{alias}}( α, β ) + Returns the standard deviation of a log-logistic distribution with scale + parameter `α` and shape parameter `β`. + + If provided `NaN` as any argument, the function returns `NaN`. + + If provided `α <= 0`, the function returns `NaN`. + + If provided `β <= 2`, the function returns `NaN`. + + Parameters + ---------- + α: number + Scale parameter. + + β: number + Shape parameter. + + Returns + ------- + out: number + Standard deviation. + + Examples + -------- + > var y = {{alias}}( 1.0, 3.0 ) + ~0.978 + > y = {{alias}}( 4.0, 3.0 ) + ~3.911 + > y = {{alias}}( 1.0, 2.0 ) + NaN + > y = {{alias}}( NaN, 3.0 ) + NaN + > y = {{alias}}( 2.0, NaN ) + NaN + > y = {{alias}}( -1.0, 3.0 ) + NaN + > y = {{alias}}( 2.0, -1.0 ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/types/index.d.ts new file mode 100644 index 000000000000..4801a81bb0a1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/types/index.d.ts @@ -0,0 +1,66 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Returns the standard deviation of a log-logistic distribution with scale parameter `alpha` and shape parameter `beta`. +* +* ## Notes +* +* - If provided `alpha <= 0`, the function returns `NaN`. +* - If provided `beta <= 2`, the function returns `NaN`. +* +* @param alpha - scale parameter +* @param beta - shape parameter +* @returns standard deviation +* +* @example +* var y = stdev( 1.0, 3.0 ); +* // returns ~0.978 +* +* @example +* var y = stdev( 4.0, 3.0 ); +* // returns ~3.911 +* +* @example +* var y = stdev( 1.0, 2.0 ); +* // returns NaN +* +* @example +* var y = stdev( NaN, 3.0 ); +* // returns NaN +* +* @example +* var y = stdev( 2.0, NaN ); +* // returns NaN +* +* @example +* var y = stdev( -1.0, 3.0 ); +* // returns NaN +* +* @example +* var y = stdev( 2.0, -1.0 ); +* // returns NaN +*/ +declare function stdev( alpha: number, beta: number ): number; + + +// EXPORTS // + +export = stdev; diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/types/test.ts new file mode 100644 index 000000000000..a28a3187b4cf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/docs/types/test.ts @@ -0,0 +1,56 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import stdev = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + stdev( 1.0, 3.0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than two numbers... +{ + stdev( true, 3 ); // $ExpectError + stdev( false, 2 ); // $ExpectError + stdev( '5', 1 ); // $ExpectError + stdev( [], 1 ); // $ExpectError + stdev( {}, 2 ); // $ExpectError + stdev( ( x: number ): number => x, 2 ); // $ExpectError + + stdev( 9, true ); // $ExpectError + stdev( 9, false ); // $ExpectError + stdev( 5, '5' ); // $ExpectError + stdev( 8, [] ); // $ExpectError + stdev( 9, {} ); // $ExpectError + stdev( 8, ( x: number ): number => x ); // $ExpectError + + stdev( [], true ); // $ExpectError + stdev( {}, false ); // $ExpectError + stdev( false, '5' ); // $ExpectError + stdev( {}, [] ); // $ExpectError + stdev( '5', ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + stdev(); // $ExpectError + stdev( 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/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/log-logistic/stdev/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/c/example.c new file mode 100644 index 000000000000..7f1772df44c0 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/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/log-logistic/stdev.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 alpha; + double beta; + double v; + int i; + + for ( i = 0; i < 25; i++ ) { + alpha = random_uniform( 0.1, 10.0 ); + beta = random_uniform( 2.1, 10.0 ); + v = stdlib_base_dists_log_logistic_stdev( alpha, beta ); + printf( "α: %lf, β: %lf, SD(X;α,β): %lf\n", alpha, beta, v ); + } +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/index.js b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/index.js new file mode 100644 index 000000000000..7b50bc421666 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/examples/index.js @@ -0,0 +1,31 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var stdev = require( './../lib' ); + +var opts = { + 'dtype': 'float64' +}; +var alpha = uniform( 10, 0.1, 10.0, opts ); +var beta = uniform( 10, 2.1, 10.0, opts ); + +logEachMap( 'α: %0.4f, β: %0.4f, SD(X;α,β): %0.4f', alpha, beta, stdev ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "distribution", + "dist", + "moments", + "continuous", + "standard deviation", + "stdev", + "std", + "deviation", + "dispersion", + "log-logistic", + "univariate" + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/src/Makefile b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/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/log-logistic/stdev/src/addon.c b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/src/addon.c new file mode 100644 index 000000000000..fe4fe91a7348 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/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/log-logistic/stdev.h" +#include "stdlib/math/base/napi/binary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_log_logistic_stdev ) diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/src/main.c b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/src/main.c new file mode 100644 index 000000000000..9f42a16a4535 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/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/log-logistic/stdev.h" +#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/special/sqrt.h" +#include "stdlib/math/base/special/sin.h" +#include "stdlib/constants/float64/pi.h" + +/** +* Returns the standard deviation of a log-logistic distribution with scale parameter `alpha` and shape parameter `beta`. +* +* @param alpha scale parameter +* @param beta shape parameter +* @return standard deviation +* +* @example +* double y = stdlib_base_dists_log_logistic_stdev( 1.0, 3.0 ); +* // returns ~0.978 +*/ +double stdlib_base_dists_log_logistic_stdev( const double alpha, const double beta ) { + double b2; + double b; + double s; + if ( + stdlib_base_is_nan( alpha ) || + stdlib_base_is_nan( beta ) || + alpha <= 0.0 || + beta <= 2.0 + ) { + return 0.0 / 0.0; // NaN + } + b = STDLIB_CONSTANT_FLOAT64_PI / beta; + b2 = 2.0 * b; + s = stdlib_base_sin( b ); + return alpha * stdlib_base_sqrt( ( b2 / stdlib_base_sin( b2 ) ) - ( ( b * b ) / ( s * s ) ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/REQUIRE b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/REQUIRE new file mode 100644 index 000000000000..98be20b58ed3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/REQUIRE @@ -0,0 +1,3 @@ +Distributions 0.23.8 +julia 1.5 +JSON 0.21 diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/data.json b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/data.json new file mode 100644 index 000000000000..32a079202b41 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/data.json @@ -0,0 +1 @@ +{"alpha":[0.397,1.09,1.7830000000000001,2.4760000000000004,3.169,3.862,4.555,5.248,5.941,6.634,7.327,8.02,8.713,9.406,0.199,0.892,1.5850000000000002,2.278,2.971,3.664,4.357,5.05,5.743,6.436,7.129,7.822,8.515,9.208,9.901,0.6940000000000001,1.3870000000000002,2.08,2.773,3.466,4.159,4.852,5.545,6.2379999999999995,6.931,7.624,8.317,9.01,9.703,0.496,1.189,1.8820000000000001,2.575,3.2680000000000002,3.9610000000000003,4.654,5.3469999999999995,6.04,6.733,7.426,8.119,8.812,9.505,0.29800000000000004,0.991,1.6840000000000002,2.3770000000000002,3.0700000000000003,3.7630000000000003,4.4559999999999995,5.149,5.842,6.535,7.228,7.921,8.614,9.307,0.1,0.793,1.4860000000000002,2.1790000000000003,2.8720000000000003,3.5650000000000004,4.258,4.951,5.644,6.337,7.03,7.723,8.416,9.109,9.802,0.595,1.2880000000000003,1.981,2.6740000000000004,3.3670000000000004,4.06,4.753,5.446,6.139,6.832,7.525,8.218,8.911,9.604000000000001],"beta":[2.495,3.5220000000000002,4.5489999999999995,5.5760000000000005,6.603,7.630000000000001,8.657,9.684,2.811,3.838,4.865,5.8919999999999995,6.9190000000000005,7.946,8.973,2.1,3.127,4.154,5.181,6.208,7.234999999999999,8.262,9.289,2.416,3.443,4.470000000000001,5.497,6.524000000000001,7.551,8.578,9.605,2.732,3.7590000000000003,4.786,5.813000000000001,6.84,7.867000000000001,8.894,9.921,3.048,4.075,5.102,6.129,7.156000000000001,8.183,9.21,2.337,3.364,4.391,5.418,6.445,7.4719999999999995,8.499,9.526,2.653,3.68,4.707000000000001,5.734,6.761000000000001,7.788,8.815,9.842,2.9690000000000003,3.996,5.023,6.050000000000001,7.077,8.104000000000001,9.131,2.258,3.285,4.312,5.339,6.366,7.393000000000001,8.42,9.447000000000001,2.574,3.601,4.628,5.655,6.682,7.709,8.736,9.763,2.89,3.917,4.944,5.971,6.997999999999999,8.025,9.052,2.1790000000000003,3.2060000000000004,4.2330000000000005,5.26,6.287000000000001,7.314,8.341,9.368],"expected":[0.635741702045429,0.779858385182194,0.8570340193101212,0.9094456218716667,0.9482314160312483,0.9783166149183812,1.0024053986600405,1.0221553366599299,6.757870089951654,4.110533173335357,3.2118856396730866,2.7512512145052264,2.4685866226020776,2.2764128052867436,0.0421053877090213,3.7659117448377404,1.4197210526623247,1.2487857690833466,1.1984963934543662,1.179745971661071,1.1725093164112095,1.1701933088898555,1.170160875078955,11.56615567759061,5.3101416524987135,3.853796654336046,3.184248640456069,2.79459478703171,2.5378180293551504,0.1542757521649296,0.27254706944532664,2.5444416489574593,1.7770379778501135,1.5533355502253614,1.4505995536373621,1.3931412384239676,1.3570967772787856,1.3326934664947985,1.3152421888838262,7.204001221977063,4.693326852825083,3.7081760581659298,3.1727530824426897,0.1351698708210305,0.2784741719981182,0.3870429112638611,5.301998687973219,2.539523979156832,2.0018178438470313,1.7725962135517208,1.6463605507448964,1.566750042920114,1.5120925497516222,1.4723077868049461,10.759016992417507,5.848816564475651,4.357611708205495,0.10571020080429243,0.28842256216370216,0.4168452646826537,0.5128124809607523,0.5876037014343345,3.765131180020063,2.5911540278357403,2.1630584996486713,1.9404758443525136,1.8038096502391028,1.7112463593860974,1.6443445264479901,20.961365412032105,7.562715649094992,0.05188167360908879,0.307744401187732,0.46429936641268754,0.5720978992630906,0.6516813002270526,0.7132128719729417,6.167580581124308,3.4088847917247693,2.6485898842601987,2.287027773124771,2.074352154877387,1.9337673742344375,1.833685411499819,1.7586835650489494,10.430552150272725,0.35693416251363647,0.5525736163482474,0.6686077798671349,0.7477099739132549,0.8059065690369751,0.8508511127024625,14.404424534104477,4.639452199509251,3.2724618087224058,2.7025817129089456,2.386476993355386,2.184241038743004,2.0431912390861364,1.9389467945923722]} diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/runner.jl b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/runner.jl new file mode 100644 index 000000000000..12cd319523e7 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/fixtures/julia/runner.jl @@ -0,0 +1,72 @@ +#!/usr/bin/env julia +# +# @license Apache-2.0 +# +# Copyright (c) 2026 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import Distributions: std, LogLogistic +import JSON + +""" + gen( alpha, beta, name ) + +Generate fixture data and write to file. + +# Arguments + +* `alpha`: scale parameter +* `beta`: shape parameter +* `name::AbstractString`: output filename + +# Examples +``` julia +julia> alpha = rand( 1000 ) .* 10.0 .+ 0.1; +julia> beta = rand( 1000 ) .* 8.0 .+ 2.1; +julia> gen( alpha, beta, "data.json" ); +``` +""" +function gen( alpha, beta, name ) + z = Array{Float64}( undef, length(alpha) ); + for i in eachindex(alpha) + z[ i ] = std( LogLogistic( alpha[i], beta[i] ) ); + end + + # Store data to be written to file as a collection: + data = Dict([ + ("alpha", alpha), + ("beta", beta), + ("expected", z) + ]); + + # Based on the script directory, create an output filepath: + filepath = joinpath( dir, name ); + + # Write the data to the output filepath as JSON: + outfile = open( filepath, "w" ); + write( outfile, JSON.json(data) ); + write( outfile, "\n" ); + close( outfile ); +end + +# Get the filename: +file = @__FILE__; + +# Extract the directory in which this file resides: +dir = dirname( file ); + +# Generate fixtures: +alpha = ( rand( 1000 ) .* 10.0 ) .+ 0.1; +beta = ( rand( 1000 ) .* 8.0 ) .+ 2.1; +gen( alpha, beta, "data.json" ); diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/test.js new file mode 100644 index 000000000000..0e5ffd670ec9 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/test.js @@ -0,0 +1,118 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var stdev = require( './../lib' ); + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof stdev, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) { + var y = stdev( NaN, 3.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = stdev( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a nonpositive `alpha`, the function returns `NaN`', function test( t ) { + var y; + + y = stdev( 0.0, 3.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( -1.0, 3.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( NINF, 3.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a nonpositive `beta`, the function returns `NaN`', function test( t ) { + var y; + + y = stdev( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( NaN, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided `beta <= 2`, the function returns `NaN`', function test( t ) { + var y; + + y = stdev( 2.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( 2.0, 1.5 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the standard deviation of a log-logistic distribution', function test( t ) { + var expected; + var alpha; + var beta; + var y; + var i; + + expected = data.expected; + alpha = data.alpha; + beta = data.beta; + for ( i = 0; i < alpha.length; i++ ) { + y = stdev( alpha[ i ], beta[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/test.native.js new file mode 100644 index 000000000000..2ae75ef2ef4c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/log-logistic/stdev/test/test.native.js @@ -0,0 +1,127 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); + + +// VARIABLES // + +var stdev = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( stdev instanceof Error ) +}; + + +// FIXTURES // + +var data = require( './fixtures/julia/data.json' ); + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof stdev, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, function test( t ) { + var y = stdev( NaN, 3.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + y = stdev( 1.0, NaN ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'if provided a nonpositive `alpha`, the function returns `NaN`', opts, function test( t ) { + var y; + + y = stdev( 0.0, 3.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( -1.0, 3.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( NINF, 3.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a nonpositive `beta`, the function returns `NaN`', opts, function test( t ) { + var y; + + y = stdev( 2.0, 0.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( 2.0, -1.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( 1.0, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( PINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( NINF, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( NaN, NINF ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided `beta <= 2`, the function returns `NaN`', opts, function test( t ) { + var y; + + y = stdev( 2.0, 2.0 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + y = stdev( 2.0, 1.5 ); + t.strictEqual( isnan( y ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the standard deviation of a log-logistic distribution', opts, function test( t ) { + var expected; + var alpha; + var beta; + var y; + var i; + + expected = data.expected; + alpha = data.alpha; + beta = data.beta; + for ( i = 0; i < alpha.length; i++ ) { + y = stdev( alpha[ i ], beta[ i ] ); + t.strictEqual( isAlmostSameValue( y, expected[ i ], 2 ), true, 'returns expected value' ); + } + t.end(); +});