diff --git a/lib/node_modules/@stdlib/stats/base/dists/studentized-range/README.md b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/README.md index a632ea432e9f..abba9738cef8 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/studentized-range/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/README.md @@ -92,6 +92,93 @@ out = tukey.quantile( 0.9, r, v, n ); + + +* * * + +
+ +## C APIS + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/studentized-range" +``` + +### tukey + +[Studentized range][studentized-range] distribution. + +```c +studentized_range_t dist; +``` + +The namespace contains the following distribution functions: + +- `cdf( x, r, v[, nranges=1] )`: Studentized range distribution cumulative distribution function (CDF). +- `quantile( p, r, v[, nranges=1] )`: Studentized range distribution quantile function. + +
+ +
+ +### Examples: Using the CDF Function + +```c +#include +#include "studentized_range.h" + +int main() { + // Parameters for the Studentized Range distribution: + double r = 5.0; // Number of means + double v = 20.0; // Degrees of freedom + double n = 3.0; // Number of ranges + double x = 2.0; // Value at which to calculate the CDF + + // Calculate the cumulative distribution function (CDF): + double cdf = studentized_range_cdf( x, r, v, n ); + printf( "CDF at x = %.2f: %.4f\n", x, cdf ); + + return 0; +} +``` + +### Examples: Using the Quantile Function + +```c +#include +#include "studentized_range.h" + +int main() { + // Parameters for the Studentized Range distribution: + double r = 5.0; // Number of means + double v = 20.0; // Degrees of freedom + double n = 3.0; // Number of ranges + double p = 0.9; // Probability value + + // Calculate the quantile function: + double quantile = studentized_range_quantile( p, r, v, n ); + printf( "Quantile at p = %.2f: %.4f\n", p, quantile ); + + return 0; +} +``` + +
+ diff --git a/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/README.md index 57ce560e7f58..e2dc4d176601 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/README.md @@ -119,6 +119,71 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIS + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/studentized-range" +``` + +### tukey + +[Studentized range][studentized-range] distribution. + +```c +studentized_range_t dist; +``` + +The namespace contains the following distribution functions: + +- `cdf( x, r, v[, nranges=1] )`: Studentized range distribution cumulative distribution function (CDF). + +
+ +
+ +### Examples: Using the CDF Function + +```c +#include +#include "studentized_range.h" + +int main() { + // Parameters for the Studentized Range distribution: + double r = 5.0; // Number of means + double v = 20.0; // Degrees of freedom + double n = 3.0; // Number of ranges + double x = 2.0; // Value at which to calculate the CDF + + // Calculate the cumulative distribution function (CDF): + double cdf = studentized_range_cdf( x, r, v, n ); + printf( "CDF at x = %.2f: %.4f\n", x, cdf ); + + return 0; +} +``` + +
+ diff --git a/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..2c512bc5d820 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/benchmark/benchmark.native.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var cdf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( cdf instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var len; + var q; + var r; + var v; + var y; + var i; + + len = 100; + q = new Float64Array( len ); // Quantiles + r = new Float64Array( len ); // Number of ranges + v = new Float64Array( len ); // Degrees of freedom + for ( i = 0; i < len; i++ ) { + q[ i ] = randu() * 10.0; // Random quantile + r[ i ] = ( randu() * 20.0 ) + 2; // Random number of ranges + v[ i ] = ( randu() * 20.0 ) + 2; // Random degrees of freedom + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = cdf( q[ i % len ], r[ i % len ], v[ 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/studentized-range/cdf/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/benchmark/c/Makefile new file mode 100644 index 000000000000..f69e9da2b4d3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/studentized-range/cdf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/benchmark/c/benchmark.c new file mode 100644 index 000000000000..24f7a07a25f4 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/benchmark/c/benchmark.c @@ -0,0 +1,100 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 +#include +#include +#include +#include "stdlib/stats/base/dists/studentized-range/cdf.h" + +// Function to generate random numbers between 0 and 1 +static double randu() { + return (double)rand() / (double)RAND_MAX; +} + +// Placeholder for cdf_factory +double (*cdf_factory(double v, double r))(double) { + // Replace with the actual logic + return NULL; // Placeholder +} + +// Benchmark function for CDF +void benchmark_cdf() { + double q, r, v, y; + clock_t start, end; + int i, iterations = 1000000; // Number of iterations + + printf("Benchmarking CDF...\n"); + + start = clock(); + for (i = 0; i < iterations; i++) { + q = randu() * 12.0; // Random quantile value + r = (randu() * 20.0) + 2.0; // Random degrees of freedom + v = (randu() * 20.0) + 2.0; // Random scale parameter + y = cdf(q, r, v); // Call to the cdf function + if (isnan(y)) { + fprintf(stderr, "Error: CDF returned NaN\n"); + return; + } + } + end = clock(); + + printf("Benchmark finished: %d iterations in %.2f seconds\n", iterations, (double)(end - start) / CLOCKS_PER_SEC); +} + +// Benchmark function for factory-generated CDF +void benchmark_cdf_factory() { + double (*mycdf)(double); // Pointer to the CDF function + double q, y, r = 3.0, v = 5.0; + clock_t start, end; + int i, iterations = 1000000; // Number of iterations + + // Assume a factory function is implemented to return a pre-configured CDF + mycdf = cdf_factory(v, r); // Create a CDF function using the factory + + if (mycdf == NULL) { + fprintf(stderr, "Error: Failed to initialize CDF factory\n"); + return; + } + + printf("Benchmarking CDF factory...\n"); + + start = clock(); + for (i = 0; i < iterations; i++) { + q = randu(); // Random quantile value + y = mycdf(q); // Call to the factory-generated CDF function + if (isnan(y)) { + fprintf(stderr, "Error: Factory CDF returned NaN\n"); + return; + } + } + end = clock(); + + printf("Benchmark finished: %d iterations in %.2f seconds\n", iterations, (double)(end - start) / CLOCKS_PER_SEC); +} + +// Main function +int main() { + // Seed random number generator + srand((unsigned int)time(NULL)); + + // Run benchmarks + benchmark_cdf(); + benchmark_cdf_factory(); + + return 0; +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/binding.gyp b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/studentized-range/cdf/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2024 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/studentized-range/cdf/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/examples/c/example.c new file mode 100644 index 000000000000..186e15cbb30a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/examples/c/example.c @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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. +*/ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 +#include +#include +#include +#include "stdlib/stats/base/dists/studentized-range/cdf.h" + + +static double randu() { + return (double)rand() / (double)RAND_MAX; +} + +int main() { + double q, r, v, y; + int i; + + + srand((unsigned int)time(NULL)); + + + for (i = 0; i < 10; i++) { + q = randu() * 12.0; + r = (randu() * 20.0) + 2.0; + v = (randu() * 10.0) + 2.0; + y = cdf(q, r, v); + printf("q: %.4f, r: %.4f, v: %.4f, F(x;v): %.4f\n", q, r, v, y); + } + + + y = cdf(-100.0, 3.0, 3.0); + printf("CDF(-100, 3, 3): %.4f\n", y); + + return 0; +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/include.gypi b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 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': [ + '= v + ) { + return 0.0/0.0; // NaN + } + if ( x < r) { + return 0.0; + } + if ( x >= v ) { + return 1.0; + } + return TWO_OVER_PI * stdlib_base_asin( stdlib_base_sqrt( ( x-r) / ( v-r ) ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/test/test.native.js new file mode 100644 index 000000000000..dbcbcdce394a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dists/studentized-range/cdf/test/test.native.js @@ -0,0 +1,133 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 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 EPS = require( '@stdlib/constants/float64/eps' ); + + +// FIXTURES // + +var pdata = require( './fixtures/python/data.json' ); +var rdata = require( './fixtures/r/data.json' ); + + +// VARIABLES // + +var cdf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( cdf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof cdf, '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 = cdf( NaN, 2.0, 10.0 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = cdf( 5.0, NaN, 10.0 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = cdf( 5.0, 2.0, NaN ); + t.equal( isnan( y ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'if provided `x < r`, the function returns `0`', opts, function test( t ) { + var y = cdf( 1.0, 2.0, 10.0 ); + t.equal( y, 0.0, 'returns 0' ); + t.end(); +}); + +tape( 'if provided `x >= v`, the function returns `1`', opts, function test( t ) { + var y = cdf( 10.0, 2.0, 10.0 ); + t.equal( y, 1.0, 'returns 1' ); + + y = cdf( Infinity, 2.0, 10.0 ); + t.equal( y, 1.0, 'returns 1' ); + t.end(); +}); + +tape( 'if provided `r >= v`, the function returns `NaN`', opts, function test( t ) { + var y = cdf( 5.0, 10.0, 10.0 ); + t.equal( isnan( y ), true, 'returns NaN' ); + + y = cdf( 5.0, 12.0, 10.0 ); + t.equal( isnan( y ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'the function evaluates the CDF using Python-generated data', opts, function test( t ) { + var expected = pdata.expected; + var delta; + var tol; + var r = pdata.r; + var v = pdata.v; + var x = pdata.x; + var y; + var i; + + for ( i = 0; i < x.length; i++ ) { + y = cdf( x[ i ], r[ i ], v[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'r: '+r[ i ]+', v: '+v[ i ]+', x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 2.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. r: '+r[ i ]+'. v: '+v[ i ]+'. x: '+x[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); + +tape( 'the function evaluates the CDF using R-generated data', opts, function test( t ) { + var expected = rdata.expected; + var delta; + var tol; + var r = rdata.r; + var v = rdata.v; + var x = rdata.x; + var y; + var i; + + for ( i = 0; i < x.length; i++ ) { + y = cdf( x[ i ], r[ i ], v[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'r: '+r[ i ]+', v: '+v[ i ]+', x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 2.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. r: '+r[ i ]+'. v: '+v[ i ]+'. x: '+x[ i ]+'. y: '+y+'. expected: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + } + t.end(); +}); diff --git a/package.json b/package.json index 25b79ee80bb9..f28dee7b431c 100644 --- a/package.json +++ b/package.json @@ -1,296 +1 @@ -{ - "name": "@stdlib/stdlib", - "version": "0.3.2", - "description": "Standard library.", - "license": "Apache-2.0 AND BSL-1.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" - } - ], - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/stdlib" - }, - "bin": { - "stdlib": "./bin/cli" - }, - "main": "./lib", - "browser": { - "process": "process/" - }, - "directories": { - "doc": "./docs", - "example": "./examples", - "lib": "./lib", - "test": "./test" - }, - "types": "./docs/types", - "scripts": { - "notes": "make notes", - "lint": "make lint", - "repl": "make repl", - "test": "make test", - "test-cov": "make test-cov", - "view-cov": "make view-cov", - "examples": "make examples", - "benchmark": "make benchmark", - "clean": "make clean", - "check-deps": "make check-deps", - "check-licenses": "make check-licenses" - }, - "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": { - "@stdlib/array": "^0.3.3", - "@stdlib/assert": "^0.3.3", - "@stdlib/bench": "^0.4.3", - "@stdlib/bigint": "^0.3.3", - "@stdlib/blas": "^0.3.3", - "@stdlib/boolean": "^0.3.3", - "@stdlib/buffer": "^0.3.3", - "@stdlib/cli": "^0.3.3", - "@stdlib/complex": "^0.3.3", - "@stdlib/console": "^0.3.3", - "@stdlib/constants": "^0.3.3", - "@stdlib/datasets": "^0.3.0", - "@stdlib/error": "^0.3.3", - "@stdlib/fs": "^0.3.3", - "@stdlib/function": "^0.3.3", - "@stdlib/iter": "^0.3.3", - "@stdlib/lapack": "^0.1.3", - "@stdlib/math": "^0.3.3", - "@stdlib/ml": "^0.3.3", - "@stdlib/namespace": "^0.3.3", - "@stdlib/napi": "^0.3.3", - "@stdlib/ndarray": "^0.3.3", - "@stdlib/net": "^0.3.3", - "@stdlib/nlp": "^0.3.3", - "@stdlib/number": "^0.3.3", - "@stdlib/object": "^0.3.3", - "@stdlib/os": "^0.3.3", - "@stdlib/plot": "^0.3.3", - "@stdlib/process": "^0.3.3", - "@stdlib/proxy": "^0.3.3", - "@stdlib/random": "^0.3.3", - "@stdlib/regexp": "^0.3.3", - "@stdlib/repl": "^0.3.3", - "@stdlib/simulate": "^0.3.3", - "@stdlib/slice": "^0.3.3", - "@stdlib/stats": "^0.3.3", - "@stdlib/streams": "^0.3.3", - "@stdlib/strided": "^0.3.3", - "@stdlib/string": "^0.3.3", - "@stdlib/symbol": "^0.3.3", - "@stdlib/time": "^0.3.3", - "@stdlib/types": "^0.4.3", - "@stdlib/utils": "^0.3.3", - "@stdlib/wasm": "^0.1.1", - "acorn": "^8.1.0", - "acorn-loose": "^8.0.2", - "acorn-walk": "^8.0.2", - "d3-format": "^1.0.0", - "d3-scale": "^1.0.0", - "d3-shape": "^1.0.0", - "d3-time-format": "^2.0.0", - "debug": "^2.6.9", - "glob": "^7.0.5", - "minimist": "^1.2.0", - "readable-stream": "^2.1.4", - "resolve": "^1.1.7", - "vdom-to-html": "^2.3.0", - "virtual-dom": "^2.1.1" - }, - "optionalDependencies": { - "node-gyp": "^9.3.1" - }, - "devDependencies": { - "0x": "^4.10.2", - "@cspell/eslint-plugin": "^8.8.0", - "@commitlint/cli": "^17.4.4", - "@commitlint/cz-commitlint": "^17.4.4", - "@conventional-commits/parser": "^0.4.1", - "@kaciras/deasync": "^1.0.1", - "@types/node": "^13.9.0", - "@typescript-eslint/parser": "^6.9.1", - "@typescript-eslint/eslint-plugin": "^6.9.1", - "ajv": "^5.2.2", - "browser-pack-flat": "^3.0.0", - "browserify": "^17.0.0", - "bundle-collapser": "^1.3.0", - "c8": "^7.12.0", - "chai": "^3.5.0", - "cheerio": "^1.0.0-rc.12", - "commitizen": "^4.3.0", - "common-shakeify": "^0.6.0", - "conventional-changelog-conventionalcommits": "^5.0.0", - "doctrine": "^3.0.0", - "editorconfig-checker": "^6.0.0", - "envify": "^4.0.0", - "eslint": "^8.57.0", - "eslint-plugin-node": "^11.1.0", - "eslint-plugin-expect-type": "^0.2.3", - "eslint-plugin-import": "^2.29.0", - "eslint-plugin-jsdoc": "^46.8.2", - "exorcist": "^2.0.0", - "factor-bundle": "^2.5.0", - "gh-pages": "git+https://github.com/Planeshifter/gh-pages.git#main", - "inquirer": "^8.0.0", - "jscodeshift": "^0.15.0", - "jsdoc": "^3.4.0", - "lunr": "^2.3.9", - "mathjax-node": "^2.0.1", - "mathjax-node-sre": "^3.0.0", - "mkdirp": "^0.5.1", - "mustache": "^4.0.0", - "parse-link-header": "^1.0.1", - "plato": "^1.5.0", - "process": "^0.11.10", - "proxyquire": "^2.0.0", - "proxyquire-universal": "^2.0.0", - "proxyquireify": "^3.1.1", - "read-installed": "^4.0.3", - "rehype": "^9.0.0", - "rehype-highlight": "^3.0.0", - "remark": "^11.0.1", - "remark-cli": "^7.0.0", - "remark-frontmatter": "^1.2.0", - "remark-html": "^10.0.0", - "remark-lint": "^6.0.0", - "remark-lint-blockquote-indentation": "^1.0.0", - "remark-lint-checkbox-character-style": "^1.0.0", - "remark-lint-checkbox-content-indent": "^1.0.0", - "remark-lint-code-block-style": "^1.0.0", - "remark-lint-definition-case": "^1.0.0", - "remark-lint-definition-spacing": "^1.0.0", - "remark-lint-emphasis-marker": "^1.0.0", - "remark-lint-fenced-code-flag": "^1.0.0", - "remark-lint-fenced-code-marker": "^1.0.0", - "remark-lint-file-extension": "^1.0.0", - "remark-lint-final-definition": "^1.0.0", - "remark-lint-final-newline": "^1.0.0", - "remark-lint-first-heading-level": "^1.1.0", - "remark-lint-hard-break-spaces": "^1.0.1", - "remark-lint-heading-increment": "^1.0.0", - "remark-lint-heading-style": "^1.0.0", - "remark-lint-linebreak-style": "^1.0.0", - "remark-lint-link-title-style": "^1.0.0", - "remark-lint-list-item-bullet-indent": "^1.0.0", - "remark-lint-list-item-content-indent": "^1.0.0", - "remark-lint-list-item-indent": "^1.0.0", - "remark-lint-list-item-spacing": "^1.1.0", - "remark-lint-maximum-heading-length": "^1.0.0", - "remark-lint-maximum-line-length": "^1.0.0", - "remark-lint-no-auto-link-without-protocol": "^1.0.0", - "remark-lint-no-blockquote-without-marker": "^2.0.0", - "remark-lint-no-consecutive-blank-lines": "^1.0.0", - "remark-lint-no-duplicate-definitions": "^1.0.0", - "remark-lint-no-duplicate-headings": "^1.0.0", - "remark-lint-no-duplicate-headings-in-section": "^1.0.0", - "remark-lint-no-emphasis-as-heading": "^1.0.0", - "remark-lint-no-empty-url": "^1.0.1", - "remark-lint-no-file-name-articles": "^1.0.0", - "remark-lint-no-file-name-consecutive-dashes": "^1.0.0", - "remark-lint-no-file-name-irregular-characters": "^1.0.0", - "remark-lint-no-file-name-mixed-case": "^1.0.0", - "remark-lint-no-file-name-outer-dashes": "^1.0.1", - "remark-lint-no-heading-content-indent": "^1.0.0", - "remark-lint-no-heading-indent": "^1.0.0", - "remark-lint-no-heading-like-paragraph": "^1.0.0", - "remark-lint-no-heading-punctuation": "^1.0.0", - "remark-lint-no-html": "^1.0.0", - "remark-lint-no-inline-padding": "^1.0.0", - "remark-lint-no-literal-urls": "^1.0.0", - "remark-lint-no-missing-blank-lines": "^1.0.0", - "remark-lint-no-multiple-toplevel-headings": "^1.0.0", - "remark-lint-no-paragraph-content-indent": "^1.0.1", - "remark-lint-no-reference-like-url": "^1.0.0", - "remark-lint-no-shell-dollars": "^1.0.0", - "remark-lint-no-shortcut-reference-image": "^1.0.0", - "remark-lint-no-shortcut-reference-link": "^1.0.1", - "remark-lint-no-table-indentation": "^1.0.0", - "remark-lint-no-tabs": "^1.0.0", - "remark-lint-no-trailing-spaces": "^3.0.2", - "remark-lint-no-undefined-references": "^1.0.0", - "remark-lint-no-unused-definitions": "^1.0.0", - "remark-lint-ordered-list-marker-style": "^1.0.0", - "remark-lint-ordered-list-marker-value": "^1.0.0", - "remark-lint-rule-style": "^1.0.0", - "remark-lint-strong-marker": "^1.0.0", - "remark-lint-table-cell-padding": "^1.0.0", - "remark-lint-table-pipe-alignment": "^1.0.0", - "remark-lint-table-pipes": "^1.0.0", - "remark-lint-unordered-list-marker-style": "^1.0.0", - "remark-slug": "^5.0.0", - "remark-unlink": "^2.0.0", - "remark-validate-links": "^9.0.1", - "remark-vdom": "^8.0.0", - "semver": "^6.0.0", - "source-map-explorer": "^2.5.3", - "spdx-license-ids": "^3.0.0", - "tap-min": "git+https://github.com/Planeshifter/tap-min.git", - "tap-spec": "5.x.x", - "tap-summary": "^4.0.0", - "tap-xunit": "^2.2.0", - "tape": "git+https://github.com/kgryte/tape.git#fix/globby", - "to-vfile": "^6.0.0", - "typedoc": "git+https://github.com/kgryte/typedoc.git#0.16.11-patch", - "typescript": "4.3.5", - "uglify-js": "^3.17.4", - "uglifyify": "^5.0.0", - "unified-lint-rule": "^1.0.1", - "unist-util-visit": "^2.0.0", - "unist-util-visit-parents": "^3.1.1", - "yaml": "^1.0.0" - }, - "engines": { - "node": ">=0.10.0", - "npm": ">2.7.0" - }, - "os": [ - "aix", - "darwin", - "freebsd", - "linux", - "macos", - "openbsd", - "sunos", - "win32", - "windows" - ], - "keywords": [ - "stdlib", - "stdlib-js", - "stdlib.js", - "js-stdlib", - "stdlibjs", - "standard", - "std", - "library", - "lib", - "libstd", - "numerical", - "numeric", - "mathematical", - "mathematics", - "math", - "scientific", - "machine learning", - "machine-learning", - "ml", - "ndarray", - "numpy", - "scipy" - ] -} +{"name":"@stdlib/stdlib","version":"0.0.0"}