diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/benchmark.native.js new file mode 100644 index 000000000000..ae8025f67a74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/benchmark/benchmark.native.js @@ -0,0 +1,149 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var format = require( '@stdlib/string/format' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var betainc = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( betainc instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native:regularized=true,upper=true', pkg ), opts, function benchmark( assert ) { + var out; + var x; + var a; + var b; + var i; + + x = uniform( 100, 0.0, 1.0 ); + a = uniform( 100, EPS, 1000.0 ); + b = uniform( 100, EPS, 1000.0 ); + + out = [ 0.0, 0.0 ]; + assert.tic(); + for ( i = 0; i < assert.iterations; i++ ) { + out = betainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], true, true ); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + assert.fail( 'should not return NaN' ); + } + } + assert.toc(); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + assert.fail( 'should not return NaN' ); + } + assert.pass( 'benchmark finished' ); + assert.end(); +}); + +bench( format( '%s::native:regularized=false,upper=true', pkg ), opts, function benchmark( assert ) { + var out; + var x; + var a; + var b; + var i; + + x = uniform( 100, 0.0, 1.0 ); + a = uniform( 100, EPS, 1000.0 ); + b = uniform( 100, EPS, 1000.0 ); + + out = [ 0.0, 0.0 ]; + assert.tic(); + for ( i = 0; i < assert.iterations; i++ ) { + out = betainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], false, true ); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + assert.fail( 'should not return NaN' ); + } + } + assert.toc(); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + assert.fail( 'should not return NaN' ); + } + assert.pass( 'benchmark finished' ); + assert.end(); +}); + +bench( format( '%s::native:regularized=true,upper=false', pkg ), opts, function benchmark( assert ) { + var out; + var x; + var a; + var b; + var i; + + x = uniform( 100, 0.0, 1.0 ); + a = uniform( 100, EPS, 1000.0 ); + b = uniform( 100, EPS, 1000.0 ); + + out = [ 0.0, 0.0 ]; + assert.tic(); + for ( i = 0; i < assert.iterations; i++ ) { + out = betainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], true, false ); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + assert.fail( 'should not return NaN' ); + } + } + assert.toc(); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + assert.fail( 'should not return NaN' ); + } + assert.pass( 'benchmark finished' ); + assert.end(); +}); + +bench( format( '%s::native:regularized=false,upper=false', pkg ), opts, function benchmark( assert ) { + var out; + var x; + var a; + var b; + var i; + + x = uniform( 100, 0.0, 1.0 ); + a = uniform( 100, EPS, 1000.0 ); + b = uniform( 100, EPS, 1000.0 ); + + out = [ 0.0, 0.0 ]; + assert.tic(); + for ( i = 0; i < assert.iterations; i++ ) { + out = betainc( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ], false, false ); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + assert.fail( 'should not return NaN' ); + } + } + assert.toc(); + if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { + assert.fail( 'should not return NaN' ); + } + assert.pass( 'benchmark finished' ); + assert.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/binding.gyp b/lib/node_modules/@stdlib/math/base/special/betainc/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/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/math/base/special/betainc/include.gypi b/lib/node_modules/@stdlib/math/base/special/betainc/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/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': [ + ' + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Evaluates the incomplete beta function and its first derivative. +*/ +void stdlib_base_betainc( double x, double a, double b, const bool regularized, const bool upper, double *out, double *derivative ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_KERNEL_BETAINC_H diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/lib/native.js b/lib/node_modules/@stdlib/math/base/special/betainc/lib/native.js new file mode 100644 index 000000000000..319a28912582 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/lib/native.js @@ -0,0 +1,62 @@ +/** +* @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 Float64Array = require( '@stdlib/array/float64' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Evaluates the incomplete beta function. +* +* @param {Probability} x - function parameter +* @param {NonNegativeNumber} a - function parameter +* @param {NonNegativeNumber} b - function parameter +* @param {boolean} [regularized=true] - boolean indicating if the function should evaluate the regularized or non-regularized incomplete beta function +* @param {boolean} [upper=false] - boolean indicating if the function should return the upper tail of the incomplete beta function +* @returns {number} function value +* +* @example +* var y = betainc( 0.5, 2.0, 2.0 ); +* // returns 0.5 +* +* @example +* var y = betainc( 0.5, 2.0, 2.0, false ); +* // returns ~0.083 +* +* @example +* var y = betainc( 0.2, 1.0, 2.0 ); +* // returns 0.36 +*/ +function betainc( x, a, b, regularized, upper ) { + var out = new Float64Array( 2 ); + regularized = ( regularized === false ) ? false : true; // eslint-disable-line no-unneeded-ternary + upper = ( upper === true ) ? true : false; // eslint-disable-line no-unneeded-ternary + addon( x, a, b, regularized, upper, out ); + return out[ 0 ]; +} + + +// EXPORTS // + +module.exports = betainc; diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json b/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json new file mode 100644 index 000000000000..8a2db5bbfc4c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/manifest.json @@ -0,0 +1,48 @@ +{ + "options": { + "task": "build", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "wasm": false, + "src": ["./src/main.c"], + "include": ["./include"], + "libraries": ["-lm"], + "libpath": [], + "dependencies": [ + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-double", + "@stdlib/napi/argv-bool", + "@stdlib/napi/argv-float64array", + "@stdlib/math/base/special/kernel-betainc", + "@stdlib/math/base/assert/is-probability", + "@stdlib/math/base/assert/is-positive-finite" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/package.json b/lib/node_modules/@stdlib/math/base/special/betainc/package.json index e10af830ef5c..97a1cc68a960 100644 --- a/lib/node_modules/@stdlib/math/base/special/betainc/package.json +++ b/lib/node_modules/@stdlib/math/base/special/betainc/package.json @@ -14,6 +14,7 @@ } ], "main": "./lib", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/src/Makefile b/lib/node_modules/@stdlib/math/base/special/betainc/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/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/math/base/special/betainc/src/addon.c b/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c new file mode 100644 index 000000000000..008ef947326c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/src/addon.c @@ -0,0 +1,46 @@ +/** +* @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/math/base/special/betainc.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_bool.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/argv_float64array.h" +#include "stdlib/napi/export.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 6 ); + STDLIB_NAPI_ARGV_DOUBLE( env, x, argv, 0 ); + STDLIB_NAPI_ARGV_DOUBLE( env, a, argv, 1 ); + STDLIB_NAPI_ARGV_DOUBLE( env, b, argv, 2 ); + STDLIB_NAPI_ARGV_BOOL( env, regularized, argv, 3 ); + STDLIB_NAPI_ARGV_BOOL( env, upper, argv, 4 ); + STDLIB_NAPI_ARGV_FLOAT64ARRAY( env, y, ylen, argv, 5 ); + stdlib_base_betainc( x, a, b, regularized, upper, &y[ 0 ], &y[ 1 ] ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c b/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c new file mode 100644 index 000000000000..ec1d9b06b318 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/src/main.c @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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/math/base/special/betainc.h" +#include "stdlib/math/base/special/kernel_betainc.h" +#include "stdlib/math/base/assert/is_probability.h" +#include "stdlib/math/base/assert/is_positive_finite.h" + +/** +* Evaluates the incomplete beta function. +* +* @param {Probability} x - function parameter +* @param {NonNegativeNumber} a - function parameter +* @param {NonNegativeNumber} b - function parameter +* @param {boolean} [regularized=true] - boolean indicating if the function should evaluate the regularized or non-regularized incomplete beta function +* @param {boolean} [upper=false] - boolean indicating if the function should return the upper tail of the incomplete beta function +* @returns {number} function value +* +* @example +* var y = betainc( 0.5, 2.0, 2.0 ); +* // returns 0.5 +* +* @example +* var y = betainc( 0.5, 2.0, 2.0, false ); +* // returns ~0.083 +* +* @example +* var y = betainc( 0.2, 1.0, 2.0 ); +* // returns 0.36 +*/ +void stdlib_base_betainc( double x, double a, double b, const bool regularized, const bool upper, double *out, double *derivative ) { + if ( !stdlib_base_is_probability( x ) ) { + // guard x [0, 1] ? + } + if ( !stdlib_base_is_positive_finite( a ) || !stdlib_base_is_positive_finite( b ) ) { + // guard a, b >= 0 ? + } + stdlib_base_kernel_betainc( x, a, b, regularized, upper, out, derivative ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js new file mode 100644 index 000000000000..acc85b22e43c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/betainc/test/test.native.js @@ -0,0 +1,163 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var betainc = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( betainc instanceof Error ) +}; + + +// FIXTURES // + +var fixtures = require( './fixtures/cpp/output.json' ); +var lowerRegularized = fixtures.lower_regularized; +var lowerUnregularized = fixtures.lower_unregularized; +var upperRegularized = fixtures.upper_regularized; +var upperUnregularized = fixtures.upper_unregularized; +var x = fixtures.x; +var a = fixtures.a; +var b = fixtures.b; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof betainc, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if `x` is outside `[0,1]`', opts, function test( t ) { + var val = betainc( -0.2, 1.0, 1.0, true, false ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); + + val = betainc( 1.1, 1.0, 1.0, true, false ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `NaN` negative `a` or `b`', opts, function test( t ) { + var val = betainc( 0.5, -1.0, 1.0, true, false ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); + + val = betainc( 0.5, 1.0, -1.0, true, false ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); + + val = betainc( 0.5, -1.0, -1.0, true, false ); + t.strictEqual( isnan( val ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function evaluates the lower regularized incomplete beta function', opts, function test( t ) { + var expected; + var delta; + var tol; + var i; + var y; + + expected = lowerRegularized; + for ( i = 0; i < x.length; i++ ) { + y = betainc( x[i], a[i], b[i], true, false ); + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+', b: '+b[i]+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 50.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + } + } + t.end(); +}); + +tape( 'the function evaluates the lower unregularized incomplete beta function', opts, function test( t ) { + var expected; + var delta; + var tol; + var i; + var y; + + expected = lowerUnregularized; + for ( i = 0; i < x.length; i++ ) { + y = betainc( x[i], a[i], b[i], false, false ); + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+', b: '+b[i]+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 80.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + } + } + t.end(); +}); + +tape( 'the function evaluates the upper regularized incomplete beta function', opts, function test( t ) { + var expected; + var delta; + var tol; + var i; + var y; + + expected = upperRegularized; + for ( i = 0; i < x.length; i++ ) { + y = betainc( x[i], a[i], b[i], true, true ); + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+', b: '+b[i]+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 50.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + } + } + t.end(); +}); + +tape( 'the function evaluates the upper unregularized incomplete beta function', opts, function test( t ) { + var expected; + var delta; + var tol; + var i; + var y; + + expected = upperUnregularized; + for ( i = 0; i < x.length; i++ ) { + y = betainc( x[i], a[i], b[i], false, true ); + if ( y === expected[i] ) { + t.strictEqual( y, expected[i], 'x: '+x[i]+', y: '+y+'. a: '+a[i]+', b: '+b[i]+', expected: '+expected[i] ); + } else { + delta = abs( y - expected[ i ] ); + tol = 80.0 * EPS * abs( expected[ i ] ); + t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + } + } + t.end(); +});