From 2a2efad09c0c5bba6e46adcb48c20019e75304e0 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Mon, 23 Jun 2025 10:50:31 +0000 Subject: [PATCH 1/3] feat: add `stats/strided/ztest2` --- .../@stdlib/stats/strided/ztest2/README.md | 237 ++++++++++ .../strided/ztest2/benchmark/benchmark.js | 104 +++++ .../ztest2/benchmark/benchmark.ndarray.js | 104 +++++ .../stats/strided/ztest2/docs/repl.txt | 136 ++++++ .../strided/ztest2/docs/types/index.d.ts | 245 ++++++++++ .../stats/strided/ztest2/docs/types/test.ts | 441 ++++++++++++++++++ .../stats/strided/ztest2/examples/index.js | 36 ++ .../@stdlib/stats/strided/ztest2/lib/index.js | 71 +++ .../@stdlib/stats/strided/ztest2/lib/main.js | 65 +++ .../stats/strided/ztest2/lib/ndarray.js | 155 ++++++ .../@stdlib/stats/strided/ztest2/package.json | 69 +++ .../@stdlib/stats/strided/ztest2/test/test.js | 38 ++ .../stats/strided/ztest2/test/test.main.js | 328 +++++++++++++ .../stats/strided/ztest2/test/test.ndarray.js | 381 +++++++++++++++ 14 files changed, 2410 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/README.md create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/package.json create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/test/test.js create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/test/test.main.js create mode 100644 lib/node_modules/@stdlib/stats/strided/ztest2/test/test.ndarray.js diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/README.md b/lib/node_modules/@stdlib/stats/strided/ztest2/README.md new file mode 100644 index 000000000000..8e6dc8b634f7 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/README.md @@ -0,0 +1,237 @@ + + + + +# ztest2 + +> Compute a two-sample Z-test for a strided array. + +
+ +A Z-test commonly refers to a two-sample location test which compares the means of two independent sets of measurements `X` and `Y` when the population standard deviations are known. A Z-test supports testing three different null hypotheses `H0`: + +- `H0: μX - μY ≥ Δ` versus the alternative hypothesis `H1: μX - μY < Δ`. +- `H0: μX - μY ≤ Δ` versus the alternative hypothesis `H1: μX - μY > Δ`. +- `H0: μX - μY = Δ` versus the alternative hypothesis `H1: μX - μY ≠ Δ`. + +Here, `μX` and `μY` are the true population means of samples `X` and `Y`, respectively, and `Δ` is the hypothesized difference in means (typically `0` by default). + +
+ + + +
+ +## Usage + +```javascript +var ztest2 = require( '@stdlib/stats/strided/ztest2' ); +``` + +#### ztest2( N, alternative, alpha, mu, sigmax, x, strideX, sigmay, y, strideY, out ) + +Computes a two-sample Z-test for a strided array. + +```javascript +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); + +var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; + +var results = new Results(); +var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); +// returns {...} + +var bool = ( out === results ); +// returns true +``` + +The function has the following parameters: + +- **N**: number of indexed elements. +- **alternative**: [alternative hypothesis][@stdlib/stats/base/ztest/alternatives]. +- **alpha**: significance level. +- **mu**: mean value under the null hypothesis. +- **sigmax**: known standard deviation of `x`. +- **x**: input array. +- **strideX**: stride length for `x`. +- **sigmay**: known standard deviation of `y`. +- **y**: input array. +- **strideY**: stride length for `y`. +- **out**: output [results object][@stdlib/stats/base/ztest/two-sample/results/float64]. + +The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to perform a two-sample Z-test over every other element in `x` and `y`, + +```javascript +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); + +var x = [ 4.0, 0.0, 4.0, 0.0, 6.0, 0.0, 6.0, 0.0, 5.0, 0.0 ]; +var y = [ 3.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 7.0, 0.0 ]; + +var results = new Results(); +var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x, 2, 2.0, y, 2, results ); +// returns {...} + +var bool = ( out === results ); +// returns true +``` + +Note that indexing is relative to the first index. To introduce an offset, use [`typed array`][mdn-typed-array] views. + + + +```javascript +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var Float64Array = require( '@stdlib/array/float64' ); + +var x0 = new Float64Array( [ 0.0, 4.0, 4.0, 6.0, 6.0, 5.0 ] ); +var x1 = new Float64Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var y0 = new Float64Array( [ 0.0, 3.0, 3.0, 5.0, 7.0, 7.0 ] ); +var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element + +var results = new Results(); +var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x1, 1, 2.0, y1, 1, results ); +// returns {...} + +var bool = ( out === results ); +// returns true +``` + +#### ztest2.ndarray( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, y, strideY, offsetY, out ) + +Computes a two-sample Z-test for a strided array using alternative indexing semantics. + +```javascript +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); + +var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; + +var results = new Results(); +var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); +// returns {...} + +var bool = ( out === results ); +// returns true +``` + +The function has the following additional parameters: + +- **offsetX**: starting index for `x`. +- **offsetY**: starting index for `y`. + +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to perform a two-sample Z-test over every other element in `x` and `y` starting from the second element + +```javascript +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); + +var x = [ 0.0, 4.0, 0.0, 4.0, 0.0, 6.0, 0.0, 6.0, 0.0, 5.0 ]; +var y = [ 0.0, 3.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 7.0 ]; + +var results = new Results(); +var out = ztest2.ndarray( 5, 'two-sided', 0.05, 0.0, 1.0, x, 2, 1, 2.0, y, 2, 1, results ); +// returns {...} + +var bool = ( out === results ); +// returns true +``` + +
+ + + +
+ +## Notes + +- As a general rule of thumb, a Z-test is most reliable when `N >= 50`. For smaller sample sizes or when the standard deviation is unknown, prefer a t-test. +- Both functions support array-like objects having getter and setter accessors for array element access (e.g., [`@stdlib/array/base/accessor`][@stdlib/array/base/accessor]). +- Depending on the environment, the typed versions ([`dztest2`][@stdlib/stats/strided/dztest2], [`sztest2`][@stdlib/stats/strided/sztest2], etc.) are likely to be significantly more performant. + +
+ + + +
+ +## Examples + + + +```javascript +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var normal = require( '@stdlib/random/array/normal' ); +var ztest2 = require( '@stdlib/stats/strided/ztest2' ); + +var x = normal( 1000, 0.0, 1.0, { + 'dtype': 'generic' +}); +var y = normal( 1000, 0.0, 1.0, { + 'dtype': 'generic' +}); + +var results = new Results(); +var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, results ); +// returns {...} + +console.log( out.toString() ); +``` + +
+ + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js new file mode 100644 index 000000000000..7c4ef7de04e3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var normal = require( '@stdlib/random/array/normal' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var pkg = require( './../package.json' ).name; +var ztest2 = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var results; + var x; + var y; + + results = new Results(); + x = normal( len, 0.0, 1.0, options ); + y = normal( len, 0.0, 1.0, options ); + + return benchmark; + + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + if ( isnan( out.statistic ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out.statistic ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js new file mode 100644 index 000000000000..9d92cc579945 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var normal = require( '@stdlib/random/array/normal' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' ); +var pkg = require( './../package.json' ).name; +var ztest2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var results; + var x; + var y; + + results = new Results(); + x = normal( len, 0.0, 1.0, options ); + y = normal( len, 0.0, 1.0, options ); + + return benchmark; + + function benchmark( b ) { + var out; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + if ( isnan( out.statistic ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( out.statistic ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( pkg+':len='+len, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt new file mode 100644 index 000000000000..c32274b297ea --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt @@ -0,0 +1,136 @@ + +{{alias}}( N, alternative, alpha, mu, sigmax, x, strideX, sigmay, y, strideY, out ) + Computes a two-sample Z-test for a strided array. + + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. + + Indexing is relative to the first index. To introduce an offset, use a typed + array view. + + Parameters + ---------- + N: integer + Number of indexed elements. + + alternative: string + Alternative hypothesis. Must be one of the following: + + - two-sided: mean is not equal to null value. + - greater: mean is larger than null value. + - less: mean is less than null value. + + alpha: number + Significance level. + + mu: number + Value of the mean under the null hypothesis. + + sigmax: number + Known standard deviation of `x`. + + x: Array|TypedArray|Object + Input array. + + strideX: integer + Stride length for `x`. + + sigmay: number + Known standard deviation of `y`. + + y: Array|TypedArray|Object + Input array. + + strideY: integer + Stride length for `y`. + + out: Object + Output results object. + + Returns + ------- + out: Object + Results object. + + Examples + -------- + > var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; + > var x = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; + > var N = x.length; + > var alt = 'two-sided'; + > var out = new {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}(); + > var res = {{alias}}( N, alt, 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, out ); + > res.toString() + + +{{alias}}.ndarray( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, y, strideY, offsetY, out ) + Computes a two-sample Z-test for a strided array using alternative indexing + semantics. + + While typed array views mandate a view offset based on the underlying + buffer, the offset parameter supports indexing semantics based on a starting + index. + + Parameters + ---------- + N: integer + Number of indexed elements. + + alternative: string + Alternative hypothesis. Must be one of the following: + + - two-sided: mean is not equal to null value. + - greater: mean is larger than null value. + - less: mean is less than null value. + + alpha: number + Significance level. + + mu: number + Value of the mean under the null hypothesis. + + sigmax: number + Known standard deviation of `x`. + + x: Array|TypedArray|Object + Input array. + + strideX: integer + Stride length for `x`. + + offsetX: integer + Starting index for `x`. + + sigmay: number + Known standard deviation of `y`. + + y: Array|TypedArray|Object + Input array. + + strideY: integer + Stride length for `y`. + + offsetY: integer + Starting index for `y`. + + out: Object + Output results object. + + Returns + ------- + out: Object + Results object. + + Examples + -------- + > var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; + > var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; + > var N = x.length; + > var alt = 'two-sided'; + > var out = new {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}(); + > var res = {{alias}}.ndarray( N, alt, 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, out ); + > res.toString() + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts new file mode 100644 index 000000000000..0790e794fe26 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts @@ -0,0 +1,245 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { NumericArray, Collection, AccessorArrayLike } from '@stdlib/types/array'; + +/** +* Input array. +*/ +type InputArray = NumericArray | Collection | AccessorArrayLike; + +/** +* Alternative hypothesis. +*/ +type Alternative = 'two-sided' | 'greater' | 'less'; + +/** +* Interface describing options when serializing a results object to a string. +*/ +interface Options { + /** + * Number of digits to display after decimal points. Default: 4. + */ + digits?: number; + + /** + * Boolean indicating whether to show the test decision. Default: true. + */ + decision?: boolean; +} + +/** +* Serializes a results object as a string. +* +* @returns string representation +*/ +type toString = ( options?: Options ) => string; + +/** +* Serializes a results object as a JSON object. +* +* @returns JSON representation +*/ +type toJSON = () => BaseResults; + +/** +* Interface describing a "base" results object. +*/ +interface BaseResults { + /** + * Boolean indicating whether the null hypothesis was rejected. + */ + rejected: boolean; + + /** + * Alternative hypothesis. + */ + alternative: Alternative; + + /** + * Significance level. + */ + alpha: number; + + /** + * p-value. + */ + pValue: number; + + /** + * Test statistic. + */ + statistic: number; + + /** + * Confidence interval. + */ + ci: Float64Array; + + /** + * Value of the mean under the null hypothesis + */ + nullValue: number; + + /** + * Sample mean of `x`. + */ + xmean: number; + + /** + * Sample mean of `y`. + */ + ymean: number; +} + +/** +* Interface describing a results object. +*/ +interface Results extends BaseResults { + /** + * Serializes results as formatted test output. + */ + toString: toString; + + /** + * Serializes results as JSON. + */ + toJSON: toJSON; +} + +/** +* Interface describing `ztest2`. +*/ +interface Routine { + /** + * Computes a two-sample Z-test for a strided array. + * + * @param N - number of indexed elements + * @param alternative - alternative hypothesis + * @param alpha - significance level + * @param mu - mean under the null hypothesis + * @param sigmax - known standard deviation of `x` + * @param x - input array + * @param strideX - stride length for `x` + * @param sigmay - known standard deviation of `y` + * @param y - input array + * @param strideY - stride length for `y` + * @param out - output results object + * @returns results object + * + * @example + * var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); + * + * var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; + * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; + * + * var results = new Results(); + * var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); + * // returns {...} + * + * var bool = ( out === results ); + * // returns true + */ + ( N: number, alternative: Alternative, alpha: number, mu: number, sigmax: number, x: InputArray, strideX: number, sigmay: number, y: InputArray, strideY: number, out: T ): Results; + + /** + * Computes a two-sample Z-test for a strided array using alternative indexing semantics. + * + * @param N - number of indexed elements + * @param alternative - alternative hypothesis + * @param alpha - significance level + * @param mu - mean under the null hypothesis + * @param sigmax - known standard deviation of `x` + * @param x - input array + * @param strideX - stride length for `x` + * @param offsetX - starting index for `x` + * @param sigmay - known standard deviation of `y` + * @param y - input array + * @param strideY - stride length for `y` + * @param offsetY - starting index for `y` + * @param out - output results object + * @returns results object + * + * @example + * var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); + * + * var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; + * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; + * + * var results = new Results(); + * var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); + * // returns {...} + * + * var bool = ( out === results ); + * // returns true + */ + ndarray( N: number, alternative: Alternative, alpha: number, mu: number, sigmax: number, x: InputArray, strideX: number, offsetX: number, sigmay: number, y: InputArray, strideY: number, offsetY: number, out: T ): Results; +} + +/** +* Computes a two-sample Z-test for a strided array. +* +* @param N - number of indexed elements +* @param alternative - alternative hypothesis +* @param alpha - significance level +* @param mu - mean under the null hypothesis +* @param sigmax - known standard deviation of `x` +* @param x - input array +* @param strideX - stride length for `x` +* @param sigmay - known standard deviation of `y` +* @param y - input array +* @param strideY - stride length for `y` +* @param out - output results object +* @returns results object +* +* @example +* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* +* var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* +* var results = new Results(); +* var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); +* // returns {...} +* +* var bool = ( out === results ); +* // returns true +* +* @example +* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* +* var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* +* var results = new Results(); +* var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); +* // returns {...} +* +* var bool = ( out === results ); +* // returns true +*/ +declare var ztest2: Routine; + + +// EXPORTS // + +export = ztest2; diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/test.ts b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/test.ts new file mode 100644 index 000000000000..75632230aee3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/test.ts @@ -0,0 +1,441 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +import ztest2 = require( './index' ); + + +// TESTS // + +// The function returns a results object... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectType Results + ztest2( x.length, 'greater', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectType Results + ztest2( x.length, 'less', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectType Results +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( '10', 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( true, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( false, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( null, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( undefined, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( [], 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( {}, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( ( x: number ): number => x, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a valid string... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, '10', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 5, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, true, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, false, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, null, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, undefined, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, [], 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, {}, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, ( x: number ): number => x, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', '10', 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', true, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', false, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', null, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', undefined, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', [], 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', {}, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', ( x: number ): number => x, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, '10', 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, true, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, false, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, null, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, undefined, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, [], 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, {}, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, ( x: number ): number => x, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, 0.0, '10', x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, true, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, false, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, null, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, undefined, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, [], x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, {}, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, ( x: number ): number => x, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a sixth argument which is not an array-like object... +{ + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, 10, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, '10', 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, true, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, false, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, null, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, undefined, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, {}, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, ( x: number ): number => x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, '10', 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, true, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, false, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, null, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, undefined, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, [], 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, {}, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, ( x: number ): number => x, 1.0, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eigth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, '10', y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, true, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, false, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, null, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, undefined, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, [], y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, {}, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, ( x: number ): number => x, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a ninth argument which is not an array-like object... +{ + const x = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, 10, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, '10', 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, true, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, false, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, null, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, undefined, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, {}, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, ( x: number ): number => x, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a tenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, '10', new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, true, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, false, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, null, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, undefined, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, [], new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, {}, new Float64Results() ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, ( x: number ): number => x, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided an eleventh argument which is not a results object... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, '10' ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, true ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, false ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, null ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, undefined ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, [] ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, {} ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2(); // $ExpectError + ztest2( x.length ); // $ExpectError + ztest2( x.length, 'two-sided' ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05 ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0 ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0 ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1 ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0 ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1 ); // $ExpectError + ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results(), {} ); // $ExpectError +} + +// Attached to main export is an `ndarray` method which returns a results object... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectType Results + ztest2.ndarray( x.length, 'greater', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectType Results + ztest2.ndarray( x.length, 'less', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectType Results +} + +// The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( '10', 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( true, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( false, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( null, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( undefined, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( [], 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( {}, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( ( x: number ): number => x, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a valid string... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, '10', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 5, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, true, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, false, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, null, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, undefined, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, [], 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, {}, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, ( x: number ): number => x, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', '10', 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', true, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', false, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', null, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', undefined, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', [], 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', {}, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', ( x: number ): number => x, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, '10', 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, true, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, false, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, null, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, undefined, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, [], 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, {}, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, ( x: number ): number => x, 1, 0.0, x, 1, 0, 0.0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, '10', x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, true, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, false, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, null, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, undefined, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, [], x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, {}, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, ( x: number ): number => x, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not an array-like object... +{ + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, 10, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, '10', 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, true, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, false, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, null, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, undefined, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, {}, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, ( x: number ): number => x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, '10', 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, true, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, false, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, null, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, undefined, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, [], 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, {}, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, ( x: number ): number => x, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, '10', 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, true, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, false, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, null, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, undefined, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, [], 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, {}, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, ( x: number ): number => x, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, '10', y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, true, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, false, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, null, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, undefined, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, [], y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, {}, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, ( x: number ): number => x, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not an array-like object... +{ + const x = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, 10, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, '10', 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, true, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, false, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, null, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, undefined, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, {}, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, ( x: number ): number => x, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a eleventh argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, '10', 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, true, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, false, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, null, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, undefined, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, [], 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, {}, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, ( x: number ): number => x, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an twelfth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, '10', new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, true, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, false, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, null, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, undefined, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, [], new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, {}, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, ( x: number ): number => x, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided a thirteenth argument which is not a results object... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, '10' ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, true ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, false ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, null ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, undefined ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, [] ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, {} ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray(); // $ExpectError + ztest2.ndarray( x.length ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided' ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05 ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0 ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0 ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1 ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0 ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0 ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1 ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError + ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results(), {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/examples/index.js b/lib/node_modules/@stdlib/stats/strided/ztest2/examples/index.js new file mode 100644 index 000000000000..a17cb5960980 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/examples/index.js @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var normal = require( '@stdlib/random/array/normal' ); +var ztest2 = require( './../lib' ); + +var x = normal( 1000, 0.0, 1.0, { + 'dtype': 'generic' +}); +var y = normal( 1000, 0.0, 1.0, { + 'dtype': 'generic' +}); + +var results = new Results(); +var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, results ); +// returns {...} + +console.log( out.toString() ); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/index.js b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/index.js new file mode 100644 index 000000000000..e2f5ddaa1eb1 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/index.js @@ -0,0 +1,71 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Compute a two-sample Z-test for a strided array. +* +* @module @stdlib/stats/strided/ztest2 +* +* @example +* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* var ztest2 = require( '@stdlib/stats/strided/ztest2' ); +* +* var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* +* var results = new Results(); +* var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); +* // returns {...} +* +* var bool = ( out === results ); +* // returns true +* +* @example +* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* var ztest2 = require( '@stdlib/stats/strided/ztest2' ); +* +* var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* +* var results = new Results(); +* var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); +* // returns {...} +* +* var bool = ( out === results ); +* // returns true +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +setReadOnly( main, 'ndarray', ndarray ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "ndarray": "main.ndarray" } diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/main.js b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/main.js new file mode 100644 index 000000000000..10535d0a3329 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/main.js @@ -0,0 +1,65 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + +// MAIN // + +/** +* Computes a two-sample Z-test for a strided array. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {string} alternative - alternative hypothesis +* @param {number} alpha - significance level +* @param {number} mu - mean under the null hypothesis +* @param {PositiveNumber} sigmax - known standard deviation of `x` +* @param {Collection} x - input array +* @param {integer} strideX - stride length for `x` +* @param {PositiveNumber} sigmay - known standard deviation of `y` +* @param {Collection} y - input array +* @param {integer} strideY - stride length for `y` +* @param {Object} out - output results object +* @returns {Object} results object +* +* @example +* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* +* var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* +* var results = new Results(); +* var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); +* // returns {...} +* +* var bool = ( out === results ); +* // returns true +*/ +function ztest2( N, alternative, alpha, mu, sigmax, x, strideX, sigmay, y, strideY, out ) { // eslint-disable-line max-len, max-params + return ndarray( N, alternative, alpha, mu, sigmax, x, strideX, stride2offset( N, strideX ), sigmay, y, strideY, stride2offset( N, strideY ), out ); // eslint-disable-line max-len +} + + +// EXPORTS // + +module.exports = ztest2; diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js new file mode 100644 index 000000000000..27c9d8fe9a81 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js @@ -0,0 +1,155 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var quantile = require( '@stdlib/stats/base/dists/normal/quantile' ).factory; +var cdf = require( '@stdlib/stats/base/dists/normal/cdf' ).factory; +var mean = require( '@stdlib/stats/strided/mean' ).ndarray; +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var Float64Array = require( '@stdlib/array/float64' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); + + +// VARIABLES // + +var normalCDF = cdf( 0.0, 1.0 ); +var normalQuantile = quantile( 0.0, 1.0 ); + +// Initialize a workspace for storing confidence intervals: +var WORKSPACE = new Float64Array( 2 ); + + +// MAIN // + +/** +* Computes a two-sample Z-test for a strided array using alternative indexing semantics. +* +* @param {PositiveInteger} N - number of indexed elements +* @param {string} alternative - alternative hypothesis +* @param {number} alpha - significance level +* @param {number} mu - mean under the null hypothesis +* @param {PositiveNumber} sigmax - known standard deviation of `x` +* @param {Collection} x - input array +* @param {integer} strideX - stride length for `x` +* @param {NonNegativeInteger} offsetX - starting index for `x` +* @param {PositiveNumber} sigmay - known standard deviation of `y` +* @param {Collection} y - input array +* @param {integer} strideY - stride length for `y` +* @param {NonNegativeInteger} offsetY - starting index for `y` +* @param {Object} out - output results object +* @returns {Object} results object +* +* @example +* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* +* var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* +* var results = new Results(); +* var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); +* // returns {...} +* +* var bool = ( out === results ); +* // returns true +*/ +function ztest2( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, y, strideY, offsetY, out ) { // eslint-disable-line max-len, max-params + var pValue; + var stderr; + var xmean; + var ymean; + var xvar; + var yvar; + var stat; + var q; + + if ( + N <= 0 || + isnan( alpha ) || + isnan( mu ) || + isnan( sigmax ) || + isnan( sigmay ) || + sigmax <= 0.0 || + sigmay <= 0.0 || + alpha < 0.0 || + alpha > 1.0 + ) { + WORKSPACE[ 0 ] = NaN; + WORKSPACE[ 1 ] = NaN; + out.rejected = false; + out.alternative = alternative; + out.alpha = NaN; + out.pValue = NaN; + out.statistic = NaN; + out.ci = WORKSPACE; + out.nullValue = NaN; + out.xmean = NaN; + out.ymean = NaN; + return out; + } + // Compute the standard error of the mean: + xvar = sigmax * sigmax; + yvar = sigmay * sigmay; + stderr = sqrt( ( xvar / N ) + ( yvar / N ) ); + + // Compute the arithmetic mean of the input array: + xmean = mean( N, x, strideX, offsetX ); + ymean = mean( N, y, strideY, offsetY ); + + // Compute the test statistic (i.e., the z-score, which is the distance of the sample mean from the population mean in units of standard error): + stat = ( xmean - ymean - mu ) / stderr; + + // Compute the p-value and confidence interval... + if ( alternative === 'less' ) { + pValue = normalCDF( stat ); + q = normalQuantile( 1.0 - alpha ); + WORKSPACE[ 0 ] = NINF; + WORKSPACE[ 1 ] = mu + ( ( stat + q ) * stderr ); + } else if ( alternative === 'greater' ) { + pValue = 1.0 - normalCDF( stat ); + q = normalQuantile( 1.0 - alpha ); + WORKSPACE[ 0 ] = mu + ( ( stat - q ) * stderr ); + WORKSPACE[ 1 ] = PINF; + } else { // alt == 'two-sided' + pValue = 2.0 * normalCDF( -abs( stat ) ); + q = normalQuantile( 1.0 - ( alpha / 2.0 ) ); + WORKSPACE[ 0 ] = mu + ( ( stat - q ) * stderr ); + WORKSPACE[ 1 ] = mu + ( ( stat + q ) * stderr ); + } + // Return test results: + out.rejected = ( pValue <= alpha ); + out.alternative = alternative; + out.alpha = alpha; + out.pValue = pValue; + out.statistic = stat; + out.ci = WORKSPACE; + out.nullValue = mu; + out.xmean = xmean; + out.ymean = ymean; + return out; +} + + +// EXPORTS // + +module.exports = ztest2; diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/package.json b/lib/node_modules/@stdlib/stats/strided/ztest2/package.json new file mode 100644 index 000000000000..d89cfa87f3d2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/stats/strided/ztest2", + "version": "0.0.0", + "description": "Compute a two-sample Z-test for a strided array.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "statistics", + "stats", + "mathematics", + "math", + "strided", + "strided array", + "typed", + "array", + "ztest", + "z-test", + "hypothesis", + "testing", + "normality" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.js b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.js new file mode 100644 index 000000000000..e1cc9c485d7f --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.js @@ -0,0 +1,38 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var ztest2 = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ztest2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is a method providing an ndarray interface', function test( t ) { + t.strictEqual( typeof ztest2.ndarray, 'function', 'method is a function' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.main.js b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.main.js new file mode 100644 index 000000000000..c6d434a806a2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.main.js @@ -0,0 +1,328 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var isfinite = require( '@stdlib/math/base/assert/is-finite' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var gfill = require( '@stdlib/blas/ext/base/gfill' ).ndarray; +var normalFactory = require( '@stdlib/random/array/normal' ).factory; +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var ztest2 = require( './../lib' ); + + +// VARIABLES // + +var normal = normalFactory({ + 'seed': 12345 +}); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ztest2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function performs a two-sample Z-test over a strided array (alternative=two-sided)', function test( t ) { + var results; + var out; + var x; + var y; + + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'two-sided', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + out = ztest2( x.length, 'two-sided', 0.1, 100.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 100.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 100.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'two-sided', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a two-sample Z-test over a strided array (alternative=greater)', function test( t ) { + var results; + var out; + var x; + var y; + + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 2.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'greater', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'greater', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( out.ci[ 1 ], PINF, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'greater', 0.1, -1.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'greater', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( out.ci[ 1 ], PINF, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a two-sample Z-test over a strided array (alternative=less)', function test( t ) { + var results; + var out; + var x; + var y; + + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 2.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'less', 0.1, -3.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'less', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( out.ci[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'less', 0.1, 1.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'less', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( out.ci[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` results', function test( t ) { + var results; + var out; + var x; + var y; + + results = new Float64Results(); + x = normal( 10, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10, 0.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( 0, 'two-sided', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); + + out = ztest2( -1, 'two-sided', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a stride parameter', function test( t ) { + var results; + var out; + var x; + var y; + var N; + + N = 10000; + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 1 ); + gfill( N, NaN, y, 2, 1 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 1.0, y, 2, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 1 ); + gfill( N, NaN, y, 2, 1 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 1.0, y, 2, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride parameter', function test( t ) { + var results; + var out; + var x; + var y; + var N; + + N = 10000; + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 1 ); + gfill( N, NaN, y, 2, 1 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, -2, 1.0, y, -2, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 1 ); + gfill( N, NaN, y, 2, 1 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, -2, 1.0, y, -2, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.ndarray.js new file mode 100644 index 000000000000..890c330678fd --- /dev/null +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.ndarray.js @@ -0,0 +1,381 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var isfinite = require( '@stdlib/math/base/assert/is-finite' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var gfill = require( '@stdlib/blas/ext/base/gfill' ).ndarray; +var normalFactory = require( '@stdlib/random/array/normal' ).factory; +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var ztest2 = require( './../lib/ndarray.js' ); + + +// VARIABLES // + +var normal = normalFactory({ + 'seed': 12345 +}); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ztest2, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function performs a two-sample Z-test over a strided array (alternative=two-sided)', function test( t ) { + var results; + var out; + var x; + var y; + + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'two-sided', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + out = ztest2( x.length, 'two-sided', 0.1, 100.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 100.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 100.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'two-sided', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a two-sample Z-test over a strided array (alternative=greater)', function test( t ) { + var results; + var out; + var x; + var y; + + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 2.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'greater', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'greater', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( out.ci[ 1 ], PINF, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'greater', 0.1, -1.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'greater', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( out.ci[ 1 ], PINF, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a two-sample Z-test over a strided array (alternative=less)', function test( t ) { + var results; + var out; + var x; + var y; + + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 2.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'less', 0.1, -3.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'less', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( out.ci[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10000, 0.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( x.length, 'less', 0.1, 1.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'less', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( out.ci[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` results', function test( t ) { + var results; + var out; + var x; + var y; + + results = new Float64Results(); + x = normal( 10, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( 10, 0.0, 1.0, { + 'dtype': 'generic' + }); + + out = ztest2( 0, 'two-sided', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); + + out = ztest2( -1, 'two-sided', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a stride parameter', function test( t ) { + var results; + var out; + var x; + var y; + var N; + + N = 10000; + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 1 ); + gfill( N, NaN, y, 2, 1 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 0, 1.0, y, 2, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 1 ); + gfill( N, NaN, y, 2, 1 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 0, 1.0, y, 2, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative stride parameter', function test( t ) { + var results; + var out; + var x; + var y; + var N; + + N = 10000; + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 1 ); + gfill( N, NaN, y, 2, 1 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, -2, (N-1)*2, 1.0, y, -2, (N-1)*2, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 1 ); + gfill( N, NaN, y, 2, 1 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, -2, (N-1)*2, 1.0, y, -2, (N-1)*2, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports an offset parameter', function test( t ) { + var results; + var out; + var x; + var y; + var N; + + N = 10000; + results = new Float64Results(); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 0.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 0 ); + gfill( N, NaN, y, 2, 0 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 1, 1.0, y, 2, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + // Generate an array with a sufficiently large sample size to effectively guarantee expected results: + x = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + y = normal( N*2, 100.0, 1.0, { + 'dtype': 'generic' + }); + + gfill( N, NaN, x, 2, 0 ); + gfill( N, NaN, y, 2, 0 ); + + out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 1, 1.0, y, 2, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + // t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); From 64fd6dfa2fc09a54d5e4d53a1805f451c6098203 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Thu, 3 Jul 2025 19:44:14 +0000 Subject: [PATCH 2/3] refactor: update signature --- .../@stdlib/stats/strided/ztest2/README.md | 29 +- .../strided/ztest2/benchmark/benchmark.js | 2 +- .../ztest2/benchmark/benchmark.ndarray.js | 4 +- .../stats/strided/ztest2/docs/repl.txt | 60 ++- .../strided/ztest2/docs/types/index.d.ts | 35 +- .../stats/strided/ztest2/docs/types/test.ts | 508 ++++++++++-------- .../stats/strided/ztest2/examples/index.js | 6 +- .../@stdlib/stats/strided/ztest2/lib/index.js | 4 +- .../@stdlib/stats/strided/ztest2/lib/main.js | 15 +- .../stats/strided/ztest2/lib/ndarray.js | 47 +- .../stats/strided/ztest2/test/test.main.js | 56 +- .../stats/strided/ztest2/test/test.ndarray.js | 70 ++- 12 files changed, 458 insertions(+), 378 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/README.md b/lib/node_modules/@stdlib/stats/strided/ztest2/README.md index 8e6dc8b634f7..09d10051c42c 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/README.md +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/README.md @@ -46,7 +46,7 @@ Here, `μX` and `μY` are the true population means of samples `X` and `Y`, resp var ztest2 = require( '@stdlib/stats/strided/ztest2' ); ``` -#### ztest2( N, alternative, alpha, mu, sigmax, x, strideX, sigmay, y, strideY, out ) +#### ztest2( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, y, strideY, out ) Computes a two-sample Z-test for a strided array. @@ -57,7 +57,7 @@ var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; var results = new Results(); -var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); +var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, results ); // returns {...} var bool = ( out === results ); @@ -66,14 +66,15 @@ var bool = ( out === results ); The function has the following parameters: -- **N**: number of indexed elements. +- **NX**: number of indexed elements in `x`. +- **NY**: number of indexed elements in `y`. - **alternative**: [alternative hypothesis][@stdlib/stats/base/ztest/alternatives]. - **alpha**: significance level. -- **mu**: mean value under the null hypothesis. +- **diff**: difference in means under the null hypothesis. - **sigmax**: known standard deviation of `x`. +- **sigmay**: known standard deviation of `y`. - **x**: input array. - **strideX**: stride length for `x`. -- **sigmay**: known standard deviation of `y`. - **y**: input array. - **strideY**: stride length for `y`. - **out**: output [results object][@stdlib/stats/base/ztest/two-sample/results/float64]. @@ -87,7 +88,7 @@ var x = [ 4.0, 0.0, 4.0, 0.0, 6.0, 0.0, 6.0, 0.0, 5.0, 0.0 ]; var y = [ 3.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 7.0, 0.0 ]; var results = new Results(); -var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x, 2, 2.0, y, 2, results ); +var out = ztest2( 5, 5, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 2, y, 2, results ); // returns {...} var bool = ( out === results ); @@ -109,14 +110,14 @@ var y0 = new Float64Array( [ 0.0, 3.0, 3.0, 5.0, 7.0, 7.0 ] ); var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element var results = new Results(); -var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x1, 1, 2.0, y1, 1, results ); +var out = ztest2( 5, 5, 'two-sided', 0.05, 0.0, 1.0, 2.0, x1, 1, y1, 1, results ); // returns {...} var bool = ( out === results ); // returns true ``` -#### ztest2.ndarray( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, y, strideY, offsetY, out ) +#### ztest2.ndarray( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, offsetX, y, strideY, offsetY, out ) Computes a two-sample Z-test for a strided array using alternative indexing semantics. @@ -127,7 +128,7 @@ var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; var results = new Results(); -var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); +var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results ); // returns {...} var bool = ( out === results ); @@ -148,7 +149,7 @@ var x = [ 0.0, 4.0, 0.0, 4.0, 0.0, 6.0, 0.0, 6.0, 0.0, 5.0 ]; var y = [ 0.0, 3.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 7.0 ]; var results = new Results(); -var out = ztest2.ndarray( 5, 'two-sided', 0.05, 0.0, 1.0, x, 2, 1, 2.0, y, 2, 1, results ); +var out = ztest2.ndarray( 5, 5, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 2, 1, y, 2, 1, results ); // returns {...} var bool = ( out === results ); @@ -182,15 +183,15 @@ var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); var normal = require( '@stdlib/random/array/normal' ); var ztest2 = require( '@stdlib/stats/strided/ztest2' ); -var x = normal( 1000, 0.0, 1.0, { +var x = normal( 1000, 4.0, 2.0, { 'dtype': 'generic' }); -var y = normal( 1000, 0.0, 1.0, { +var y = normal( 800, 3.0, 2.0, { 'dtype': 'generic' }); var results = new Results(); -var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, results ); +var out = ztest2( x.length, y.length, 'two-sided', 0.05, 1.0, 2.0, 2.0, x, 1, y, 1, results ); // returns {...} console.log( out.toString() ); @@ -222,7 +223,7 @@ console.log( out.toString() ); [@stdlib/stats/base/ztest/alternatives]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/ztest/alternatives -[@stdlib/stats/base/ztest/one-sample/results/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/ztest/one-sample/results/float64 +[@stdlib/stats/base/ztest/two-sample/results/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/ztest/two-sample/results/float64 [@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js index 7c4ef7de04e3..ed6e2f2ff196 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js @@ -62,7 +62,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, results ); if ( isnan( out.statistic ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js index 9d92cc579945..dd7e08e39302 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js @@ -24,7 +24,7 @@ var bench = require( '@stdlib/bench' ); var normal = require( '@stdlib/random/array/normal' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' ); +var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); var pkg = require( './../package.json' ).name; var ztest2 = require( './../lib/ndarray.js' ); @@ -62,7 +62,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); if ( isnan( out.statistic ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt index c32274b297ea..5867a2c95aa8 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt @@ -1,5 +1,5 @@ -{{alias}}( N, alternative, alpha, mu, sigmax, x, strideX, sigmay, y, strideY, out ) +{{alias}}( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, y, strideY, out ) Computes a two-sample Z-test for a strided array. The `N` and stride parameters determine which elements in the strided array @@ -10,34 +10,37 @@ Parameters ---------- - N: integer - Number of indexed elements. + NX: integer + Number of indexed elements in `x`. + + NY: integer + Number of indexed elements in `y`. alternative: string Alternative hypothesis. Must be one of the following: - - two-sided: mean is not equal to null value. - - greater: mean is larger than null value. - - less: mean is less than null value. + - two-sided: `x` has same mean as `y` + - greater: `x` has larger mean than `y` + - less: `x` has smaller mean than `y` alpha: number Significance level. - mu: number - Value of the mean under the null hypothesis. + diff: number + Difference in means under the null hypothesis. sigmax: number Known standard deviation of `x`. + sigmay: number + Known standard deviation of `y`. + x: Array|TypedArray|Object Input array. strideX: integer Stride length for `x`. - sigmay: number - Known standard deviation of `y`. - y: Array|TypedArray|Object Input array. @@ -56,14 +59,15 @@ -------- > var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; > var x = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; - > var N = x.length; + > var NX = x.length; + > var NY = y.length; > var alt = 'two-sided'; > var out = new {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}(); - > var res = {{alias}}( N, alt, 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, out ); + > var res = {{alias}}( NX, NY, alt, 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, out ); > res.toString() -{{alias}}.ndarray( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, y, strideY, offsetY, out ) +{{alias}}.ndarray( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, offsetX, y, strideY, offsetY, out ) Computes a two-sample Z-test for a strided array using alternative indexing semantics. @@ -73,25 +77,31 @@ Parameters ---------- - N: integer - Number of indexed elements. + NX: integer + Number of indexed elements in `x`. + + NY: integer + Number of indexed elements in `y`. alternative: string Alternative hypothesis. Must be one of the following: - - two-sided: mean is not equal to null value. - - greater: mean is larger than null value. - - less: mean is less than null value. + - two-sided: `x` has same mean as `y` + - greater: `x` has larger mean than `y` + - less: `x` has smaller mean than `y` alpha: number Significance level. - mu: number - Value of the mean under the null hypothesis. + diff: number + Difference in means under the null hypothesis. sigmax: number Known standard deviation of `x`. + sigmay: number + Known standard deviation of `y`. + x: Array|TypedArray|Object Input array. @@ -101,9 +111,6 @@ offsetX: integer Starting index for `x`. - sigmay: number - Known standard deviation of `y`. - y: Array|TypedArray|Object Input array. @@ -125,10 +132,11 @@ -------- > var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; > var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; - > var N = x.length; + > var NX = x.length; + > var NY = y.length; > var alt = 'two-sided'; > var out = new {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}(); - > var res = {{alias}}.ndarray( N, alt, 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, out ); + > var res = {{alias}}.ndarray( NX, NY, alt, 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, out ); > res.toString() See Also diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts index 0790e794fe26..eea94746b44d 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts @@ -96,7 +96,7 @@ interface BaseResults { ci: Float64Array; /** - * Value of the mean under the null hypothesis + * Difference in means under the null hypothesis */ nullValue: number; @@ -133,14 +133,15 @@ interface Routine { /** * Computes a two-sample Z-test for a strided array. * - * @param N - number of indexed elements + * @param NX - number of indexed elements in `x` + * @param NY - number of indexed elements in `y` * @param alternative - alternative hypothesis * @param alpha - significance level - * @param mu - mean under the null hypothesis + * @param diff - difference in means under the null hypothesis * @param sigmax - known standard deviation of `x` + * @param sigmay - known standard deviation of `y` * @param x - input array * @param strideX - stride length for `x` - * @param sigmay - known standard deviation of `y` * @param y - input array * @param strideY - stride length for `y` * @param out - output results object @@ -153,26 +154,27 @@ interface Routine { * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); - * var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); + * var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, results ); * // returns {...} * * var bool = ( out === results ); * // returns true */ - ( N: number, alternative: Alternative, alpha: number, mu: number, sigmax: number, x: InputArray, strideX: number, sigmay: number, y: InputArray, strideY: number, out: T ): Results; + ( NX: number, NY: number, alternative: Alternative, alpha: number, diff: number, sigmax: number, sigmay: number, x: InputArray, strideX: number, y: InputArray, strideY: number, out: T ): Results; /** * Computes a two-sample Z-test for a strided array using alternative indexing semantics. * - * @param N - number of indexed elements + * @param NX - number of indexed elements in `x` + * @param NY - number of indexed elements in `y` * @param alternative - alternative hypothesis * @param alpha - significance level - * @param mu - mean under the null hypothesis + * @param diff - difference in means under the null hypothesis * @param sigmax - known standard deviation of `x` + * @param sigmay - known standard deviation of `y` * @param x - input array * @param strideX - stride length for `x` * @param offsetX - starting index for `x` - * @param sigmay - known standard deviation of `y` * @param y - input array * @param strideY - stride length for `y` * @param offsetY - starting index for `y` @@ -186,26 +188,27 @@ interface Routine { * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); - * var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); + * var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results ); * // returns {...} * * var bool = ( out === results ); * // returns true */ - ndarray( N: number, alternative: Alternative, alpha: number, mu: number, sigmax: number, x: InputArray, strideX: number, offsetX: number, sigmay: number, y: InputArray, strideY: number, offsetY: number, out: T ): Results; + ndarray( NX: number, NY: number, alternative: Alternative, alpha: number, diff: number, sigmax: number, sigmay: number, x: InputArray, strideX: number, offsetX: number, y: InputArray, strideY: number, offsetY: number, out: T ): Results; } /** * Computes a two-sample Z-test for a strided array. * -* @param N - number of indexed elements +* @param NX - number of indexed elements in `x` +* @param NY - number of indexed elements in `y` * @param alternative - alternative hypothesis * @param alpha - significance level -* @param mu - mean under the null hypothesis +* @param diff - difference in means under the null hypothesis * @param sigmax - known standard deviation of `x` +* @param sigmay - known standard deviation of `y` * @param x - input array * @param strideX - stride length for `x` -* @param sigmay - known standard deviation of `y` * @param y - input array * @param strideY - stride length for `y` * @param out - output results object @@ -218,7 +221,7 @@ interface Routine { * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); -* var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); +* var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, results ); * // returns {...} * * var bool = ( out === results ); @@ -231,7 +234,7 @@ interface Routine { * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); -* var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); +* var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results ); * // returns {...} * * var bool = ( out === results ); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/test.ts b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/test.ts index 75632230aee3..189987f05a0a 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/test.ts +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/test.ts @@ -27,9 +27,9 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectType Results - ztest2( x.length, 'greater', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectType Results - ztest2( x.length, 'less', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectType Results + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectType Results + ztest2( x.length, y.length, 'greater', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectType Results + ztest2( x.length, y.length, 'less', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectType Results } // The compiler throws an error if the function is provided a first argument which is not a number... @@ -37,45 +37,44 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( '10', 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( true, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( false, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( null, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( undefined, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( [], 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( {}, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( ( x: number ): number => x, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( '10', y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( true, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( false, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( null, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( undefined, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( [], y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( {}, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( ( x: number ): number => x, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the function is provided a second argument which is not a valid string... +// The compiler throws an error if the function is provided a second argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, '10', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 5, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, true, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, false, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, null, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, undefined, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, [], 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, {}, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, ( x: number ): number => x, 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, '10', 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, true, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, false, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, null, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, undefined, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, [], 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, {}, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, ( x: number ): number => x, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the function is provided a third argument which is not a number... +// The compiler throws an error if the function is provided a third argument which is not a valid string... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', '10', 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', true, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', false, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', null, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', undefined, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', [], 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', {}, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', ( x: number ): number => x, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, '10', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, true, 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, false, 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, null, 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, undefined, 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, [], 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, {}, 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, ( x: number ): number => x, 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError } // The compiler throws an error if the function is provided a fourth argument which is not a number... @@ -83,14 +82,14 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, '10', 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, true, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, false, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, null, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, undefined, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, [], 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, {}, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, ( x: number ): number => x, 1.0, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', '10', 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', true, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', false, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', null, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', undefined, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', [], 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', {}, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', ( x: number ): number => x, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError } // The compiler throws an error if the function is provided a fifth argument which is not a number... @@ -98,28 +97,29 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, 0.0, '10', x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, true, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, false, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, null, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, undefined, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, [], x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, {}, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, ( x: number ): number => x, x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, '10', 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, true, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, false, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, null, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, undefined, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, [], 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, {}, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, ( x: number ): number => x, 1.0, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the function is provided a sixth argument which is not an array-like object... +// The compiler throws an error if the function is provided a sixth argument which is not a number... { + const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, 10, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, '10', 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, true, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, false, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, null, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, undefined, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, {}, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, ( x: number ): number => x, 1, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, '10', 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, true, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, false, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, null, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, undefined, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, [], 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, {}, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, ( x: number ): number => x, 1.0, x, 1, y, 1, new Float64Results() ); // $ExpectError } // The compiler throws an error if the function is provided a seventh argument which is not a number... @@ -127,73 +127,89 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, '10', 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, true, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, false, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, null, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, undefined, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, [], 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, {}, 1.0, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, ( x: number ): number => x, 1.0, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, '10', x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, true, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, false, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, null, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, undefined, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, [], x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, {}, x, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, ( x: number ): number => x, x, 1, y, 1, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the function is provided a eigth argument which is not an array-like object... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, 10, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, '10', 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, true, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, false, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, null, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, undefined, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, {}, 1, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, ( x: number ): number => x, 1, y, 1, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the function is provided a eigth argument which is not a number... +// The compiler throws an error if the function is provided a ninth argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, '10', y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, true, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, false, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, null, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, undefined, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, [], y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, {}, y, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, ( x: number ): number => x, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, '10', y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, true, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, false, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, null, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, undefined, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, [], y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, {}, y, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, ( x: number ): number => x, y, 1, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the function is provided a ninth argument which is not an array-like object... +// The compiler throws an error if the function is provided a tenth argument which is not an array-like object... { const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, 10, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, '10', 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, true, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, false, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, null, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, undefined, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, {}, 1, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, ( x: number ): number => x, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 10, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, '10', 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, true, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, false, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, null, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, undefined, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, {}, 1, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, ( x: number ): number => x, 1, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the function is provided a tenth argument which is not a number... +// The compiler throws an error if the function is provided a eleventh argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, '10', new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, true, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, false, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, null, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, undefined, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, [], new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, {}, new Float64Results() ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, ( x: number ): number => x, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, '10', new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, true, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, false, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, null, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, undefined, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, [], new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, {}, new Float64Results() ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, ( x: number ): number => x, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the function is provided an eleventh argument which is not a results object... +// The compiler throws an error if the function is provided an twelfth argument which is not a results object... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, '10' ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, true ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, false ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, null ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, undefined ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, [] ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, {} ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, ( x: number ): number => x ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, '10' ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, true ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, false ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, null ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, undefined ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, [] ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, {} ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the function is provided an unsupported number of arguments... @@ -203,16 +219,17 @@ import ztest2 = require( './index' ); ztest2(); // $ExpectError ztest2( x.length ); // $ExpectError - ztest2( x.length, 'two-sided' ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05 ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0 ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0 ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1 ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0 ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1 ); // $ExpectError - ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, new Float64Results(), {} ); // $ExpectError + ztest2( x.length, y.length ); // $ExpectError + ztest2( x.length, y.length, 'two-sided' ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05 ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0 ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0 ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0 ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1 ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1 ); // $ExpectError + ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, new Float64Results(), {} ); // $ExpectError } // Attached to main export is an `ndarray` method which returns a results object... @@ -220,9 +237,9 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectType Results - ztest2.ndarray( x.length, 'greater', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectType Results - ztest2.ndarray( x.length, 'less', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectType Results + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectType Results + ztest2.ndarray( x.length, y.length, 'greater', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectType Results + ztest2.ndarray( x.length, y.length, 'less', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectType Results } // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number... @@ -230,45 +247,45 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( '10', 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( true, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( false, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( null, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( undefined, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( [], 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( {}, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( ( x: number ): number => x, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( '10', y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( true, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( false, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( null, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( undefined, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( [], y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( {}, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( ( x: number ): number => x, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a second argument which is not a valid string... +// The compiler throws an error if the `ndarray` method is provided a second argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, '10', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 5, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, true, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, false, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, null, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, undefined, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, [], 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, {}, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, ( x: number ): number => x, 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, '10', 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, true, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, false, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, null, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, undefined, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, [], 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, {}, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, ( x: number ): number => x, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a third argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a third argument which is not a valid string... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', '10', 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', true, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', false, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', null, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', undefined, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', [], 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', {}, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', ( x: number ): number => x, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, '10', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 5, 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, true, 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, false, 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, null, 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, undefined, 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, [], 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, {}, 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, ( x: number ): number => x, 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number... @@ -276,14 +293,14 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, '10', 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, true, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, false, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, null, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, undefined, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, [], 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, {}, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, ( x: number ): number => x, 1, 0.0, x, 1, 0, 0.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', '10', 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', true, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', false, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', null, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', undefined, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', [], 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', {}, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', ( x: number ): number => x, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a number... @@ -291,28 +308,29 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, '10', x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, true, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, false, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, null, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, undefined, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, [], x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, {}, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, ( x: number ): number => x, x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, '10', 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, true, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, false, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, null, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, undefined, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, [], 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, {}, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, ( x: number ): number => x, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not an array-like object... +// The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number... { + const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, 10, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, '10', 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, true, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, false, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, null, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, undefined, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, {}, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, ( x: number ): number => x, 1, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, '10', 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, true, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, false, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, null, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, undefined, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, [], 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, {}, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, ( x: number ): number => x, 1.0, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number... @@ -320,29 +338,29 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, '10', 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, true, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, false, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, null, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, undefined, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, [], 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, {}, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, ( x: number ): number => x, 0, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, '10', x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, true, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, false, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, null, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, undefined, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, [], x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, {}, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, ( x: number ): number => x, x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a eigth argument which is not an array-like object... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, '10', 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, true, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, false, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, null, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, undefined, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, [], 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, {}, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, ( x: number ): number => x, 1.0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, 10, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, '10', 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, true, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, false, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, null, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, undefined, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, {}, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, ( x: number ): number => x, 1, 0, y, 1, 0, new Float64Results() ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided a ninth argument which is not a number... @@ -350,73 +368,89 @@ import ztest2 = require( './index' ); const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, '10', y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, true, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, false, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, null, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, undefined, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, [], y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, {}, y, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, ( x: number ): number => x, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, '10', 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, true, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, false, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, null, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, undefined, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, [], 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, {}, 0, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, ( x: number ): number => x, 0, y, 1, 0, new Float64Results() ); // $ExpectError +} + +// The compiler throws an error if the `ndarray` method is provided an tenth argument which is not a number... +{ + const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); + + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, '10', y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, true, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, false, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, null, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, undefined, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, [], y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, {}, y, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, ( x: number ): number => x, y, 1, 0, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a tenth argument which is not an array-like object... +// The compiler throws an error if the `ndarray` method is provided a eleventh argument which is not an array-like object... { const x = new Float64Array( 10 ); + const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, 10, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, '10', 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, true, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, false, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, null, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, undefined, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, {}, 1, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, ( x: number ): number => x, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, 10, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, '10', 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, true, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, false, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, null, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, undefined, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, {}, 1, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, ( x: number ): number => x, 1, 0, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a eleventh argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided a twelfth argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, '10', 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, true, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, false, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, null, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, undefined, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, [], 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, {}, 0, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, ( x: number ): number => x, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, '10', 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, true, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, false, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, null, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, undefined, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, [], 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, {}, 0, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, ( x: number ): number => x, 0, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided an twelfth argument which is not a number... +// The compiler throws an error if the `ndarray` method is provided an thirteenth argument which is not a number... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, '10', new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, true, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, false, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, null, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, undefined, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, [], new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, {}, new Float64Results() ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, ( x: number ): number => x, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, '10', new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, true, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, false, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, null, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, undefined, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, [], new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, {}, new Float64Results() ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, ( x: number ): number => x, new Float64Results() ); // $ExpectError } -// The compiler throws an error if the `ndarray` method is provided a thirteenth argument which is not a results object... +// The compiler throws an error if the `ndarray` method is provided a fourteenth argument which is not a results object... { const x = new Float64Array( 10 ); const y = new Float64Array( 10 ); - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, '10' ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, true ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, false ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, null ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, undefined ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, [] ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, {} ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, ( x: number ): number => x ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, '10' ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, true ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, false ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, null ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, undefined ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, [] ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, {} ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, ( x: number ): number => x ); // $ExpectError } // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments... @@ -426,16 +460,16 @@ import ztest2 = require( './index' ); ztest2.ndarray(); // $ExpectError ztest2.ndarray( x.length ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided' ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05 ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0 ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0 ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1 ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0 ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0 ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1 ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0 ); // $ExpectError - ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, new Float64Results(), {} ); // $ExpectError + ztest2.ndarray( x.length, y.length ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05 ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0 ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0 ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0 ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1 ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0 ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1 ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0 ); // $ExpectError + ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, new Float64Results(), {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/examples/index.js b/lib/node_modules/@stdlib/stats/strided/ztest2/examples/index.js index a17cb5960980..ef67a5e78259 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/examples/index.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/examples/index.js @@ -22,15 +22,15 @@ var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); var normal = require( '@stdlib/random/array/normal' ); var ztest2 = require( './../lib' ); -var x = normal( 1000, 0.0, 1.0, { +var x = normal( 1000, 4.0, 2.0, { 'dtype': 'generic' }); -var y = normal( 1000, 0.0, 1.0, { +var y = normal( 800, 3.0, 2.0, { 'dtype': 'generic' }); var results = new Results(); -var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, results ); +var out = ztest2( x.length, y.length, 'two-sided', 0.05, 1.0, 2.0, 2.0, x, 1, y, 1, results ); // returns {...} console.log( out.toString() ); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/index.js b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/index.js index e2f5ddaa1eb1..e20b10914b72 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/index.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/index.js @@ -31,7 +31,7 @@ * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); -* var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); +* var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, results ); * // returns {...} * * var bool = ( out === results ); @@ -45,7 +45,7 @@ * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); -* var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); +* var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results ); * // returns {...} * * var bool = ( out === results ); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/main.js b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/main.js index 10535d0a3329..078d4e9ce766 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/main.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/main.js @@ -29,14 +29,15 @@ var ndarray = require( './ndarray.js' ); /** * Computes a two-sample Z-test for a strided array. * -* @param {PositiveInteger} N - number of indexed elements -* @param {string} alternative - alternative hypothesis +* @param {PositiveInteger} NX - number of indexed elements in `x` +* @param {PositiveInteger} NY - number of indexed elements in `y` +* @param {(integer|string)} alternative - alternative hypothesis * @param {number} alpha - significance level -* @param {number} mu - mean under the null hypothesis +* @param {number} diff - difference in means under the null hypothesis * @param {PositiveNumber} sigmax - known standard deviation of `x` +* @param {PositiveNumber} sigmay - known standard deviation of `y` * @param {Collection} x - input array * @param {integer} strideX - stride length for `x` -* @param {PositiveNumber} sigmay - known standard deviation of `y` * @param {Collection} y - input array * @param {integer} strideY - stride length for `y` * @param {Object} out - output results object @@ -49,14 +50,14 @@ var ndarray = require( './ndarray.js' ); * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); -* var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results ); +* var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, results ); * // returns {...} * * var bool = ( out === results ); * // returns true */ -function ztest2( N, alternative, alpha, mu, sigmax, x, strideX, sigmay, y, strideY, out ) { // eslint-disable-line max-len, max-params - return ndarray( N, alternative, alpha, mu, sigmax, x, strideX, stride2offset( N, strideX ), sigmay, y, strideY, stride2offset( N, strideY ), out ); // eslint-disable-line max-len +function ztest2( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, y, strideY, out ) { // eslint-disable-line max-len, max-params + return ndarray( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, stride2offset( NX, strideX ), y, strideY, stride2offset( NY, strideY ), out ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js index 27c9d8fe9a81..57543f7ca880 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js @@ -20,6 +20,7 @@ // MODULES // +var resolveStr = require( '@stdlib/stats/base/ztest/alternative-resolve-str' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var quantile = require( '@stdlib/stats/base/dists/normal/quantile' ).factory; var cdf = require( '@stdlib/stats/base/dists/normal/cdf' ).factory; @@ -45,15 +46,16 @@ var WORKSPACE = new Float64Array( 2 ); /** * Computes a two-sample Z-test for a strided array using alternative indexing semantics. * -* @param {PositiveInteger} N - number of indexed elements -* @param {string} alternative - alternative hypothesis +* @param {PositiveInteger} NX - number of indexed elements in `x` +* @param {PositiveInteger} NY - number of indexed elements in `y` +* @param {(integer|string)} alternative - alternative hypothesis * @param {number} alpha - significance level -* @param {number} mu - mean under the null hypothesis +* @param {number} diff - difference in means under the null hypothesis * @param {PositiveNumber} sigmax - known standard deviation of `x` +* @param {PositiveNumber} sigmay - known standard deviation of `y` * @param {Collection} x - input array * @param {integer} strideX - stride length for `x` * @param {NonNegativeInteger} offsetX - starting index for `x` -* @param {PositiveNumber} sigmay - known standard deviation of `y` * @param {Collection} y - input array * @param {integer} strideY - stride length for `y` * @param {NonNegativeInteger} offsetY - starting index for `y` @@ -67,13 +69,13 @@ var WORKSPACE = new Float64Array( 2 ); * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); -* var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results ); +* var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results ); * // returns {...} * * var bool = ( out === results ); * // returns true */ -function ztest2( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, y, strideY, offsetY, out ) { // eslint-disable-line max-len, max-params +function ztest2( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, offsetX, y, strideY, offsetY, out ) { // eslint-disable-line max-len, max-params var pValue; var stderr; var xmean; @@ -81,12 +83,15 @@ function ztest2( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, var xvar; var yvar; var stat; + var alt; var q; + alt = resolveStr( alternative ); if ( - N <= 0 || + NX <= 0 || + NY <= 0 || isnan( alpha ) || - isnan( mu ) || + isnan( diff ) || isnan( sigmax ) || isnan( sigmay ) || sigmax <= 0.0 || @@ -97,7 +102,7 @@ function ztest2( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, WORKSPACE[ 0 ] = NaN; WORKSPACE[ 1 ] = NaN; out.rejected = false; - out.alternative = alternative; + out.alternative = alt; out.alpha = NaN; out.pValue = NaN; out.statistic = NaN; @@ -110,40 +115,40 @@ function ztest2( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, // Compute the standard error of the mean: xvar = sigmax * sigmax; yvar = sigmay * sigmay; - stderr = sqrt( ( xvar / N ) + ( yvar / N ) ); + stderr = sqrt( ( xvar / NX ) + ( yvar / NY ) ); // Compute the arithmetic mean of the input array: - xmean = mean( N, x, strideX, offsetX ); - ymean = mean( N, y, strideY, offsetY ); + xmean = mean( NX, x, strideX, offsetX ); + ymean = mean( NY, y, strideY, offsetY ); // Compute the test statistic (i.e., the z-score, which is the distance of the sample mean from the population mean in units of standard error): - stat = ( xmean - ymean - mu ) / stderr; + stat = ( xmean - ymean - diff ) / stderr; // Compute the p-value and confidence interval... - if ( alternative === 'less' ) { + if ( alt === 'less' ) { pValue = normalCDF( stat ); q = normalQuantile( 1.0 - alpha ); WORKSPACE[ 0 ] = NINF; - WORKSPACE[ 1 ] = mu + ( ( stat + q ) * stderr ); - } else if ( alternative === 'greater' ) { + WORKSPACE[ 1 ] = diff + ( ( stat + q ) * stderr ); + } else if ( alt === 'greater' ) { pValue = 1.0 - normalCDF( stat ); q = normalQuantile( 1.0 - alpha ); - WORKSPACE[ 0 ] = mu + ( ( stat - q ) * stderr ); + WORKSPACE[ 0 ] = diff + ( ( stat - q ) * stderr ); WORKSPACE[ 1 ] = PINF; } else { // alt == 'two-sided' pValue = 2.0 * normalCDF( -abs( stat ) ); q = normalQuantile( 1.0 - ( alpha / 2.0 ) ); - WORKSPACE[ 0 ] = mu + ( ( stat - q ) * stderr ); - WORKSPACE[ 1 ] = mu + ( ( stat + q ) * stderr ); + WORKSPACE[ 0 ] = diff + ( ( stat - q ) * stderr ); + WORKSPACE[ 1 ] = diff + ( ( stat + q ) * stderr ); } // Return test results: out.rejected = ( pValue <= alpha ); - out.alternative = alternative; out.alpha = alpha; out.pValue = pValue; out.statistic = stat; out.ci = WORKSPACE; - out.nullValue = mu; + out.alternative = alt; + out.nullValue = diff; out.xmean = xmean; out.ymean = ymean; return out; diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.main.js b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.main.js index c6d434a806a2..ce35684aa0ef 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.main.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.main.js @@ -62,7 +62,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati 'dtype': 'generic' }); - out = ztest2( x.length, 'two-sided', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, y.length, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -71,7 +71,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); - out = ztest2( x.length, 'two-sided', 0.1, 100.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, y.length, 'two-sided', 0.1, 10.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -81,14 +81,14 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); // Generate an array with a sufficiently large sample size to effectively guarantee expected results: - x = normal( 10000, 100.0, 1.0, { + x = normal( 10000, 4.0, 1.0, { 'dtype': 'generic' }); - y = normal( 10000, 100.0, 1.0, { + y = normal( 10000, 2.0, 1.0, { 'dtype': 'generic' }); - out = ztest2( x.length, 'two-sided', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, y.length, 'two-sided', 0.1, 2.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -116,7 +116,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati 'dtype': 'generic' }); - out = ztest2( x.length, 'greater', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, y.length, 'greater', 0.1, 0.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'greater', 'returns expected value' ); @@ -133,7 +133,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati 'dtype': 'generic' }); - out = ztest2( x.length, 'greater', 0.1, -1.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, y.length, 'greater', 0.1, -1.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'greater', 'returns expected value' ); @@ -154,14 +154,14 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati results = new Float64Results(); // Generate an array with a sufficiently large sample size to effectively guarantee expected results: - x = normal( 10000, 0.0, 1.0, { + x = normal( 10000, 2.0, 1.0, { 'dtype': 'generic' }); - y = normal( 10000, 2.0, 1.0, { + y = normal( 10000, 0.0, 1.0, { 'dtype': 'generic' }); - out = ztest2( x.length, 'less', 0.1, -3.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, y.length, 'less', 0.1, 0.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'less', 'returns expected value' ); @@ -178,7 +178,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati 'dtype': 'generic' }); - out = ztest2( x.length, 'less', 0.1, 1.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, y.length, 'less', 0.1, 1.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'less', 'returns expected value' ); @@ -190,7 +190,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` results', function test( t ) { +tape( 'if provided an `NX` or `NY` parameter less than or equal to `0`, the function returns `NaN` results', function test( t ) { var results; var out; var x; @@ -204,14 +204,28 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu 'dtype': 'generic' }); - out = ztest2( 0, 'two-sided', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( 0, y.length, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); + + out = ztest2( -1, y.length, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); - out = ztest2( -1, 'two-sided', 0.1, 0.0, 1.0, x, 1, 1.0, y, 1, results ); + out = ztest2( x.length, 0, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, y, 1, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); + + out = ztest2( x.length, -1, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, y, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -242,7 +256,7 @@ tape( 'the function supports a stride parameter', function test( t ) { gfill( N, NaN, x, 2, 1 ); gfill( N, NaN, y, 2, 1 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 1.0, y, 2, results ); + out = ztest2( N, N, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 2, y, 2, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -252,19 +266,19 @@ tape( 'the function supports a stride parameter', function test( t ) { t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); // Generate an array with a sufficiently large sample size to effectively guarantee expected results: - x = normal( N*2, 100.0, 1.0, { + x = normal( N*2, 4.0, 1.0, { 'dtype': 'generic' }); - y = normal( N*2, 100.0, 1.0, { + y = normal( N*2, 2.0, 1.0, { 'dtype': 'generic' }); gfill( N, NaN, x, 2, 1 ); gfill( N, NaN, y, 2, 1 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 1.0, y, 2, results ); + out = ztest2( N, N, 'two-sided', 0.1, 10.0, 1.0, 1.0, x, 2, y, 2, results ); t.strictEqual( out, results, 'returns expected value' ); - t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); @@ -295,7 +309,7 @@ tape( 'the function supports a negative stride parameter', function test( t ) { gfill( N, NaN, x, 2, 1 ); gfill( N, NaN, y, 2, 1 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, -2, 1.0, y, -2, results ); + out = ztest2( N, N, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, -2, y, -2, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -315,7 +329,7 @@ tape( 'the function supports a negative stride parameter', function test( t ) { gfill( N, NaN, x, 2, 1 ); gfill( N, NaN, y, 2, 1 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, -2, 1.0, y, -2, results ); + out = ztest2( N, N, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, -2, y, -2, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.ndarray.js index 890c330678fd..8ba65680c52f 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/test/test.ndarray.js @@ -62,7 +62,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati 'dtype': 'generic' }); - out = ztest2( x.length, 'two-sided', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, y.length, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -71,7 +71,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati t.strictEqual( isfinite( out.ci[ 0 ] ), true, 'returns expected value' ); t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); - out = ztest2( x.length, 'two-sided', 0.1, 100.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, y.length, 'two-sided', 0.1, 10.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -81,14 +81,14 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); // Generate an array with a sufficiently large sample size to effectively guarantee expected results: - x = normal( 10000, 100.0, 1.0, { + x = normal( 10000, 4.0, 1.0, { 'dtype': 'generic' }); - y = normal( 10000, 100.0, 1.0, { + y = normal( 10000, 2.0, 1.0, { 'dtype': 'generic' }); - out = ztest2( x.length, 'two-sided', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, y.length, 'two-sided', 0.1, 2.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -116,7 +116,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati 'dtype': 'generic' }); - out = ztest2( x.length, 'greater', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, y.length, 'greater', 0.1, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'greater', 'returns expected value' ); @@ -133,7 +133,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati 'dtype': 'generic' }); - out = ztest2( x.length, 'greater', 0.1, -1.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, y.length, 'greater', 0.1, -1.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'greater', 'returns expected value' ); @@ -154,14 +154,14 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati results = new Float64Results(); // Generate an array with a sufficiently large sample size to effectively guarantee expected results: - x = normal( 10000, 0.0, 1.0, { + x = normal( 10000, 2.0, 1.0, { 'dtype': 'generic' }); - y = normal( 10000, 2.0, 1.0, { + y = normal( 10000, 0.0, 1.0, { 'dtype': 'generic' }); - out = ztest2( x.length, 'less', 0.1, -3.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, y.length, 'less', 0.1, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'less', 'returns expected value' ); @@ -178,7 +178,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati 'dtype': 'generic' }); - out = ztest2( x.length, 'less', 0.1, 1.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, y.length, 'less', 0.1, 1.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'less', 'returns expected value' ); @@ -190,7 +190,7 @@ tape( 'the function performs a two-sample Z-test over a strided array (alternati t.end(); }); -tape( 'if provided an `N` parameter less than or equal to `0`, the function returns `NaN` results', function test( t ) { +tape( 'if provided an `NX` or `NY` parameter less than or equal to `0`, the function returns `NaN` results', function test( t ) { var results; var out; var x; @@ -204,14 +204,28 @@ tape( 'if provided an `N` parameter less than or equal to `0`, the function retu 'dtype': 'generic' }); - out = ztest2( 0, 'two-sided', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( 0, y.length, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); + + out = ztest2( -1, y.length, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); - out = ztest2( -1, 'two-sided', 0.1, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results ); + out = ztest2( x.length, 0, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); + t.strictEqual( out, results, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); + t.strictEqual( isnan( out.statistic ), true, 'returns expected value' ); + t.strictEqual( isnan( out.pValue ), true, 'returns expected value' ); + + out = ztest2( x.length, -1, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -242,7 +256,7 @@ tape( 'the function supports a stride parameter', function test( t ) { gfill( N, NaN, x, 2, 1 ); gfill( N, NaN, y, 2, 1 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 0, 1.0, y, 2, 0, results ); + out = ztest2( N, N, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 2, 0, y, 2, 0, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -252,19 +266,19 @@ tape( 'the function supports a stride parameter', function test( t ) { t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); // Generate an array with a sufficiently large sample size to effectively guarantee expected results: - x = normal( N*2, 100.0, 1.0, { + x = normal( N*2, 4.0, 1.0, { 'dtype': 'generic' }); - y = normal( N*2, 100.0, 1.0, { + y = normal( N*2, 2.0, 1.0, { 'dtype': 'generic' }); gfill( N, NaN, x, 2, 1 ); gfill( N, NaN, y, 2, 1 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 0, 1.0, y, 2, 0, results ); + out = ztest2( N, N, 'two-sided', 0.1, 10.0, 1.0, 1.0, x, 2, 0, y, 2, 0, results ); t.strictEqual( out, results, 'returns expected value' ); - t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); @@ -295,7 +309,7 @@ tape( 'the function supports a negative stride parameter', function test( t ) { gfill( N, NaN, x, 2, 1 ); gfill( N, NaN, y, 2, 1 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, -2, (N-1)*2, 1.0, y, -2, (N-1)*2, results ); + out = ztest2( N, N, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, -2, (N-1)*2, y, -2, (N-1)*2, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -305,17 +319,17 @@ tape( 'the function supports a negative stride parameter', function test( t ) { t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); // Generate an array with a sufficiently large sample size to effectively guarantee expected results: - x = normal( N*2, 100.0, 1.0, { + x = normal( N*2, 4.0, 1.0, { 'dtype': 'generic' }); - y = normal( N*2, 100.0, 1.0, { + y = normal( N*2, 2.0, 1.0, { 'dtype': 'generic' }); gfill( N, NaN, x, 2, 1 ); gfill( N, NaN, y, 2, 1 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, -2, (N-1)*2, 1.0, y, -2, (N-1)*2, results ); + out = ztest2( N, N, 'two-sided', 0.1, 10.0, 1.0, 1.0, x, -2, (N-1)*2, y, -2, (N-1)*2, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, true, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -348,7 +362,7 @@ tape( 'the function supports an offset parameter', function test( t ) { gfill( N, NaN, x, 2, 0 ); gfill( N, NaN, y, 2, 0 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 1, 1.0, y, 2, 1, results ); + out = ztest2( N, N, 'two-sided', 0.1, 0.0, 1.0, 1.0, x, 2, 1, y, 2, 1, results ); t.strictEqual( out, results, 'returns expected value' ); t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); @@ -358,19 +372,19 @@ tape( 'the function supports an offset parameter', function test( t ) { t.strictEqual( isfinite( out.ci[ 1 ] ), true, 'returns expected value' ); // Generate an array with a sufficiently large sample size to effectively guarantee expected results: - x = normal( N*2, 100.0, 1.0, { + x = normal( N*2, 4.0, 1.0, { 'dtype': 'generic' }); - y = normal( N*2, 100.0, 1.0, { + y = normal( N*2, 2.0, 1.0, { 'dtype': 'generic' }); gfill( N, NaN, x, 2, 0 ); gfill( N, NaN, y, 2, 0 ); - out = ztest2( N, 'two-sided', 0.1, 0.0, 1.0, x, 2, 1, 1.0, y, 2, 1, results ); + out = ztest2( N, N, 'two-sided', 0.1, 2.0, 1.0, 1.0, x, 2, 1, y, 2, 1, results ); t.strictEqual( out, results, 'returns expected value' ); - // t.strictEqual( out.rejected, false, 'returns expected value' ); + t.strictEqual( out.rejected, false, 'returns expected value' ); t.strictEqual( out.alternative, 'two-sided', 'returns expected value' ); t.strictEqual( isnan( out.statistic ), false, 'returns expected value' ); t.strictEqual( isnan( out.pValue ), false, 'returns expected value' ); From a5ea81bcb4e447ebca8d4a1cc177a173383f97c5 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Fri, 4 Jul 2025 14:39:17 +0000 Subject: [PATCH 3/3] fix: update ztest2 function call --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js index 57543f7ca880..9ae463e4fe85 100644 --- a/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/strided/ztest2/lib/ndarray.js @@ -69,7 +69,7 @@ var WORKSPACE = new Float64Array( 2 ); * var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; * * var results = new Results(); -* var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results ); +* var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results ); * // returns {...} * * var bool = ( out === results );