|
| 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