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(); +});