Skip to content

Commit 7b547ff

Browse files
committed
feat: add docs
1 parent eb60164 commit 7b547ff

File tree

3 files changed

+863
-0
lines changed

3 files changed

+863
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
2+
{{alias}}( NX, NY, alt, alpha, d, sdx, x, sx, sdy, y, sy, out )
3+
Computes a two-sample Z-test for double-precision floating-point strided
4+
arrays.
5+
6+
The `N` and stride parameters determine which elements in the strided
7+
arrays are accessed at runtime.
8+
9+
Indexing is relative to the first index. To introduce an offset, use a typed
10+
array view.
11+
12+
Parameters
13+
----------
14+
NX: integer
15+
Number of indexed elements in `x`.
16+
17+
NY: integer
18+
Number of indexed elements in `y`.
19+
20+
alternative: string
21+
Alternative hypothesis. Must be one of the following:
22+
23+
- two-sided: `x` has the same mean as `y`.
24+
- greater: `x` has a larger mean than `y`.
25+
- less: `x` has a smaller mean than `y`.
26+
27+
alpha: number
28+
Significance level.
29+
30+
d: number
31+
Difference in means under the null hypothesis.
32+
33+
sdx: number
34+
Known standard deviation of `x`.
35+
36+
x: Float64Array
37+
First input array.
38+
39+
strideX: integer
40+
Stride length for `x`.
41+
42+
sdy: number
43+
Known standard deviation of `y`.
44+
45+
y: Float64Array
46+
Second input array.
47+
48+
strideY: integer
49+
Stride length for `y`.
50+
51+
out: Object
52+
Output results object.
53+
54+
Returns
55+
-------
56+
out: Object
57+
Results object.
58+
59+
Examples
60+
--------
61+
> var x = new {{alias:@stdlib/array/float64}}( [ 4.0, 4.0, 6.0, 6.0, 5.0 ] );
62+
> var y = new {{alias:@stdlib/array/float64}}( [ 3.0, 3.0, 5.0, 7.0, 7.0 ] );
63+
> var NX = x.length;
64+
> var NY = y.length;
65+
> var alt = 'two-sided';
66+
> var out = new {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}();
67+
> var res = {{alias}}( NX, NY, alt, 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, out );
68+
> res.toString()
69+
70+
71+
{{alias}}.ndarray( NX, NY, alt, alpha, d, sdx, x, sx, ox, sdy, y, sy, oy, out )
72+
Computes a two-sample Z-test for double-precision floating-point strided
73+
arrays using alternative indexing semantics.
74+
75+
While typed array views mandate a view offset based on the underlying
76+
buffer, offset parameters support indexing semantics based on starting
77+
indices.
78+
79+
Parameters
80+
----------
81+
NX: integer
82+
Number of indexed elements in `x`.
83+
84+
NY: integer
85+
Number of indexed elements in `y`.
86+
87+
alternative: string
88+
Alternative hypothesis. Must be one of the following:
89+
90+
- two-sided: `x` has the same mean as `y`.
91+
- greater: `x` has a larger mean than `y`.
92+
- less: `x` has a smaller mean than `y`.
93+
94+
alpha: number
95+
Significance level.
96+
97+
d: number
98+
Difference in means under the null hypothesis.
99+
100+
sdx: number
101+
Known standard deviation of `x`.
102+
103+
x: Float64Array
104+
First input array.
105+
106+
strideX: integer
107+
Stride length for `x`.
108+
109+
offsetX: integer
110+
Starting index for `x`.
111+
112+
sdy: number
113+
Known standard deviation of `y`.
114+
115+
y: Float64Array
116+
Second input array.
117+
118+
strideY: integer
119+
Stride length for `y`.
120+
121+
offsetY: integer
122+
Starting index for `y`.
123+
124+
out: Object
125+
Output results object.
126+
127+
Returns
128+
-------
129+
out: Object
130+
Results object.
131+
132+
Examples
133+
--------
134+
> var x = new {{alias:@stdlib/array/float64}}( [ 4.0, 4.0, 6.0, 6.0, 5.0 ] );
135+
> var y = new {{alias:@stdlib/array/float64}}( [ 3.0, 3.0, 5.0, 7.0, 7.0 ] );
136+
> var NX = x.length;
137+
> var NY = y.length;
138+
> var alt = 'two-sided';
139+
> var out = new {{alias:@stdlib/stats/base/ztest/two-sample/results/float64}}();
140+
> var res = {{alias}}.ndarray( NX, NY, alt, 0.05, 0.0, 1.0, x, 1, 0, 2.0, x, 1, 0, out );
141+
> res.toString()
142+
143+
See Also
144+
--------
145+
Lines changed: 243 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,243 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 4.1
20+
21+
/**
22+
* Alternative hypothesis.
23+
*/
24+
type Alternative = 'two-sided' | 'greater' | 'less';
25+
26+
/**
27+
* Interface describing options when serializing a results object to a string.
28+
*/
29+
interface Options {
30+
/**
31+
* Number of digits to display after decimal points. Default: 4.
32+
*/
33+
digits?: number;
34+
35+
/**
36+
* Boolean indicating whether to show the test decision. Default: true.
37+
*/
38+
decision?: boolean;
39+
}
40+
41+
/**
42+
* Serializes a results object as a string.
43+
*
44+
* @returns string representation
45+
*/
46+
type toString = ( options?: Options ) => string;
47+
48+
/**
49+
* Serializes a results object as a JSON object.
50+
*
51+
* @returns JSON representation
52+
*/
53+
type toJSON = () => BaseResults;
54+
55+
/**
56+
* Interface describing a "base" results object.
57+
*/
58+
interface BaseResults {
59+
/**
60+
* Boolean indicating whether the null hypothesis was rejected.
61+
*/
62+
rejected: boolean;
63+
64+
/**
65+
* Alternative hypothesis.
66+
*/
67+
alternative: Alternative;
68+
69+
/**
70+
* Significance level.
71+
*/
72+
alpha: number;
73+
74+
/**
75+
* p-value.
76+
*/
77+
pValue: number;
78+
79+
/**
80+
* Test statistic.
81+
*/
82+
statistic: number;
83+
84+
/**
85+
* Confidence interval.
86+
*/
87+
ci: Float64Array;
88+
89+
/**
90+
* Value of the mean under the null hypothesis
91+
*/
92+
nullValue: number;
93+
94+
/**
95+
* Sample mean of `x`.
96+
*/
97+
xmean: number;
98+
99+
/**
100+
* Sample mean of `y`.
101+
*/
102+
ymean: number;
103+
}
104+
105+
/**
106+
* Interface describing a results object.
107+
*/
108+
interface Results extends BaseResults {
109+
/**
110+
* Serializes results as formatted test output.
111+
*/
112+
toString: toString;
113+
114+
/**
115+
* Serializes results as JSON.
116+
*/
117+
toJSON: toJSON;
118+
}
119+
120+
/**
121+
* Interface describing `dztest2`.
122+
*/
123+
interface Routine {
124+
/**
125+
* Computes a two-sample Z-test for double-precision floating-point strided arrays.
126+
*
127+
* @param NX - number of indexed elements in `x`
128+
* @param NY - number of indexed elements in `y`
129+
* @param alternative - alternative hypothesis
130+
* @param alpha - significance level
131+
* @param diff - difference in means under the null hypothesis
132+
* @param sigmax - known standard deviation of `x`
133+
* @param x - first input array
134+
* @param strideX - stride length for `x`
135+
* @param sigmay - known standard deviation of `y`
136+
* @param y - second input array
137+
* @param strideY - stride length for `y`
138+
* @param out - output results object
139+
* @returns results object
140+
*
141+
* @example
142+
* var Float64Array = require( '@stdlib/array/float64' );
143+
* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' );
144+
*
145+
* var x = new Float64Array( [ 4.0, 4.0, 6.0, 6.0, 5.0 ] );
146+
* var y = new Float64Array( [ 3.0, 3.0, 5.0, 7.0, 7.0 ] );
147+
*
148+
* var results = new Results();
149+
* var out = dztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results );
150+
* // returns {...}
151+
*
152+
* var bool = ( out === results );
153+
* // returns true
154+
*/
155+
<T extends BaseResults>( NX: number, NY: number, alternative: Alternative, alpha: number, diff: number, sigmax: number, x: Float64Array, strideX: number, sigmay: number, y: Float64Array, strideY: number, out: T ): Results;
156+
157+
/**
158+
* Computes a two-sample Z-test for double-precision floating-point strided arrays using alternative indexing semantics.
159+
*
160+
* @param NX - number of indexed elements in `x`
161+
* @param NY - number of indexed elements in `y`
162+
* @param alternative - alternative hypothesis
163+
* @param alpha - significance level
164+
* @param diff - difference in means under the null hypothesis
165+
* @param sigmax - known standard deviation of `x`
166+
* @param x - first input array
167+
* @param strideX - stride length for `x`
168+
* @param offsetX - starting index for `x`
169+
* @param sigmay - known standard deviation of `y`
170+
* @param y - second input array
171+
* @param strideY - stride length for `y`
172+
* @param offsetY - starting index for `y`
173+
* @param out - output results object
174+
* @returns results object
175+
*
176+
* @example
177+
* var Float64Array = require( '@stdlib/array/float64' );
178+
* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' );
179+
*
180+
* var x = new Float64Array( [ 4.0, 4.0, 6.0, 6.0, 5.0 ] );
181+
* var y = new Float64Array( [ 3.0, 3.0, 5.0, 7.0, 7.0 ] );
182+
*
183+
* var results = new Results();
184+
* var out = dztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results );
185+
* // returns {...}
186+
*
187+
* var bool = ( out === results );
188+
* // returns true
189+
*/
190+
ndarray<T extends BaseResults>( NX: number, NY: number, alternative: Alternative, alpha: number, diff: number, sigmax: number, x: Float64Array, strideX: number, offsetX: number, sigmay: number, y: Float64Array, strideY: number, offsetY: number, out: T ): Results;
191+
}
192+
193+
/**
194+
* Computes a two-sample Z-test for double-precision floating-point strided arrays.
195+
*
196+
* @param NX - number of indexed elements in `x`
197+
* @param NY - number of indexed elements in `y`
198+
* @param alternative - alternative hypothesis
199+
* @param alpha - significance level
200+
* @param diff - difference in means under the null hypothesis
201+
* @param sigmax - known standard deviation of `x`
202+
* @param x - first input array
203+
* @param strideX - stride length for `x`
204+
* @param sigmay - known standard deviation of `y`
205+
* @param y - second input array
206+
* @param strideY - stride length for `y`
207+
* @param out - output results object
208+
* @returns results object
209+
*
210+
* @example
211+
* var Float64Array = require( '@stdlib/array/float64' );
212+
* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' );
213+
*
214+
* var x = new Float64Array( [ 4.0, 4.0, 6.0, 6.0, 5.0 ] );
215+
* var y = new Float64Array( [ 3.0, 3.0, 5.0, 7.0, 7.0 ] );
216+
*
217+
* var results = new Results();
218+
* var out = dztest2( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 2.0, y, 1, results );
219+
* // returns {...}
220+
*
221+
* var bool = ( out === results );
222+
* // returns true
223+
*
224+
* @example
225+
* var Float64Array = require( '@stdlib/array/float64' );
226+
* var Results = require( '@stdlib/stats/base/ztest/two-sample/results/float64' );
227+
*
228+
* var x = new Float64Array( [ 4.0, 4.0, 6.0, 6.0, 5.0 ] );
229+
* var y = new Float64Array( [ 3.0, 3.0, 5.0, 7.0, 7.0 ] );
230+
*
231+
* var results = new Results();
232+
* var out = dztest2.ndarray( x.length, y.length, 'two-sided', 0.05, 0.0, 1.0, x, 1, 0, 2.0, y, 1, 0, results );
233+
* // returns {...}
234+
*
235+
* var bool = ( out === results );
236+
* // returns true
237+
*/
238+
declare var dztest2: Routine;
239+
240+
241+
// EXPORTS //
242+
243+
export = dztest2;

0 commit comments

Comments
 (0)