Skip to content

Commit 64fd6df

Browse files
committed
refactor: update signature
1 parent 1b92f9f commit 64fd6df

File tree

12 files changed

+458
-378
lines changed

12 files changed

+458
-378
lines changed

lib/node_modules/@stdlib/stats/strided/ztest2/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Here, `μX` and `μY` are the true population means of samples `X` and `Y`, resp
4646
var ztest2 = require( '@stdlib/stats/strided/ztest2' );
4747
```
4848

49-
#### ztest2( N, alternative, alpha, mu, sigmax, x, strideX, sigmay, y, strideY, out )
49+
#### ztest2( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, y, strideY, out )
5050

5151
Computes a two-sample Z-test for a strided array.
5252

@@ -57,7 +57,7 @@ var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ];
5757
var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
5858

5959
var results = new Results();
60-
var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results );
60+
var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, results );
6161
// returns {...}
6262

6363
var bool = ( out === results );
@@ -66,14 +66,15 @@ var bool = ( out === results );
6666

6767
The function has the following parameters:
6868

69-
- **N**: number of indexed elements.
69+
- **NX**: number of indexed elements in `x`.
70+
- **NY**: number of indexed elements in `y`.
7071
- **alternative**: [alternative hypothesis][@stdlib/stats/base/ztest/alternatives].
7172
- **alpha**: significance level.
72-
- **mu**: mean value under the null hypothesis.
73+
- **diff**: difference in means under the null hypothesis.
7374
- **sigmax**: known standard deviation of `x`.
75+
- **sigmay**: known standard deviation of `y`.
7476
- **x**: input array.
7577
- **strideX**: stride length for `x`.
76-
- **sigmay**: known standard deviation of `y`.
7778
- **y**: input array.
7879
- **strideY**: stride length for `y`.
7980
- **out**: output [results object][@stdlib/stats/base/ztest/two-sample/results/float64].
@@ -87,7 +88,7 @@ var x = [ 4.0, 0.0, 4.0, 0.0, 6.0, 0.0, 6.0, 0.0, 5.0, 0.0 ];
8788
var y = [ 3.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 7.0, 0.0 ];
8889

8990
var results = new Results();
90-
var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x, 2, 2.0, y, 2, results );
91+
var out = ztest2( 5, 5, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 2, y, 2, results );
9192
// returns {...}
9293

9394
var bool = ( out === results );
@@ -109,14 +110,14 @@ var y0 = new Float64Array( [ 0.0, 3.0, 3.0, 5.0, 7.0, 7.0 ] );
109110
var y1 = new Float64Array( y0.buffer, y0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
110111

111112
var results = new Results();
112-
var out = ztest2( 5, 'two-sided', 0.05, 0.0, 1.0, x1, 1, 2.0, y1, 1, results );
113+
var out = ztest2( 5, 5, 'two-sided', 0.05, 0.0, 1.0, 2.0, x1, 1, y1, 1, results );
113114
// returns {...}
114115

115116
var bool = ( out === results );
116117
// returns true
117118
```
118119

119-
#### ztest2.ndarray( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, y, strideY, offsetY, out )
120+
#### ztest2.ndarray( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, offsetX, y, strideY, offsetY, out )
120121

121122
Computes a two-sample Z-test for a strided array using alternative indexing semantics.
122123

@@ -127,7 +128,7 @@ var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ];
127128
var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
128129

129130
var results = new Results();
130-
var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results );
131+
var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results );
131132
// returns {...}
132133

133134
var bool = ( out === results );
@@ -148,7 +149,7 @@ var x = [ 0.0, 4.0, 0.0, 4.0, 0.0, 6.0, 0.0, 6.0, 0.0, 5.0 ];
148149
var y = [ 0.0, 3.0, 0.0, 3.0, 0.0, 5.0, 0.0, 7.0, 0.0, 7.0 ];
149150

150151
var results = new Results();
151-
var out = ztest2.ndarray( 5, 'two-sided', 0.05, 0.0, 1.0, x, 2, 1, 2.0, y, 2, 1, results );
152+
var out = ztest2.ndarray( 5, 5, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 2, 1, y, 2, 1, results );
152153
// returns {...}
153154

154155
var bool = ( out === results );
@@ -182,15 +183,15 @@ var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' );
182183
var normal = require( '@stdlib/random/array/normal' );
183184
var ztest2 = require( '@stdlib/stats/strided/ztest2' );
184185

185-
var x = normal( 1000, 0.0, 1.0, {
186+
var x = normal( 1000, 4.0, 2.0, {
186187
'dtype': 'generic'
187188
});
188-
var y = normal( 1000, 0.0, 1.0, {
189+
var y = normal( 800, 3.0, 2.0, {
189190
'dtype': 'generic'
190191
});
191192

192193
var results = new Results();
193-
var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, results );
194+
var out = ztest2( x.length, y.length, 'two-sided', 0.05, 1.0, 2.0, 2.0, x, 1, y, 1, results );
194195
// returns {...}
195196

196197
console.log( out.toString() );
@@ -222,7 +223,7 @@ console.log( out.toString() );
222223

223224
[@stdlib/stats/base/ztest/alternatives]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/ztest/alternatives
224225

225-
[@stdlib/stats/base/ztest/one-sample/results/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/ztest/one-sample/results/float64
226+
[@stdlib/stats/base/ztest/two-sample/results/float64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/base/ztest/two-sample/results/float64
226227

227228
[@stdlib/array/base/accessor]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/accessor
228229

lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function createBenchmark( len ) {
6262

6363
b.tic();
6464
for ( i = 0; i < b.iterations; i++ ) {
65-
out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 1.0, y, 1, results );
65+
out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, y, 1, results );
6666
if ( isnan( out.statistic ) ) {
6767
b.fail( 'should not return NaN' );
6868
}

lib/node_modules/@stdlib/stats/strided/ztest2/benchmark/benchmark.ndarray.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ var bench = require( '@stdlib/bench' );
2424
var normal = require( '@stdlib/random/array/normal' );
2525
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2626
var pow = require( '@stdlib/math/base/special/pow' );
27-
var Results = require( '@stdlib/stats/base/ztest/one-sample/results/float64' );
27+
var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' );
2828
var pkg = require( './../package.json' ).name;
2929
var ztest2 = require( './../lib/ndarray.js' );
3030

@@ -62,7 +62,7 @@ function createBenchmark( len ) {
6262

6363
b.tic();
6464
for ( i = 0; i < b.iterations; i++ ) {
65-
out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 1.0, y, 1, 0, results );
65+
out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 1.0, x, 1, 0, y, 1, 0, results );
6666
if ( isnan( out.statistic ) ) {
6767
b.fail( 'should not return NaN' );
6868
}

lib/node_modules/@stdlib/stats/strided/ztest2/docs/repl.txt

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{alias}}( N, alternative, alpha, mu, sigmax, x, strideX, sigmay, y, strideY, out )
2+
{{alias}}( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, y, strideY, out )
33
Computes a two-sample Z-test for a strided array.
44

55
The `N` and stride parameters determine which elements in the strided array
@@ -10,34 +10,37 @@
1010

1111
Parameters
1212
----------
13-
N: integer
14-
Number of indexed elements.
13+
NX: integer
14+
Number of indexed elements in `x`.
15+
16+
NY: integer
17+
Number of indexed elements in `y`.
1518

1619
alternative: string
1720
Alternative hypothesis. Must be one of the following:
1821

19-
- two-sided: mean is not equal to null value.
20-
- greater: mean is larger than null value.
21-
- less: mean is less than null value.
22+
- two-sided: `x` has same mean as `y`
23+
- greater: `x` has larger mean than `y`
24+
- less: `x` has smaller mean than `y`
2225

2326
alpha: number
2427
Significance level.
2528

26-
mu: number
27-
Value of the mean under the null hypothesis.
29+
diff: number
30+
Difference in means under the null hypothesis.
2831

2932
sigmax: number
3033
Known standard deviation of `x`.
3134

35+
sigmay: number
36+
Known standard deviation of `y`.
37+
3238
x: Array|TypedArray|Object
3339
Input array.
3440

3541
strideX: integer
3642
Stride length for `x`.
3743

38-
sigmay: number
39-
Known standard deviation of `y`.
40-
4144
y: Array|TypedArray|Object
4245
Input array.
4346

@@ -56,14 +59,15 @@
5659
--------
5760
> var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ];
5861
> var x = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
59-
> var N = x.length;
62+
> var NX = x.length;
63+
> var NY = y.length;
6064
> var alt = 'two-sided';
6165
> var out = new {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}();
62-
> var res = {{alias}}( N, alt, 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, out );
66+
> var res = {{alias}}( NX, NY, alt, 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, out );
6367
> res.toString()
6468

6569

66-
{{alias}}.ndarray( N, alternative, alpha, mu, sigmax, x, strideX, offsetX, sigmay, y, strideY, offsetY, out )
70+
{{alias}}.ndarray( NX, NY, alternative, alpha, diff, sigmax, sigmay, x, strideX, offsetX, y, strideY, offsetY, out )
6771
Computes a two-sample Z-test for a strided array using alternative indexing
6872
semantics.
6973

@@ -73,25 +77,31 @@
7377

7478
Parameters
7579
----------
76-
N: integer
77-
Number of indexed elements.
80+
NX: integer
81+
Number of indexed elements in `x`.
82+
83+
NY: integer
84+
Number of indexed elements in `y`.
7885

7986
alternative: string
8087
Alternative hypothesis. Must be one of the following:
8188

82-
- two-sided: mean is not equal to null value.
83-
- greater: mean is larger than null value.
84-
- less: mean is less than null value.
89+
- two-sided: `x` has same mean as `y`
90+
- greater: `x` has larger mean than `y`
91+
- less: `x` has smaller mean than `y`
8592

8693
alpha: number
8794
Significance level.
8895

89-
mu: number
90-
Value of the mean under the null hypothesis.
96+
diff: number
97+
Difference in means under the null hypothesis.
9198

9299
sigmax: number
93100
Known standard deviation of `x`.
94101

102+
sigmay: number
103+
Known standard deviation of `y`.
104+
95105
x: Array|TypedArray|Object
96106
Input array.
97107

@@ -101,9 +111,6 @@
101111
offsetX: integer
102112
Starting index for `x`.
103113

104-
sigmay: number
105-
Known standard deviation of `y`.
106-
107114
y: Array|TypedArray|Object
108115
Input array.
109116

@@ -125,10 +132,11 @@
125132
--------
126133
> var x = [ 4.0, 4.0, 6.0, 6.0, 5.0 ];
127134
> var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
128-
> var N = x.length;
135+
> var NX = x.length;
136+
> var NY = y.length;
129137
> var alt = 'two-sided';
130138
> var out = new {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}();
131-
> var res = {{alias}}.ndarray( N, alt, 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, out );
139+
> var res = {{alias}}.ndarray( NX, NY, alt, 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, out );
132140
> res.toString()
133141

134142
See Also

lib/node_modules/@stdlib/stats/strided/ztest2/docs/types/index.d.ts

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ interface BaseResults {
9696
ci: Float64Array;
9797

9898
/**
99-
* Value of the mean under the null hypothesis
99+
* Difference in means under the null hypothesis
100100
*/
101101
nullValue: number;
102102

@@ -133,14 +133,15 @@ interface Routine {
133133
/**
134134
* Computes a two-sample Z-test for a strided array.
135135
*
136-
* @param N - number of indexed elements
136+
* @param NX - number of indexed elements in `x`
137+
* @param NY - number of indexed elements in `y`
137138
* @param alternative - alternative hypothesis
138139
* @param alpha - significance level
139-
* @param mu - mean under the null hypothesis
140+
* @param diff - difference in means under the null hypothesis
140141
* @param sigmax - known standard deviation of `x`
142+
* @param sigmay - known standard deviation of `y`
141143
* @param x - input array
142144
* @param strideX - stride length for `x`
143-
* @param sigmay - known standard deviation of `y`
144145
* @param y - input array
145146
* @param strideY - stride length for `y`
146147
* @param out - output results object
@@ -153,26 +154,27 @@ interface Routine {
153154
* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
154155
*
155156
* var results = new Results();
156-
* var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results );
157+
* var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, results );
157158
* // returns {...}
158159
*
159160
* var bool = ( out === results );
160161
* // returns true
161162
*/
162-
<T extends BaseResults>( N: number, alternative: Alternative, alpha: number, mu: number, sigmax: number, x: InputArray, strideX: number, sigmay: number, y: InputArray, strideY: number, out: T ): Results;
163+
<T extends BaseResults>( NX: number, NY: number, alternative: Alternative, alpha: number, diff: number, sigmax: number, sigmay: number, x: InputArray, strideX: number, y: InputArray, strideY: number, out: T ): Results;
163164

164165
/**
165166
* Computes a two-sample Z-test for a strided array using alternative indexing semantics.
166167
*
167-
* @param N - number of indexed elements
168+
* @param NX - number of indexed elements in `x`
169+
* @param NY - number of indexed elements in `y`
168170
* @param alternative - alternative hypothesis
169171
* @param alpha - significance level
170-
* @param mu - mean under the null hypothesis
172+
* @param diff - difference in means under the null hypothesis
171173
* @param sigmax - known standard deviation of `x`
174+
* @param sigmay - known standard deviation of `y`
172175
* @param x - input array
173176
* @param strideX - stride length for `x`
174177
* @param offsetX - starting index for `x`
175-
* @param sigmay - known standard deviation of `y`
176178
* @param y - input array
177179
* @param strideY - stride length for `y`
178180
* @param offsetY - starting index for `y`
@@ -186,26 +188,27 @@ interface Routine {
186188
* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
187189
*
188190
* var results = new Results();
189-
* var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results );
191+
* var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results );
190192
* // returns {...}
191193
*
192194
* var bool = ( out === results );
193195
* // returns true
194196
*/
195-
ndarray<T extends BaseResults>( 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;
197+
ndarray<T extends BaseResults>( NX: number, NY: number, alternative: Alternative, alpha: number, diff: number, sigmax: number, sigmay: number, x: InputArray, strideX: number, offsetX: number, y: InputArray, strideY: number, offsetY: number, out: T ): Results;
196198
}
197199

198200
/**
199201
* Computes a two-sample Z-test for a strided array.
200202
*
201-
* @param N - number of indexed elements
203+
* @param NX - number of indexed elements in `x`
204+
* @param NY - number of indexed elements in `y`
202205
* @param alternative - alternative hypothesis
203206
* @param alpha - significance level
204-
* @param mu - mean under the null hypothesis
207+
* @param diff - difference in means under the null hypothesis
205208
* @param sigmax - known standard deviation of `x`
209+
* @param sigmay - known standard deviation of `y`
206210
* @param x - input array
207211
* @param strideX - stride length for `x`
208-
* @param sigmay - known standard deviation of `y`
209212
* @param y - input array
210213
* @param strideY - stride length for `y`
211214
* @param out - output results object
@@ -218,7 +221,7 @@ interface Routine {
218221
* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
219222
*
220223
* var results = new Results();
221-
* var out = ztest2( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results );
224+
* var out = ztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, y, 1, results );
222225
* // returns {...}
223226
*
224227
* var bool = ( out === results );
@@ -231,7 +234,7 @@ interface Routine {
231234
* var y = [ 3.0, 3.0, 5.0, 7.0, 7.0 ];
232235
*
233236
* var results = new Results();
234-
* var out = ztest2.ndarray( x.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results );
237+
* var out = ztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, 2.0, x, 1, 0, y, 1, 0, results );
235238
* // returns {...}
236239
*
237240
* var bool = ( out === results );

0 commit comments

Comments
 (0)