From 644a4614d12542a05b847397faeebde5961160c3 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sat, 19 Jul 2025 19:05:10 +0000 Subject: [PATCH 1/3] feat: add `stats/base/ndarray/ztest2` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: skipped - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../stats/base/ndarray/ztest2/README.md | 185 +++++++++ .../ndarray/ztest2/benchmark/benchmark.js | 128 +++++++ .../stats/base/ndarray/ztest2/docs/repl.txt | 68 ++++ .../base/ndarray/ztest2/docs/types/index.d.ts | 92 +++++ .../base/ndarray/ztest2/docs/types/test.ts | 57 +++ .../base/ndarray/ztest2/examples/index.js | 64 ++++ .../stats/base/ndarray/ztest2/lib/index.js | 78 ++++ .../stats/base/ndarray/ztest2/lib/main.js | 123 ++++++ .../stats/base/ndarray/ztest2/package.json | 65 ++++ .../stats/base/ndarray/ztest2/test/test.js | 352 ++++++++++++++++++ 10 files changed, 1212 insertions(+) create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/examples/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/package.json create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/ztest2/test/test.js diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md new file mode 100644 index 000000000000..69ee6d503b8b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md @@ -0,0 +1,185 @@ + + +# ztest2 + +> Compute a two-sample Z-test for two one-dimensional ndarrays. + +
+ +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/base/ndarray/ztest2' ); +``` + +#### ztest2( arrays ) + +Computes a two-sample Z-test for two one-dimensional ndarrays. + +```javascript +var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' ); +var structFactory = require( '@stdlib/array/struct-factory' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); + +var opts = { + 'dtype': 'generic' +}; + +var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +var x = new ndarray( opts.dtype, xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); + +var ybuf = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +var y = new ndarray( opts.dtype, ybuf, [ 5 ], [ 1 ], 0, 'row-major' ); + +var alt = scalar2ndarray( resolveEnum( 'two-sided' ), { + 'dtype': 'int8' +}); +var alpha = scalar2ndarray( 0.05, opts ); +var diff = scalar2ndarray( 0.0, opts ); +var sigmax = scalar2ndarray( 1.0, opts ); +var sigmay = scalar2ndarray( 2.0, opts ); + +var ResultsArray = structFactory( Float64Results ); +var out = new ndarray( Float64Results, new ResultsArray( 1 ), [], [ 0 ], 0, 'row-major' ); + +var v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + +var bool = ( v === out ); +// returns true +``` + +The function has the following parameters: + +- **arrays**: array-like object containing the following ndarrays in order: + + 1. first one-dimensional input ndarray. + 1. second one-dimensional input ndarray. + 2. a zero-dimensional output ndarray containing a [results object][@stdlib/stats/base/ztest/two-sample/results/float64]. + 3. a zero-dimensional ndarray specifying the alternative hypothesis. + 4. a zero-dimensional ndarray specifying the significance level. + 5. a zero-dimensional ndarray specifying the difference in means under the null hypothesis. + 6. a zero-dimensional ndarray specifying the known standard deviation of first one-dimensional input ndarray. + 7. a zero-dimensional ndarray specifying the known standard deviation of second one-dimensional input ndarray. + +
+ + + +
+ +## Notes + +- As a general rule of thumb, a Z-test is most reliable for sample sizes greater than `50`. For smaller sample sizes or when the standard deviation is unknown, prefer a t-test. + +
+ + + +
+ +## Examples + + + +```javascript +var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' ); +var structFactory = require( '@stdlib/array/struct-factory' ); +var normal = require( '@stdlib/random/array/normal' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ztest2 = require( '@stdlib/stats/base/ndarray/ztest2' ); + +var opts = { + 'dtype': 'generic' +}; + +// Create a one-dimensional ndarrays containing pseudorandom numbers drawn from a normal distribution: +var xbuf = normal( 100, 0.0, 1.0, opts ); +var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var ybuf = normal( 100, 0.0, 1.0, opts ); +var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( y ) ); + +// Specify the alternative hypothesis: +var alt = scalar2ndarray( resolveEnum( 'two-sided' ), { + 'dtype': 'int8' +}); + +// Specify the significance level: +var alpha = scalar2ndarray( 0.05, opts ); + +// Specify the difference in means under the null hypothesis: +var diff = scalar2ndarray( 0.0, opts ); + +// Specify the known standard deviations: +var sigmax = scalar2ndarray( 1.0, opts ); +var sigmay = scalar2ndarray( 1.0, opts ); + +// Create a zero-dimensional results ndarray: +var ResultsArray = structFactory( Float64Results ); +var out = new ndarray( Float64Results, new ResultsArray( 1 ), [], [ 0 ], 0, 'row-major' ); + +// Perform a Z-test: +var v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); +console.log( v.get().toString() ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/benchmark/benchmark.js new file mode 100644 index 000000000000..b932b1e371b8 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/benchmark/benchmark.js @@ -0,0 +1,128 @@ +/** +* @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 ndarray = require( '@stdlib/ndarray/base/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' ); +var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' ); +var structFactory = require( '@stdlib/array/struct-factory' ); +var pkg = require( './../package.json' ).name; +var ztest2 = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'generic' +}; +var ResultsArray = structFactory( Float64Results ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var sigmax; + var sigmay; + var alpha; + var diff; + var xbuf; + var ybuf; + var obuf; + var out; + var alt; + var x; + var y; + + xbuf = normal( len, 0.0, 1.0, options ); + x = new ndarray( options.dtype, xbuf, [ len ], [ 1 ], 0, 'row-major' ); + + ybuf = normal( len, 0.0, 1.0, options ); + y = new ndarray( options.dtype, ybuf, [ len ], [ 1 ], 0, 'row-major' ); + + obuf = new ResultsArray( 1 ); + out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); + + alt = scalar2ndarray( resolveEnum( 'two-sided' ), 'int8', 'row-major' ); + alpha = scalar2ndarray( 0.05, options.dtype, 'row-major' ); + diff = scalar2ndarray( 0.0, options.dtype, 'row-major' ); + sigmax = scalar2ndarray( 1.0, options.dtype, 'row-major' ); + sigmay = scalar2ndarray( 1.0, options.dtype, 'row-major' ); + + return benchmark; + + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + if ( typeof v !== 'object' ) { + b.fail( 'should return an ndarray' ); + } + } + b.toc(); + if ( isnan( v.get().statistic ) || isnan( v.get().pValue ) ) { + 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/base/ndarray/ztest2/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt new file mode 100644 index 000000000000..13050aad8a6b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt @@ -0,0 +1,68 @@ + +{{alias}}( arrays ) + Computes a two-sample Z-test for two one-dimensional ndarrays. + + Parameters + ---------- + arrays: ArrayLikeObject + Array-like object containing the following ndarrays in order: + + - first one-dimensional input ndarray. + - second one-dimensional input ndarray. + - a zero-dimensional output ndarray containing a results object. + - a zero-dimensional ndarray specifying the alternative hypothesis. + - a zero-dimensional ndarray specifying the significance level. + - a zero-dimensional ndarray specifying the difference in means under + the null hypothesis. + - a zero-dimensional ndarray specifying the known standard deviation of + first one-dimensional input ndarray. + - a zero-dimensional ndarray specifying the known standard deviation of + second one-dimensional input ndarray. + + Returns + ------- + out: ndarray + Output ndarray. + + Examples + -------- + // Create the input ndarray: + > var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; + > var ybuf = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; + > var dt = 'generic'; + > var sh = [ xbuf.length ]; + > var st = [ 1 ]; + > var oo = 0; + > var ord = 'row-major'; + > var x = new {{alias:@stdlib/ndarray/ctor}}( dt, xbuf, sh, st, oo, ord ); + > var y = new {{alias:@stdlib/ndarray/ctor}}( dt, ybuf, sh, st, oo, ord ); + + // Create the output ndarray: + > var S = {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}; + > var Results = {{alias:@stdlib/array/struct-factory}}( S ); + > var obuf = new Results( 1 ); + > var out = new {{alias:@stdlib/ndarray/ctor}}( S, obuf, [], [ 0 ], 0, ord ); + + // Specify the alternative hypothesis: + > var alt = {{alias:@stdlib/ndarray/from-scalar}}( 'two-sided' ); + + // Specify the significance level: + > var opts = { 'dtype': dt }; + > var alpha = {{alias:@stdlib/ndarray/from-scalar}}( 0.05, opts ); + + // Specify the difference in means under the null hypothesis: + > var diff = {{alias:@stdlib/ndarray/from-scalar}}( 0.0, opts ); + + // Specify the known standard deviations: + > var sigmax = {{alias:@stdlib/ndarray/from-scalar}}( 1.0, opts ); + > var sigmay = {{alias:@stdlib/ndarray/from-scalar}}( 2.0, opts ); + + // Perform a Z-test: + > {{alias}}( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + + // Print the results: + > out.get().toString() + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts new file mode 100644 index 000000000000..2563ce3caf5c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts @@ -0,0 +1,92 @@ +/* +* @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 { typedndarray, ndarray } from '@stdlib/types/ndarray'; + +/** +* Computes a two-sample Z-test for two one-dimensional ndarrays. +* +* ## Notes +* +* - The function expects the following ndarrays in order: +* +* - first one-dimensional input ndarray. +* - second one-dimensional input ndarray. +* - a zero-dimensional output ndarray containing a results object. +* - a zero-dimensional ndarray specifying the alternative hypothesis. +* - a zero-dimensional ndarray specifying the significance level. +* - a zero-dimensional ndarray specifying the difference in means under the null hypothesis. +* - a zero-dimensional ndarray specifying the known standard deviation of first one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the known standard deviation of second one-dimensional input ndarray. +* +* @param arrays - array-like object containing ndarrays +* @returns output ndarray +* +* @example +* var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' ); +* var structFactory = require( '@stdlib/array/struct-factory' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* var opts = { +* 'dtype': 'generic' +* }; +* +* // Define a one-dimensional input ndarray: +* var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var x = new ndarray( opts.dtype, xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* var ybuf = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* var y = new ndarray( opts.dtype, ybuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* // Specify the alternative hypothesis: +* var alt = scalar2ndarray( resolveEnum( 'two-sided' ), { +* 'dtype': 'int8' +* }); +* +* // Specify the significance level: +* var alpha = scalar2ndarray( 0.05, opts ); +* +* // Specify the difference in means under the null hypothesis: +* var diff = scalar2ndarray( 0.0, opts ); +* +* // Specify the known standard deviations: +* var sigmax = scalar2ndarray( 1.0, opts ); +* var sigmay = scalar2ndarray( 2.0, opts ); +* +* // Create a zero-dimensional results ndarray: +* var ResultsArray = structFactory( Float64Results ); +* var out = new ndarray( Float64Results, new ResultsArray( 1 ), [], [ 0 ], 0, 'row-major' ); +* +* // Perform a Z-test: +* var v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); +* // returns +* +* console.log( v.get().toString() ); +*/ +declare function ztest2, U extends ndarray>( arrays: [ T, T, U, T, T, T, T, T ] ): U; + + +// EXPORTS // + +export = ztest2; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/test.ts b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/test.ts new file mode 100644 index 000000000000..17725386d442 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/test.ts @@ -0,0 +1,57 @@ +/* +* @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. +*/ + +/* eslint-disable space-in-parens */ + +import zeros = require( '@stdlib/ndarray/zeros' ); +import ztest2 = require( './index' ); + + +// TESTS // + +// The function returns an ndarray... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + + ztest2( [ x, x, x, x, x, x, x, x ] ); // $ExpectType float64ndarray +} + +// The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... +{ + ztest2( '10' ); // $ExpectError + ztest2( 10 ); // $ExpectError + ztest2( true ); // $ExpectError + ztest2( false ); // $ExpectError + ztest2( null ); // $ExpectError + ztest2( undefined ); // $ExpectError + ztest2( [] ); // $ExpectError + ztest2( {} ); // $ExpectError + ztest2( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const x = zeros( [ 10 ], { + 'dtype': 'float64' + }); + + ztest2(); // $ExpectError + ztest2( [ x, x, x, x, x, x ], {} ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/examples/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/examples/index.js new file mode 100644 index 000000000000..557f49da3f4c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/examples/index.js @@ -0,0 +1,64 @@ +/** +* @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 Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' ); +var structFactory = require( '@stdlib/array/struct-factory' ); +var normal = require( '@stdlib/random/array/normal' ); +var ndarray = require( '@stdlib/ndarray/ctor' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ztest2 = require( './../lib' ); + +var opts = { + 'dtype': 'generic' +}; + +// Create a one-dimensional ndarrays containing pseudorandom numbers drawn from a normal distribution: +var xbuf = normal( 100, 0.0, 1.0, opts ); +var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( x ) ); + +var ybuf = normal( 100, 0.0, 1.0, opts ); +var y = new ndarray( opts.dtype, ybuf, [ ybuf.length ], [ 1 ], 0, 'row-major' ); +console.log( ndarray2array( y ) ); + +// Specify the alternative hypothesis: +var alt = scalar2ndarray( resolveEnum( 'two-sided' ), { + 'dtype': 'int8' +}); + +// Specify the significance level: +var alpha = scalar2ndarray( 0.05, opts ); + +// Specify the difference in means under the null hypothesis: +var diff = scalar2ndarray( 0.0, opts ); + +// Specify the known standard deviations: +var sigmax = scalar2ndarray( 1.0, opts ); +var sigmay = scalar2ndarray( 1.0, opts ); + +// Create a zero-dimensional results ndarray: +var ResultsArray = structFactory( Float64Results ); +var out = new ndarray( Float64Results, new ResultsArray( 1 ), [], [ 0 ], 0, 'row-major' ); + +// Perform a Z-test: +var v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); +console.log( v.get().toString() ); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js new file mode 100644 index 000000000000..27203c9b61cf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js @@ -0,0 +1,78 @@ +/** +* @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 two one-dimensional ndarrays. +* +* @module @stdlib/stats/base/ndarray/ztest2 +* +* @example +* var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' ); +* var structFactory = require( '@stdlib/array/struct-factory' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* var ztest2 = require( '@stdlib/stats/base/ndarray/ztest2' ); +* +* var opts = { +* 'dtype': 'generic' +* }; +* +* // Define a one-dimensional input ndarray: +* var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var x = new ndarray( opts.dtype, xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* var ybuf = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* var y = new ndarray( opts.dtype, ybuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* // Specify the alternative hypothesis: +* var alt = scalar2ndarray( resolveEnum( 'two-sided' ), { +* 'dtype': 'int8' +* }); +* +* // Specify the significance level: +* var alpha = scalar2ndarray( 0.05, opts ); +* +* // Specify the difference in means under the null hypothesis: +* var diff = scalar2ndarray( 0.0, opts ); +* +* // Specify the known standard deviations: +* var sigmax = scalar2ndarray( 1.0, opts ); +* var sigmay = scalar2ndarray( 2.0, opts ); +* +* // Create a zero-dimensional results ndarray: +* var ResultsArray = structFactory( Float64Results ); +* var out = new ndarray( Float64Results, new ResultsArray( 1 ), [], [ 0 ], 0, 'row-major' ); +* +* // Perform a Z-test: +* var v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); +* // returns +* +* console.log( v.get().toString() ); +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js new file mode 100644 index 000000000000..a64e113fc4b2 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js @@ -0,0 +1,123 @@ +/** +* @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 numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); +var getStride = require( '@stdlib/ndarray/base/stride' ); +var getOffset = require( '@stdlib/ndarray/base/offset' ); +var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); +var strided = require( '@stdlib/stats/strided/ztest2' ).ndarray; + + +// MAIN // + +/** +* Computes a two-sample Z-test for two one-dimensional ndarrays. +* +* ## Notes +* +* - The function expects the following ndarrays in order: +* +* - first one-dimensional input ndarray. +* - second one-dimensional input ndarray. +* - a zero-dimensional output ndarray containing a results object. +* - a zero-dimensional ndarray specifying the alternative hypothesis. +* - a zero-dimensional ndarray specifying the significance level. +* - a zero-dimensional ndarray specifying the difference in means under the null hypothesis. +* - a zero-dimensional ndarray specifying the known standard deviation of first one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the known standard deviation of second one-dimensional input ndarray. +* +* @param {ArrayLikeObject} arrays - array-like object containing ndarrays +* @returns {ndarrayLike} output ndarray +* +* @example +* var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +* var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' ); +* var structFactory = require( '@stdlib/array/struct-factory' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +* var ndarray = require( '@stdlib/ndarray/ctor' ); +* +* var opts = { +* 'dtype': 'generic' +* }; +* +* // Define a one-dimensional input ndarray: +* var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; +* var x = new ndarray( opts.dtype, xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* var ybuf = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; +* var y = new ndarray( opts.dtype, ybuf, [ 5 ], [ 1 ], 0, 'row-major' ); +* +* // Specify the alternative hypothesis: +* var alt = scalar2ndarray( resolveEnum( 'two-sided' ), { +* 'dtype': 'int8' +* }); +* +* // Specify the significance level: +* var alpha = scalar2ndarray( 0.05, opts ); +* +* // Specify the difference in means under the null hypothesis: +* var diff = scalar2ndarray( 0.0, opts ); +* +* // Specify the known standard deviations: +* var sigmax = scalar2ndarray( 1.0, opts ); +* var sigmay = scalar2ndarray( 2.0, opts ); +* +* // Create a zero-dimensional results ndarray: +* var ResultsArray = structFactory( Float64Results ); +* var out = new ndarray( Float64Results, new ResultsArray( 1 ), [], [ 0 ], 0, 'row-major' ); +* +* // Perform a Z-test: +* var v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); +* // returns +* +* console.log( v.get().toString() ); +*/ +function ztest2( arrays ) { + var sigmax; + var sigmay; + var alpha; + var diff; + var alt; + var out; + var x; + var y; + + x = arrays[ 0 ]; + y = arrays[ 1 ]; + out = ndarraylike2scalar( arrays[ 2 ] ); + + alt = ndarraylike2scalar( arrays[ 3 ] ); + alpha = ndarraylike2scalar( arrays[ 4 ] ); + diff = ndarraylike2scalar( arrays[ 5 ] ); + sigmax = ndarraylike2scalar( arrays[ 6 ] ); + sigmay = ndarraylike2scalar( arrays[ 7 ] ); + + strided( numelDimension( x, 0 ), numelDimension( y, 0 ), alt, alpha, diff, sigmax, getData( x ), getStride( x, 0 ), getOffset( x ), sigmay, getData( y ), getStride( y, 0 ), getOffset( y ), out ); // eslint-disable-line max-len + + return arrays[ 2 ]; +} + + +// EXPORTS // + +module.exports = ztest2; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/package.json b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/package.json new file mode 100644 index 000000000000..b3694c78993c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/stats/base/ndarray/ztest2", + "version": "0.0.0", + "description": "Compute a two-sample Z-test for two one-dimensional ndarrays.", + "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", + "z-test", + "ztest", + "hypothesis", + "normality", + "ndarray" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/test/test.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/test/test.js new file mode 100644 index 000000000000..fc4081308233 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/test/test.js @@ -0,0 +1,352 @@ +/** +* @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. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var Float64Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' ); +var resolveEnum = require( '@stdlib/stats/base/ztest/alternative-resolve-enum' ); +var structFactory = require( '@stdlib/array/struct-factory' ); +var normal = require( '@stdlib/random/strided/normal' ).ndarray; +var zeros = require( '@stdlib/array/zeros' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var ztest2 = require( './../lib' ); + + +// VARIABLES // + +var ResultsArray = structFactory( Float64Results ); +var RANDOM_OPTS = { + 'seed': 12345 +}; + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'generic', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// 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 has an arity of 1', function test( t ) { + t.strictEqual( ztest2.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function performs a Z-test over two one-dimensional ndarrays (two-sided)', function test( t ) { + var sigmax; + var sigmay; + var alpha; + var diff; + var opts; + var xbuf; + var ybuf; + var obuf; + var alt; + var out; + var x; + var y; + var v; + + opts = { + 'dtype': 'generic' + }; + + alt = scalar2ndarray( resolveEnum( 'two-sided' ), { + 'dtype': 'int8' + }); + alpha = scalar2ndarray( 0.1, opts ); + sigmax = scalar2ndarray( 1.0, opts ); + sigmay = scalar2ndarray( 1.0, opts ); + + obuf = new ResultsArray( 1 ); + out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); + + // Generate a large enough arrays to effectively guarantee results... + xbuf = zeros( 10000, opts.dtype ); + ybuf = zeros( 10000, opts.dtype ); + + normal( xbuf.length, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 1, 0, RANDOM_OPTS ); + x = vector( xbuf, xbuf.length, 1, 0 ); + + normal( ybuf.length, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 1, 0, RANDOM_OPTS ); + y = vector( ybuf, ybuf.length, 1, 0 ); + + diff = scalar2ndarray( 0.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, false, 'returns expected value' ); + + diff = scalar2ndarray( 10.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, true, 'returns expected value' ); + + normal( xbuf.length, [ 4.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 1, 0, RANDOM_OPTS ); + normal( ybuf.length, [ 2.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 1, 0, RANDOM_OPTS ); + + diff = scalar2ndarray( 1.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a Z-test over two one-dimensional ndarrays (less)', function test( t ) { + var sigmax; + var sigmay; + var alpha; + var diff; + var opts; + var xbuf; + var ybuf; + var obuf; + var alt; + var out; + var x; + var y; + var v; + + opts = { + 'dtype': 'generic' + }; + + alt = scalar2ndarray( resolveEnum( 'less' ), { + 'dtype': 'int8' + }); + alpha = scalar2ndarray( 0.1, opts ); + sigmax = scalar2ndarray( 1.0, opts ); + sigmay = scalar2ndarray( 1.0, opts ); + + obuf = new ResultsArray( 1 ); + out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); + + // Generate a large enough arrays to effectively guarantee results... + xbuf = zeros( 10000, opts.dtype ); + ybuf = zeros( 10000, opts.dtype ); + + normal( xbuf.length, [ 2.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 1, 0, RANDOM_OPTS ); + x = vector( xbuf, xbuf.length, 1, 0 ); + + normal( ybuf.length, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 1, 0, RANDOM_OPTS ); + y = vector( ybuf, ybuf.length, 1, 0 ); + + diff = scalar2ndarray( 0.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, false, 'returns expected value' ); + + normal( xbuf.length, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 1, 0, RANDOM_OPTS ); + normal( ybuf.length, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 1, 0, RANDOM_OPTS ); + + diff = scalar2ndarray( 1.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function performs a Z-test over two one-dimensional ndarrays (greater)', function test( t ) { + var sigmax; + var sigmay; + var alpha; + var diff; + var opts; + var xbuf; + var ybuf; + var obuf; + var alt; + var out; + var x; + var y; + var v; + + opts = { + 'dtype': 'generic' + }; + + alt = scalar2ndarray( resolveEnum( 'greater' ), { + 'dtype': 'int8' + }); + alpha = scalar2ndarray( 0.1, opts ); + sigmax = scalar2ndarray( 1.0, opts ); + sigmay = scalar2ndarray( 1.0, opts ); + + obuf = new ResultsArray( 1 ); + out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); + + // Generate a large enough arrays to effectively guarantee results... + xbuf = zeros( 10000, opts.dtype ); + ybuf = zeros( 10000, opts.dtype ); + + normal( xbuf.length, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 1, 0, RANDOM_OPTS ); + x = vector( xbuf, xbuf.length, 1, 0 ); + + normal( ybuf.length, [ 2.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 1, 0, RANDOM_OPTS ); + y = vector( ybuf, ybuf.length, 1, 0 ); + + diff = scalar2ndarray( 0.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, false, 'returns expected value' ); + + normal( xbuf.length, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 1, 0, RANDOM_OPTS ); + normal( ybuf.length, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 1, 0, RANDOM_OPTS ); + + diff = scalar2ndarray( -1.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { + var sigmax; + var sigmay; + var alpha; + var diff; + var opts; + var xbuf; + var ybuf; + var obuf; + var alt; + var out; + var x; + var y; + var v; + + opts = { + 'dtype': 'generic' + }; + + alt = scalar2ndarray( resolveEnum( 'two-sided' ), { + 'dtype': 'int8' + }); + alpha = scalar2ndarray( 0.1, opts ); + sigmax = scalar2ndarray( 1.0, opts ); + sigmay = scalar2ndarray( 1.0, opts ); + + obuf = new ResultsArray( 1 ); + out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); + + // Generate a large enough arrays to effectively guarantee results... + xbuf = zeros( 10000, opts.dtype ); + ybuf = zeros( 10000, opts.dtype ); + + normal( 5000, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 2, 0, RANDOM_OPTS ); + x = vector( xbuf, 5000, 2, 0 ); + + normal( 5000, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 2, 0, RANDOM_OPTS ); + y = vector( ybuf, 5000, 2, 0 ); + + diff = scalar2ndarray( 0.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, false, 'returns expected value' ); + + normal( 5000, [ 4.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 2, 0, RANDOM_OPTS ); + normal( 5000, [ 2.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 2, 0, RANDOM_OPTS ); + + diff = scalar2ndarray( 10.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { + var sigmax; + var sigmay; + var alpha; + var diff; + var opts; + var xbuf; + var ybuf; + var obuf; + var alt; + var out; + var x; + var y; + var v; + + opts = { + 'dtype': 'generic' + }; + + alt = scalar2ndarray( resolveEnum( 'two-sided' ), { + 'dtype': 'int8' + }); + alpha = scalar2ndarray( 0.1, opts ); + sigmax = scalar2ndarray( 1.0, opts ); + sigmay = scalar2ndarray( 1.0, opts ); + + obuf = new ResultsArray( 1 ); + out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); + + // Generate a large enough arrays to effectively guarantee results... + xbuf = zeros( 10000, opts.dtype ); + ybuf = zeros( 10000, opts.dtype ); + + normal( 5000, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 1, 5000, RANDOM_OPTS ); + x = vector( xbuf, 5000, 1, 5000 ); + + normal( 5000, [ 0.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 1, 5000, RANDOM_OPTS ); + y = vector( ybuf, 5000, 1, 5000 ); + + diff = scalar2ndarray( 0.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, false, 'returns expected value' ); + + normal( 5000, [ 100.0 ], 0, 0, [ 1.0 ], 0, 0, xbuf, 1, 5000, RANDOM_OPTS ); + normal( 5000, [ 100.0 ], 0, 0, [ 1.0 ], 0, 0, ybuf, 1, 5000, RANDOM_OPTS ); + + diff = scalar2ndarray( 1.0, opts ); + v = ztest2( [ x, y, out, alt, alpha, diff, sigmax, sigmay ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.strictEqual( out.get().rejected, true, 'returns expected value' ); + + t.end(); +}); From 6166485f523781ea25fa6fe5bd4fb28c66449b57 Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Sun, 20 Jul 2025 08:52:42 +0000 Subject: [PATCH 2/3] chore: fix comments --- lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md | 2 +- .../@stdlib/stats/base/ndarray/ztest2/docs/repl.txt | 2 +- .../@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts | 2 +- .../@stdlib/stats/base/ndarray/ztest2/examples/index.js | 2 +- lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js | 2 +- lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md index 69ee6d503b8b..c80617273562 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md @@ -129,7 +129,7 @@ var opts = { 'dtype': 'generic' }; -// Create a one-dimensional ndarrays containing pseudorandom numbers drawn from a normal distribution: +// Create one-dimensional ndarrays containing pseudorandom numbers drawn from a normal distribution: var xbuf = normal( 100, 0.0, 1.0, opts ); var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt index 13050aad8a6b..f263aa204bc8 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt @@ -26,7 +26,7 @@ Examples -------- - // Create the input ndarray: + // Create input ndarrays: > var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; > var ybuf = [ 3.0, 3.0, 5.0, 7.0, 7.0 ]; > var dt = 'generic'; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts index 2563ce3caf5c..2d78f8a7a5a9 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts @@ -52,7 +52,7 @@ import { typedndarray, ndarray } from '@stdlib/types/ndarray'; * 'dtype': 'generic' * }; * -* // Define a one-dimensional input ndarray: +* // Define one-dimensional input ndarrays: * var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; * var x = new ndarray( opts.dtype, xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); * diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/examples/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/examples/index.js index 557f49da3f4c..f1cbb9b7d7f2 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/examples/index.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/examples/index.js @@ -31,7 +31,7 @@ var opts = { 'dtype': 'generic' }; -// Create a one-dimensional ndarrays containing pseudorandom numbers drawn from a normal distribution: +// Create one-dimensional ndarrays containing pseudorandom numbers drawn from a normal distribution: var xbuf = normal( 100, 0.0, 1.0, opts ); var x = new ndarray( opts.dtype, xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' ); console.log( ndarray2array( x ) ); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js index 27203c9b61cf..d4b46840d00e 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/index.js @@ -35,7 +35,7 @@ * 'dtype': 'generic' * }; * -* // Define a one-dimensional input ndarray: +* // Define one-dimensional input ndarrays: * var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; * var x = new ndarray( opts.dtype, xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); * diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js index a64e113fc4b2..7a51dc41320e 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js @@ -60,7 +60,7 @@ var strided = require( '@stdlib/stats/strided/ztest2' ).ndarray; * 'dtype': 'generic' * }; * -* // Define a one-dimensional input ndarray: +* // Define one-dimensional input ndarrays: * var xbuf = [ 4.0, 4.0, 6.0, 6.0, 5.0 ]; * var x = new ndarray( opts.dtype, xbuf, [ 5 ], [ 1 ], 0, 'row-major' ); * From 1a2d1b703d5dfb58bf5c5838be6e728b1c52e58d Mon Sep 17 00:00:00 2001 From: gururaj1512 Date: Mon, 21 Jul 2025 07:08:53 +0000 Subject: [PATCH 3/3] chore: clean-up --- .../@stdlib/stats/base/ndarray/ztest2/README.md | 14 +++++++------- .../stats/base/ndarray/ztest2/docs/repl.txt | 4 ++-- .../base/ndarray/ztest2/docs/types/index.d.ts | 4 ++-- .../@stdlib/stats/base/ndarray/ztest2/lib/main.js | 4 ++-- .../@stdlib/stats/base/ndarray/ztest2/test/test.js | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md index c80617273562..a5c9504809cc 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/README.md @@ -87,13 +87,13 @@ The function has the following parameters: - **arrays**: array-like object containing the following ndarrays in order: 1. first one-dimensional input ndarray. - 1. second one-dimensional input ndarray. - 2. a zero-dimensional output ndarray containing a [results object][@stdlib/stats/base/ztest/two-sample/results/float64]. - 3. a zero-dimensional ndarray specifying the alternative hypothesis. - 4. a zero-dimensional ndarray specifying the significance level. - 5. a zero-dimensional ndarray specifying the difference in means under the null hypothesis. - 6. a zero-dimensional ndarray specifying the known standard deviation of first one-dimensional input ndarray. - 7. a zero-dimensional ndarray specifying the known standard deviation of second one-dimensional input ndarray. + 2. second one-dimensional input ndarray. + 3. a zero-dimensional output ndarray containing a [results object][@stdlib/stats/base/ztest/two-sample/results/float64]. + 4. a zero-dimensional ndarray specifying the alternative hypothesis. + 5. a zero-dimensional ndarray specifying the significance level. + 6. a zero-dimensional ndarray specifying the difference in means under the null hypothesis. + 7. a zero-dimensional ndarray specifying the known standard deviation of the first one-dimensional input ndarray. + 8. a zero-dimensional ndarray specifying the known standard deviation of the second one-dimensional input ndarray. diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt index f263aa204bc8..de38f914846c 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/repl.txt @@ -15,9 +15,9 @@ - a zero-dimensional ndarray specifying the difference in means under the null hypothesis. - a zero-dimensional ndarray specifying the known standard deviation of - first one-dimensional input ndarray. + the first one-dimensional input ndarray. - a zero-dimensional ndarray specifying the known standard deviation of - second one-dimensional input ndarray. + the second one-dimensional input ndarray. Returns ------- diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts index 2d78f8a7a5a9..b10d6cfef2f5 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/docs/types/index.d.ts @@ -35,8 +35,8 @@ import { typedndarray, ndarray } from '@stdlib/types/ndarray'; * - a zero-dimensional ndarray specifying the alternative hypothesis. * - a zero-dimensional ndarray specifying the significance level. * - a zero-dimensional ndarray specifying the difference in means under the null hypothesis. -* - a zero-dimensional ndarray specifying the known standard deviation of first one-dimensional input ndarray. -* - a zero-dimensional ndarray specifying the known standard deviation of second one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the known standard deviation of the first one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the known standard deviation of the second one-dimensional input ndarray. * * @param arrays - array-like object containing ndarrays * @returns output ndarray diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js index 7a51dc41320e..94961ca6b6fd 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/lib/main.js @@ -43,8 +43,8 @@ var strided = require( '@stdlib/stats/strided/ztest2' ).ndarray; * - a zero-dimensional ndarray specifying the alternative hypothesis. * - a zero-dimensional ndarray specifying the significance level. * - a zero-dimensional ndarray specifying the difference in means under the null hypothesis. -* - a zero-dimensional ndarray specifying the known standard deviation of first one-dimensional input ndarray. -* - a zero-dimensional ndarray specifying the known standard deviation of second one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the known standard deviation of the first one-dimensional input ndarray. +* - a zero-dimensional ndarray specifying the known standard deviation of the second one-dimensional input ndarray. * * @param {ArrayLikeObject} arrays - array-like object containing ndarrays * @returns {ndarrayLike} output ndarray diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/test/test.js b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/test/test.js index fc4081308233..426b7e8b11c4 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/ztest2/test/test.js @@ -100,7 +100,7 @@ tape( 'the function performs a Z-test over two one-dimensional ndarrays (two-sid obuf = new ResultsArray( 1 ); out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); - // Generate a large enough arrays to effectively guarantee results... + // Generate large enough arrays to effectively guarantee results... xbuf = zeros( 10000, opts.dtype ); ybuf = zeros( 10000, opts.dtype ); @@ -160,7 +160,7 @@ tape( 'the function performs a Z-test over two one-dimensional ndarrays (less)', obuf = new ResultsArray( 1 ); out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); - // Generate a large enough arrays to effectively guarantee results... + // Generate large enough arrays to effectively guarantee results... xbuf = zeros( 10000, opts.dtype ); ybuf = zeros( 10000, opts.dtype ); @@ -215,7 +215,7 @@ tape( 'the function performs a Z-test over two one-dimensional ndarrays (greater obuf = new ResultsArray( 1 ); out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); - // Generate a large enough arrays to effectively guarantee results... + // Generate large enough arrays to effectively guarantee results... xbuf = zeros( 10000, opts.dtype ); ybuf = zeros( 10000, opts.dtype ); @@ -270,7 +270,7 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', obuf = new ResultsArray( 1 ); out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); - // Generate a large enough arrays to effectively guarantee results... + // Generate large enough arrays to effectively guarantee results... xbuf = zeros( 10000, opts.dtype ); ybuf = zeros( 10000, opts.dtype ); @@ -325,7 +325,7 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets', obuf = new ResultsArray( 1 ); out = new ndarray( Float64Results, obuf, [], [ 0 ], 0, 'row-major' ); - // Generate a large enough arrays to effectively guarantee results... + // Generate large enough arrays to effectively guarantee results... xbuf = zeros( 10000, opts.dtype ); ybuf = zeros( 10000, opts.dtype );