@sipemu/anofox-statistics 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +281 -0
- package/anofox_statistics_js.d.ts +744 -0
- package/anofox_statistics_js.js +1758 -0
- package/anofox_statistics_js_bg.wasm +0 -0
- package/package.json +39 -0
|
@@ -0,0 +1,1758 @@
|
|
|
1
|
+
/* @ts-self-types="./anofox_statistics_js.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Alternative hypothesis for JavaScript
|
|
5
|
+
* @enum {0 | 1 | 2}
|
|
6
|
+
*/
|
|
7
|
+
export const JsAlternative = Object.freeze({
|
|
8
|
+
TwoSided: 0, "0": "TwoSided",
|
|
9
|
+
Less: 1, "1": "Less",
|
|
10
|
+
Greater: 2, "2": "Greater",
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* ANOVA kind for JavaScript
|
|
15
|
+
* @enum {0 | 1}
|
|
16
|
+
*/
|
|
17
|
+
export const JsAnovaKind = Object.freeze({
|
|
18
|
+
Fisher: 0, "0": "Fisher",
|
|
19
|
+
Welch: 1, "1": "Welch",
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Correlation TOST method for JavaScript
|
|
24
|
+
* @enum {0 | 1}
|
|
25
|
+
*/
|
|
26
|
+
export const JsCorrelationTostMethod = Object.freeze({
|
|
27
|
+
Pearson: 0, "0": "Pearson",
|
|
28
|
+
Spearman: 1, "1": "Spearman",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ICC type for JavaScript
|
|
33
|
+
* @enum {0 | 1 | 2 | 3 | 4 | 5}
|
|
34
|
+
*/
|
|
35
|
+
export const JsICCType = Object.freeze({
|
|
36
|
+
ICC1: 0, "0": "ICC1",
|
|
37
|
+
ICC2: 1, "1": "ICC2",
|
|
38
|
+
ICC3: 2, "2": "ICC3",
|
|
39
|
+
ICC1k: 3, "3": "ICC1k",
|
|
40
|
+
ICC2k: 4, "4": "ICC2k",
|
|
41
|
+
ICC3k: 5, "5": "ICC3k",
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Kendall variant for JavaScript
|
|
46
|
+
* @enum {0 | 1 | 2}
|
|
47
|
+
*/
|
|
48
|
+
export const JsKendallVariant = Object.freeze({
|
|
49
|
+
TauA: 0, "0": "TauA",
|
|
50
|
+
TauB: 1, "1": "TauB",
|
|
51
|
+
TauC: 2, "2": "TauC",
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Kernel type for MMD test
|
|
56
|
+
* @enum {0 | 1 | 2}
|
|
57
|
+
*/
|
|
58
|
+
export const JsKernel = Object.freeze({
|
|
59
|
+
Gaussian: 0, "0": "Gaussian",
|
|
60
|
+
Laplacian: 1, "1": "Laplacian",
|
|
61
|
+
Linear: 2, "2": "Linear",
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Loss function for forecast comparison
|
|
66
|
+
* @enum {0 | 1}
|
|
67
|
+
*/
|
|
68
|
+
export const JsLossFunction = Object.freeze({
|
|
69
|
+
SquaredError: 0, "0": "SquaredError",
|
|
70
|
+
AbsoluteError: 1, "1": "AbsoluteError",
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* MCS statistic type
|
|
75
|
+
* @enum {0 | 1}
|
|
76
|
+
*/
|
|
77
|
+
export const JsMCSStatistic = Object.freeze({
|
|
78
|
+
Max: 0, "0": "Max",
|
|
79
|
+
Range: 1, "1": "Range",
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* T-test kind for JavaScript
|
|
84
|
+
* @enum {0 | 1 | 2}
|
|
85
|
+
*/
|
|
86
|
+
export const JsTTestKind = Object.freeze({
|
|
87
|
+
Welch: 0, "0": "Welch",
|
|
88
|
+
Student: 1, "1": "Student",
|
|
89
|
+
Paired: 2, "2": "Paired",
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Variance estimator for forecast tests
|
|
94
|
+
* @enum {0 | 1}
|
|
95
|
+
*/
|
|
96
|
+
export const JsVarEstimator = Object.freeze({
|
|
97
|
+
Acf: 0, "0": "Acf",
|
|
98
|
+
Bartlett: 1, "1": "Bartlett",
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Exact binomial test.
|
|
103
|
+
*
|
|
104
|
+
* @param successes - Number of successes
|
|
105
|
+
* @param trials - Number of trials
|
|
106
|
+
* @param p0 - Hypothesized probability (default: 0.5)
|
|
107
|
+
* @param alternative - Alternative hypothesis direction
|
|
108
|
+
* @returns Object with p_value, estimate, conf_int_lower, conf_int_upper
|
|
109
|
+
* @param {number} successes
|
|
110
|
+
* @param {number} trials
|
|
111
|
+
* @param {number | null | undefined} p0
|
|
112
|
+
* @param {JsAlternative} alternative
|
|
113
|
+
* @returns {any}
|
|
114
|
+
*/
|
|
115
|
+
export function binomTest(successes, trials, p0, alternative) {
|
|
116
|
+
const ret = wasm.binomTest(successes, trials, !isLikeNone(p0), isLikeNone(p0) ? 0 : p0, alternative);
|
|
117
|
+
if (ret[2]) {
|
|
118
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
119
|
+
}
|
|
120
|
+
return takeFromExternrefTable0(ret[0]);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Brown-Forsythe test for homogeneity of variances.
|
|
125
|
+
*
|
|
126
|
+
* @param groups - Array of groups, each group is a Float64Array
|
|
127
|
+
* @returns Object with statistic, df1, df2, p_value
|
|
128
|
+
* @param {Array<any>} groups
|
|
129
|
+
* @returns {any}
|
|
130
|
+
*/
|
|
131
|
+
export function brownForsythe(groups) {
|
|
132
|
+
const ret = wasm.brownForsythe(groups);
|
|
133
|
+
if (ret[2]) {
|
|
134
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
135
|
+
}
|
|
136
|
+
return takeFromExternrefTable0(ret[0]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Brunner-Munzel test for stochastic equality.
|
|
141
|
+
*
|
|
142
|
+
* @param x - First sample as Float64Array
|
|
143
|
+
* @param y - Second sample as Float64Array
|
|
144
|
+
* @param alternative - Alternative hypothesis direction
|
|
145
|
+
* @param alpha - If specified, compute CI at (1-alpha) level (e.g., 0.05 for 95% CI)
|
|
146
|
+
* @returns Object with statistic, df, p_value, estimate, conf_int
|
|
147
|
+
* @param {Float64Array} x
|
|
148
|
+
* @param {Float64Array} y
|
|
149
|
+
* @param {JsAlternative} alternative
|
|
150
|
+
* @param {number | null} [alpha]
|
|
151
|
+
* @returns {any}
|
|
152
|
+
*/
|
|
153
|
+
export function brunnerMunzel(x, y, alternative, alpha) {
|
|
154
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
155
|
+
const len0 = WASM_VECTOR_LEN;
|
|
156
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
157
|
+
const len1 = WASM_VECTOR_LEN;
|
|
158
|
+
const ret = wasm.brunnerMunzel(ptr0, len0, ptr1, len1, alternative, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
159
|
+
if (ret[2]) {
|
|
160
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
161
|
+
}
|
|
162
|
+
return takeFromExternrefTable0(ret[0]);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Chi-square goodness-of-fit test.
|
|
167
|
+
*
|
|
168
|
+
* @param observed - Observed counts as array of numbers
|
|
169
|
+
* @param expectedProps - Expected proportions as array of numbers (must sum to 1), or null for uniform
|
|
170
|
+
* @returns Object with statistic, df, p_value
|
|
171
|
+
* @param {Float64Array} observed
|
|
172
|
+
* @param {Float64Array | null} [expected_props]
|
|
173
|
+
* @returns {any}
|
|
174
|
+
*/
|
|
175
|
+
export function chiSquareGoodnessOfFit(observed, expected_props) {
|
|
176
|
+
const ptr0 = passArrayF64ToWasm0(observed, wasm.__wbindgen_malloc);
|
|
177
|
+
const len0 = WASM_VECTOR_LEN;
|
|
178
|
+
var ptr1 = isLikeNone(expected_props) ? 0 : passArrayF64ToWasm0(expected_props, wasm.__wbindgen_malloc);
|
|
179
|
+
var len1 = WASM_VECTOR_LEN;
|
|
180
|
+
const ret = wasm.chiSquareGoodnessOfFit(ptr0, len0, ptr1, len1);
|
|
181
|
+
if (ret[2]) {
|
|
182
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
183
|
+
}
|
|
184
|
+
return takeFromExternrefTable0(ret[0]);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Chi-square test for independence.
|
|
189
|
+
*
|
|
190
|
+
* @param observed - 2D array of observed counts (contingency table)
|
|
191
|
+
* @param yatesCorrection - Apply Yates continuity correction for 2x2 tables (default: false)
|
|
192
|
+
* @returns Object with statistic, df, p_value, expected frequencies
|
|
193
|
+
* @param {Array<any>} observed
|
|
194
|
+
* @param {boolean | null} [yates_correction]
|
|
195
|
+
* @returns {any}
|
|
196
|
+
*/
|
|
197
|
+
export function chiSquareTest(observed, yates_correction) {
|
|
198
|
+
const ret = wasm.chiSquareTest(observed, isLikeNone(yates_correction) ? 0xFFFFFF : yates_correction ? 1 : 0);
|
|
199
|
+
if (ret[2]) {
|
|
200
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
201
|
+
}
|
|
202
|
+
return takeFromExternrefTable0(ret[0]);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Clark-West test for comparing nested forecast models.
|
|
207
|
+
*
|
|
208
|
+
* @param e1 - Forecast errors from restricted model as Float64Array
|
|
209
|
+
* @param e2 - Forecast errors from unrestricted model as Float64Array
|
|
210
|
+
* @param horizon - Forecast horizon for HAC variance adjustment
|
|
211
|
+
* @returns Object with statistic, p_value, p_value_two_sided
|
|
212
|
+
* @param {Float64Array} e1
|
|
213
|
+
* @param {Float64Array} e2
|
|
214
|
+
* @param {number} horizon
|
|
215
|
+
* @returns {any}
|
|
216
|
+
*/
|
|
217
|
+
export function clarkWest(e1, e2, horizon) {
|
|
218
|
+
const ptr0 = passArrayF64ToWasm0(e1, wasm.__wbindgen_malloc);
|
|
219
|
+
const len0 = WASM_VECTOR_LEN;
|
|
220
|
+
const ptr1 = passArrayF64ToWasm0(e2, wasm.__wbindgen_malloc);
|
|
221
|
+
const len1 = WASM_VECTOR_LEN;
|
|
222
|
+
const ret = wasm.clarkWest(ptr0, len0, ptr1, len1, horizon);
|
|
223
|
+
if (ret[2]) {
|
|
224
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
225
|
+
}
|
|
226
|
+
return takeFromExternrefTable0(ret[0]);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Cohen's Kappa for inter-rater agreement.
|
|
231
|
+
*
|
|
232
|
+
* @param table - 2D agreement matrix (square, same categories for both raters)
|
|
233
|
+
* @param weighted - Use weighted kappa with linear weights (default: false)
|
|
234
|
+
* @returns Object with kappa, se, z, p_value, conf_int_lower, conf_int_upper, weighted
|
|
235
|
+
* @param {Array<any>} table
|
|
236
|
+
* @param {boolean | null} [weighted]
|
|
237
|
+
* @returns {any}
|
|
238
|
+
*/
|
|
239
|
+
export function cohenKappa(table, weighted) {
|
|
240
|
+
const ret = wasm.cohenKappa(table, isLikeNone(weighted) ? 0xFFFFFF : weighted ? 1 : 0);
|
|
241
|
+
if (ret[2]) {
|
|
242
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
243
|
+
}
|
|
244
|
+
return takeFromExternrefTable0(ret[0]);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Contingency coefficient.
|
|
249
|
+
*
|
|
250
|
+
* @param observed - 2D array of observed counts
|
|
251
|
+
* @returns Object with estimate
|
|
252
|
+
* @param {Array<any>} observed
|
|
253
|
+
* @returns {any}
|
|
254
|
+
*/
|
|
255
|
+
export function contingencyCoefficient(observed) {
|
|
256
|
+
const ret = wasm.contingencyCoefficient(observed);
|
|
257
|
+
if (ret[2]) {
|
|
258
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
259
|
+
}
|
|
260
|
+
return takeFromExternrefTable0(ret[0]);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Cramér's V measure of association.
|
|
265
|
+
*
|
|
266
|
+
* @param observed - 2D array of observed counts
|
|
267
|
+
* @returns Object with estimate (Cramér's V)
|
|
268
|
+
* @param {Array<any>} observed
|
|
269
|
+
* @returns {any}
|
|
270
|
+
*/
|
|
271
|
+
export function cramersV(observed) {
|
|
272
|
+
const ret = wasm.cramersV(observed);
|
|
273
|
+
if (ret[2]) {
|
|
274
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
275
|
+
}
|
|
276
|
+
return takeFromExternrefTable0(ret[0]);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* D'Agostino-Pearson K² test for normality.
|
|
281
|
+
*
|
|
282
|
+
* Tests normality using both skewness and kurtosis.
|
|
283
|
+
*
|
|
284
|
+
* @param x - Sample data as Float64Array
|
|
285
|
+
* @returns Object with k2_statistic, p_value, skewness_z, kurtosis_z
|
|
286
|
+
* @param {Float64Array} x
|
|
287
|
+
* @returns {any}
|
|
288
|
+
*/
|
|
289
|
+
export function dagostinoKSquared(x) {
|
|
290
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
291
|
+
const len0 = WASM_VECTOR_LEN;
|
|
292
|
+
const ret = wasm.dagostinoKSquared(ptr0, len0);
|
|
293
|
+
if (ret[2]) {
|
|
294
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
295
|
+
}
|
|
296
|
+
return takeFromExternrefTable0(ret[0]);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* Diebold-Mariano test for comparing forecast accuracy.
|
|
301
|
+
*
|
|
302
|
+
* @param e1 - Forecast errors from model 1 as Float64Array
|
|
303
|
+
* @param e2 - Forecast errors from model 2 as Float64Array
|
|
304
|
+
* @param lossFunction - Loss function (SquaredError or AbsoluteError)
|
|
305
|
+
* @param horizon - Forecast horizon (h=1 for 1-step ahead)
|
|
306
|
+
* @param alternative - Alternative hypothesis direction
|
|
307
|
+
* @param varEstimator - Variance estimator (Acf or Bartlett)
|
|
308
|
+
* @returns Object with statistic, p_value, horizon
|
|
309
|
+
* @param {Float64Array} e1
|
|
310
|
+
* @param {Float64Array} e2
|
|
311
|
+
* @param {JsLossFunction} loss_function
|
|
312
|
+
* @param {number} horizon
|
|
313
|
+
* @param {JsAlternative} alternative
|
|
314
|
+
* @param {JsVarEstimator} var_estimator
|
|
315
|
+
* @returns {any}
|
|
316
|
+
*/
|
|
317
|
+
export function dieboldMariano(e1, e2, loss_function, horizon, alternative, var_estimator) {
|
|
318
|
+
const ptr0 = passArrayF64ToWasm0(e1, wasm.__wbindgen_malloc);
|
|
319
|
+
const len0 = WASM_VECTOR_LEN;
|
|
320
|
+
const ptr1 = passArrayF64ToWasm0(e2, wasm.__wbindgen_malloc);
|
|
321
|
+
const len1 = WASM_VECTOR_LEN;
|
|
322
|
+
const ret = wasm.dieboldMariano(ptr0, len0, ptr1, len1, loss_function, horizon, alternative, var_estimator);
|
|
323
|
+
if (ret[2]) {
|
|
324
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
325
|
+
}
|
|
326
|
+
return takeFromExternrefTable0(ret[0]);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Distance correlation (measures non-linear dependence).
|
|
331
|
+
*
|
|
332
|
+
* @param x - First variable as Float64Array
|
|
333
|
+
* @param y - Second variable as Float64Array
|
|
334
|
+
* @returns Object with dcor, dcov, dvar_x, dvar_y, statistic
|
|
335
|
+
* @param {Float64Array} x
|
|
336
|
+
* @param {Float64Array} y
|
|
337
|
+
* @returns {any}
|
|
338
|
+
*/
|
|
339
|
+
export function distanceCorrelation(x, y) {
|
|
340
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
341
|
+
const len0 = WASM_VECTOR_LEN;
|
|
342
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
343
|
+
const len1 = WASM_VECTOR_LEN;
|
|
344
|
+
const ret = wasm.distanceCorrelation(ptr0, len0, ptr1, len1);
|
|
345
|
+
if (ret[2]) {
|
|
346
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
347
|
+
}
|
|
348
|
+
return takeFromExternrefTable0(ret[0]);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Distance correlation with permutation test.
|
|
353
|
+
*
|
|
354
|
+
* @param x - First variable as Float64Array
|
|
355
|
+
* @param y - Second variable as Float64Array
|
|
356
|
+
* @param nPermutations - Number of permutations (default: 999)
|
|
357
|
+
* @param seed - Random seed (optional)
|
|
358
|
+
* @returns Object with dcor, statistic, p_value
|
|
359
|
+
* @param {Float64Array} x
|
|
360
|
+
* @param {Float64Array} y
|
|
361
|
+
* @param {number | null} [n_permutations]
|
|
362
|
+
* @param {bigint | null} [seed]
|
|
363
|
+
* @returns {any}
|
|
364
|
+
*/
|
|
365
|
+
export function distanceCorrelationTest(x, y, n_permutations, seed) {
|
|
366
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
367
|
+
const len0 = WASM_VECTOR_LEN;
|
|
368
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
369
|
+
const len1 = WASM_VECTOR_LEN;
|
|
370
|
+
const ret = wasm.distanceCorrelationTest(ptr0, len0, ptr1, len1, isLikeNone(n_permutations) ? 0x100000001 : (n_permutations) >>> 0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
371
|
+
if (ret[2]) {
|
|
372
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
373
|
+
}
|
|
374
|
+
return takeFromExternrefTable0(ret[0]);
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Energy distance two-sample test (multivariate data).
|
|
379
|
+
*
|
|
380
|
+
* @param x - First sample as 2D array (each row is an observation)
|
|
381
|
+
* @param y - Second sample as 2D array
|
|
382
|
+
* @param nPermutations - Number of permutations (default: 999)
|
|
383
|
+
* @param seed - Random seed (optional)
|
|
384
|
+
* @returns Object with statistic, p_value, n_permutations
|
|
385
|
+
* @param {Array<any>} x
|
|
386
|
+
* @param {Array<any>} y
|
|
387
|
+
* @param {number | null} [n_permutations]
|
|
388
|
+
* @param {bigint | null} [seed]
|
|
389
|
+
* @returns {any}
|
|
390
|
+
*/
|
|
391
|
+
export function energyDistanceTest(x, y, n_permutations, seed) {
|
|
392
|
+
const ret = wasm.energyDistanceTest(x, y, isLikeNone(n_permutations) ? 0x100000001 : (n_permutations) >>> 0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
393
|
+
if (ret[2]) {
|
|
394
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
395
|
+
}
|
|
396
|
+
return takeFromExternrefTable0(ret[0]);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Energy distance two-sample test (1D data).
|
|
401
|
+
*
|
|
402
|
+
* Tests if two samples come from the same distribution using energy distance.
|
|
403
|
+
*
|
|
404
|
+
* @param x - First sample as Float64Array
|
|
405
|
+
* @param y - Second sample as Float64Array
|
|
406
|
+
* @param nPermutations - Number of permutations (default: 999)
|
|
407
|
+
* @param seed - Random seed (optional)
|
|
408
|
+
* @returns Object with statistic, p_value, n_permutations
|
|
409
|
+
* @param {Float64Array} x
|
|
410
|
+
* @param {Float64Array} y
|
|
411
|
+
* @param {number | null} [n_permutations]
|
|
412
|
+
* @param {bigint | null} [seed]
|
|
413
|
+
* @returns {any}
|
|
414
|
+
*/
|
|
415
|
+
export function energyDistanceTest1d(x, y, n_permutations, seed) {
|
|
416
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
417
|
+
const len0 = WASM_VECTOR_LEN;
|
|
418
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
419
|
+
const len1 = WASM_VECTOR_LEN;
|
|
420
|
+
const ret = wasm.energyDistanceTest1d(ptr0, len0, ptr1, len1, isLikeNone(n_permutations) ? 0x100000001 : (n_permutations) >>> 0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
421
|
+
if (ret[2]) {
|
|
422
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
423
|
+
}
|
|
424
|
+
return takeFromExternrefTable0(ret[0]);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Fisher's exact test for 2x2 contingency tables.
|
|
429
|
+
*
|
|
430
|
+
* @param table - 2x2 contingency table as [[a, b], [c, d]]
|
|
431
|
+
* @param alternative - Alternative hypothesis direction
|
|
432
|
+
* @returns Object with odds_ratio, p_value, conf_int_lower, conf_int_upper
|
|
433
|
+
* @param {Array<any>} table
|
|
434
|
+
* @param {JsAlternative} alternative
|
|
435
|
+
* @returns {any}
|
|
436
|
+
*/
|
|
437
|
+
export function fisherExact(table, alternative) {
|
|
438
|
+
const ret = wasm.fisherExact(table, alternative);
|
|
439
|
+
if (ret[2]) {
|
|
440
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
441
|
+
}
|
|
442
|
+
return takeFromExternrefTable0(ret[0]);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
* G-test (likelihood ratio test) for independence.
|
|
447
|
+
*
|
|
448
|
+
* @param observed - 2D array of observed counts (contingency table)
|
|
449
|
+
* @returns Object with statistic, df, p_value, expected frequencies
|
|
450
|
+
* @param {Array<any>} observed
|
|
451
|
+
* @returns {any}
|
|
452
|
+
*/
|
|
453
|
+
export function gTest(observed) {
|
|
454
|
+
const ret = wasm.gTest(observed);
|
|
455
|
+
if (ret[2]) {
|
|
456
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
457
|
+
}
|
|
458
|
+
return takeFromExternrefTable0(ret[0]);
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/**
|
|
462
|
+
* @returns {string}
|
|
463
|
+
*/
|
|
464
|
+
export function getVersion() {
|
|
465
|
+
let deferred1_0;
|
|
466
|
+
let deferred1_1;
|
|
467
|
+
try {
|
|
468
|
+
const ret = wasm.getVersion();
|
|
469
|
+
deferred1_0 = ret[0];
|
|
470
|
+
deferred1_1 = ret[1];
|
|
471
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
472
|
+
} finally {
|
|
473
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/**
|
|
478
|
+
* Intraclass correlation coefficient.
|
|
479
|
+
*
|
|
480
|
+
* @param data - 2D array where rows are subjects and columns are raters
|
|
481
|
+
* @param iccType - ICC type (ICC1, ICC2, ICC3, ICC1k, ICC2k, ICC3k)
|
|
482
|
+
* @returns Object with icc, f_value, df1, df2, p_value, conf_int_lower, conf_int_upper
|
|
483
|
+
* @param {Array<any>} data
|
|
484
|
+
* @param {JsICCType} icc_type
|
|
485
|
+
* @returns {any}
|
|
486
|
+
*/
|
|
487
|
+
export function intraclassCorrelation(data, icc_type) {
|
|
488
|
+
const ret = wasm.intraclassCorrelation(data, icc_type);
|
|
489
|
+
if (ret[2]) {
|
|
490
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
491
|
+
}
|
|
492
|
+
return takeFromExternrefTable0(ret[0]);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Kendall's tau correlation coefficient.
|
|
497
|
+
*
|
|
498
|
+
* @param x - First variable as Float64Array
|
|
499
|
+
* @param y - Second variable as Float64Array
|
|
500
|
+
* @param variant - Tau variant (TauA, TauB, TauC)
|
|
501
|
+
* @returns Object with estimate, statistic, p_value, conf_int
|
|
502
|
+
* @param {Float64Array} x
|
|
503
|
+
* @param {Float64Array} y
|
|
504
|
+
* @param {JsKendallVariant} variant
|
|
505
|
+
* @returns {any}
|
|
506
|
+
*/
|
|
507
|
+
export function kendallCorrelation(x, y, variant) {
|
|
508
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
509
|
+
const len0 = WASM_VECTOR_LEN;
|
|
510
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
511
|
+
const len1 = WASM_VECTOR_LEN;
|
|
512
|
+
const ret = wasm.kendallCorrelation(ptr0, len0, ptr1, len1, variant);
|
|
513
|
+
if (ret[2]) {
|
|
514
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
515
|
+
}
|
|
516
|
+
return takeFromExternrefTable0(ret[0]);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Kruskal-Wallis H test (non-parametric one-way ANOVA).
|
|
521
|
+
*
|
|
522
|
+
* @param groups - Array of groups, each group is a Float64Array
|
|
523
|
+
* @returns Object with statistic (H), df, p_value
|
|
524
|
+
* @param {Array<any>} groups
|
|
525
|
+
* @returns {any}
|
|
526
|
+
*/
|
|
527
|
+
export function kruskalWallis(groups) {
|
|
528
|
+
const ret = wasm.kruskalWallis(groups);
|
|
529
|
+
if (ret[2]) {
|
|
530
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
531
|
+
}
|
|
532
|
+
return takeFromExternrefTable0(ret[0]);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Mann-Whitney U test (Wilcoxon rank-sum test).
|
|
537
|
+
*
|
|
538
|
+
* @param x - First sample as Float64Array
|
|
539
|
+
* @param y - Second sample as Float64Array
|
|
540
|
+
* @param alternative - Alternative hypothesis direction
|
|
541
|
+
* @param continuityCorrectionParam - Whether to apply continuity correction (default: true)
|
|
542
|
+
* @param exact - Whether to compute exact p-value (default: false)
|
|
543
|
+
* @param confLevel - Confidence level for Hodges-Lehmann CI (optional)
|
|
544
|
+
* @param mu - Location shift under H0 (default: 0)
|
|
545
|
+
* @returns Object with statistic, p_value, estimate, null_value, conf_int
|
|
546
|
+
* @param {Float64Array} x
|
|
547
|
+
* @param {Float64Array} y
|
|
548
|
+
* @param {JsAlternative} alternative
|
|
549
|
+
* @param {boolean | null} [continuity_correction]
|
|
550
|
+
* @param {boolean | null} [exact]
|
|
551
|
+
* @param {number | null} [conf_level]
|
|
552
|
+
* @param {number | null} [mu]
|
|
553
|
+
* @returns {any}
|
|
554
|
+
*/
|
|
555
|
+
export function mannWhitneyU(x, y, alternative, continuity_correction, exact, conf_level, mu) {
|
|
556
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
557
|
+
const len0 = WASM_VECTOR_LEN;
|
|
558
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
559
|
+
const len1 = WASM_VECTOR_LEN;
|
|
560
|
+
const ret = wasm.mannWhitneyU(ptr0, len0, ptr1, len1, alternative, isLikeNone(continuity_correction) ? 0xFFFFFF : continuity_correction ? 1 : 0, isLikeNone(exact) ? 0xFFFFFF : exact ? 1 : 0, !isLikeNone(conf_level), isLikeNone(conf_level) ? 0 : conf_level, !isLikeNone(mu), isLikeNone(mu) ? 0 : mu);
|
|
561
|
+
if (ret[2]) {
|
|
562
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
563
|
+
}
|
|
564
|
+
return takeFromExternrefTable0(ret[0]);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/**
|
|
568
|
+
* McNemar's exact test for paired proportions (small samples).
|
|
569
|
+
*
|
|
570
|
+
* @param table - 2x2 paired table as [[a, b], [c, d]]
|
|
571
|
+
* @returns Object with p_value, b, c
|
|
572
|
+
* @param {Array<any>} table
|
|
573
|
+
* @returns {any}
|
|
574
|
+
*/
|
|
575
|
+
export function mcnemarExact(table) {
|
|
576
|
+
const ret = wasm.mcnemarExact(table);
|
|
577
|
+
if (ret[2]) {
|
|
578
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
579
|
+
}
|
|
580
|
+
return takeFromExternrefTable0(ret[0]);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/**
|
|
584
|
+
* McNemar's test for paired proportions.
|
|
585
|
+
*
|
|
586
|
+
* @param table - 2x2 paired table as [[a, b], [c, d]]
|
|
587
|
+
* @param correction - Apply continuity correction (default: true)
|
|
588
|
+
* @returns Object with statistic, df, p_value
|
|
589
|
+
* @param {Array<any>} table
|
|
590
|
+
* @param {boolean | null} [correction]
|
|
591
|
+
* @returns {any}
|
|
592
|
+
*/
|
|
593
|
+
export function mcnemarTest(table, correction) {
|
|
594
|
+
const ret = wasm.mcnemarTest(table, isLikeNone(correction) ? 0xFFFFFF : correction ? 1 : 0);
|
|
595
|
+
if (ret[2]) {
|
|
596
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
597
|
+
}
|
|
598
|
+
return takeFromExternrefTable0(ret[0]);
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Maximum Mean Discrepancy two-sample test (multivariate data).
|
|
603
|
+
*
|
|
604
|
+
* @param x - First sample as 2D array
|
|
605
|
+
* @param y - Second sample as 2D array
|
|
606
|
+
* @param kernel - Kernel type (Gaussian, Laplacian, or Linear)
|
|
607
|
+
* @param bandwidth - Kernel bandwidth (required for Gaussian and Laplacian)
|
|
608
|
+
* @param nPermutations - Number of permutations (default: 999)
|
|
609
|
+
* @param seed - Random seed (optional)
|
|
610
|
+
* @returns Object with statistic, p_value, n_permutations
|
|
611
|
+
* @param {Array<any>} x
|
|
612
|
+
* @param {Array<any>} y
|
|
613
|
+
* @param {JsKernel} kernel
|
|
614
|
+
* @param {number | null} [bandwidth]
|
|
615
|
+
* @param {number | null} [n_permutations]
|
|
616
|
+
* @param {bigint | null} [seed]
|
|
617
|
+
* @returns {any}
|
|
618
|
+
*/
|
|
619
|
+
export function mmdTest(x, y, kernel, bandwidth, n_permutations, seed) {
|
|
620
|
+
const ret = wasm.mmdTest(x, y, kernel, !isLikeNone(bandwidth), isLikeNone(bandwidth) ? 0 : bandwidth, isLikeNone(n_permutations) ? 0x100000001 : (n_permutations) >>> 0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
621
|
+
if (ret[2]) {
|
|
622
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
623
|
+
}
|
|
624
|
+
return takeFromExternrefTable0(ret[0]);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Maximum Mean Discrepancy two-sample test (1D data).
|
|
629
|
+
*
|
|
630
|
+
* Uses median heuristic for bandwidth selection automatically.
|
|
631
|
+
*
|
|
632
|
+
* @param x - First sample as Float64Array
|
|
633
|
+
* @param y - Second sample as Float64Array
|
|
634
|
+
* @param nPermutations - Number of permutations (default: 999)
|
|
635
|
+
* @param seed - Random seed (optional)
|
|
636
|
+
* @returns Object with statistic, p_value, n_permutations
|
|
637
|
+
* @param {Float64Array} x
|
|
638
|
+
* @param {Float64Array} y
|
|
639
|
+
* @param {number | null} [n_permutations]
|
|
640
|
+
* @param {bigint | null} [seed]
|
|
641
|
+
* @returns {any}
|
|
642
|
+
*/
|
|
643
|
+
export function mmdTest1d(x, y, n_permutations, seed) {
|
|
644
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
645
|
+
const len0 = WASM_VECTOR_LEN;
|
|
646
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
647
|
+
const len1 = WASM_VECTOR_LEN;
|
|
648
|
+
const ret = wasm.mmdTest1d(ptr0, len0, ptr1, len1, isLikeNone(n_permutations) ? 0x100000001 : (n_permutations) >>> 0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
649
|
+
if (ret[2]) {
|
|
650
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
651
|
+
}
|
|
652
|
+
return takeFromExternrefTable0(ret[0]);
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Model Confidence Set (MCS) procedure.
|
|
657
|
+
*
|
|
658
|
+
* Identifies the set of models that contains the best model with a given confidence.
|
|
659
|
+
*
|
|
660
|
+
* @param losses - Array of loss value arrays (one per model)
|
|
661
|
+
* @param alpha - Significance level (default: 0.1)
|
|
662
|
+
* @param statistic - MCS statistic (TMax or TR)
|
|
663
|
+
* @param nBootstrap - Number of bootstrap samples (default: 1000)
|
|
664
|
+
* @param blockLength - Expected block length for stationary bootstrap
|
|
665
|
+
* @param seed - Random seed (optional)
|
|
666
|
+
* @returns Object with included_models, excluded_models, p_values, elimination_order
|
|
667
|
+
* @param {Array<any>} losses
|
|
668
|
+
* @param {number | null | undefined} alpha
|
|
669
|
+
* @param {JsMCSStatistic} statistic
|
|
670
|
+
* @param {number | null | undefined} n_bootstrap
|
|
671
|
+
* @param {number} block_length
|
|
672
|
+
* @param {bigint | null} [seed]
|
|
673
|
+
* @returns {any}
|
|
674
|
+
*/
|
|
675
|
+
export function modelConfidenceSet(losses, alpha, statistic, n_bootstrap, block_length, seed) {
|
|
676
|
+
const ret = wasm.modelConfidenceSet(losses, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha, statistic, isLikeNone(n_bootstrap) ? 0x100000001 : (n_bootstrap) >>> 0, block_length, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
677
|
+
if (ret[2]) {
|
|
678
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
679
|
+
}
|
|
680
|
+
return takeFromExternrefTable0(ret[0]);
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/**
|
|
684
|
+
* MSPE-adjusted SPA test.
|
|
685
|
+
*
|
|
686
|
+
* @param benchmarkErrors - Forecast errors from benchmark model as Float64Array
|
|
687
|
+
* @param modelErrors - Array of forecast error arrays from alternative models
|
|
688
|
+
* @param nBootstrap - Number of bootstrap samples (default: 1000)
|
|
689
|
+
* @param blockLength - Expected block length for stationary bootstrap
|
|
690
|
+
* @param seed - Random seed (optional)
|
|
691
|
+
* @returns Object with statistic, p_value_consistent, p_value_upper
|
|
692
|
+
* @param {Float64Array} benchmark_errors
|
|
693
|
+
* @param {Array<any>} model_errors
|
|
694
|
+
* @param {number | null | undefined} n_bootstrap
|
|
695
|
+
* @param {number} block_length
|
|
696
|
+
* @param {bigint | null} [seed]
|
|
697
|
+
* @returns {any}
|
|
698
|
+
*/
|
|
699
|
+
export function mspeAdjustedSpa(benchmark_errors, model_errors, n_bootstrap, block_length, seed) {
|
|
700
|
+
const ptr0 = passArrayF64ToWasm0(benchmark_errors, wasm.__wbindgen_malloc);
|
|
701
|
+
const len0 = WASM_VECTOR_LEN;
|
|
702
|
+
const ret = wasm.mspeAdjustedSpa(ptr0, len0, model_errors, isLikeNone(n_bootstrap) ? 0x100000001 : (n_bootstrap) >>> 0, block_length, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
703
|
+
if (ret[2]) {
|
|
704
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
705
|
+
}
|
|
706
|
+
return takeFromExternrefTable0(ret[0]);
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* One-way ANOVA test.
|
|
711
|
+
*
|
|
712
|
+
* @param groups - Array of groups, each group is a Float64Array
|
|
713
|
+
* @param kind - Type of ANOVA (Fisher or Welch)
|
|
714
|
+
* @returns Object with statistic, df_between, df_within, p_value, SS and MS components
|
|
715
|
+
* @param {Array<any>} groups
|
|
716
|
+
* @param {JsAnovaKind} kind
|
|
717
|
+
* @returns {any}
|
|
718
|
+
*/
|
|
719
|
+
export function oneWayAnova(groups, kind) {
|
|
720
|
+
const ret = wasm.oneWayAnova(groups, kind);
|
|
721
|
+
if (ret[2]) {
|
|
722
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
723
|
+
}
|
|
724
|
+
return takeFromExternrefTable0(ret[0]);
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* Partial correlation controlling for confounders.
|
|
729
|
+
*
|
|
730
|
+
* @param x - First variable as Float64Array
|
|
731
|
+
* @param y - Second variable as Float64Array
|
|
732
|
+
* @param z - Array of confounding variables (each as Float64Array)
|
|
733
|
+
* @returns Object with estimate, statistic, df, p_value
|
|
734
|
+
* @param {Float64Array} x
|
|
735
|
+
* @param {Float64Array} y
|
|
736
|
+
* @param {Array<any>} z
|
|
737
|
+
* @returns {any}
|
|
738
|
+
*/
|
|
739
|
+
export function partialCorrelation(x, y, z) {
|
|
740
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
741
|
+
const len0 = WASM_VECTOR_LEN;
|
|
742
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
743
|
+
const len1 = WASM_VECTOR_LEN;
|
|
744
|
+
const ret = wasm.partialCorrelation(ptr0, len0, ptr1, len1, z);
|
|
745
|
+
if (ret[2]) {
|
|
746
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
747
|
+
}
|
|
748
|
+
return takeFromExternrefTable0(ret[0]);
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/**
|
|
752
|
+
* Pearson correlation coefficient with significance test.
|
|
753
|
+
*
|
|
754
|
+
* @param x - First variable as Float64Array
|
|
755
|
+
* @param y - Second variable as Float64Array
|
|
756
|
+
* @param confLevel - Confidence level for CI (optional, e.g., 0.95)
|
|
757
|
+
* @returns Object with estimate, statistic, df, p_value, conf_int
|
|
758
|
+
* @param {Float64Array} x
|
|
759
|
+
* @param {Float64Array} y
|
|
760
|
+
* @param {number | null} [conf_level]
|
|
761
|
+
* @returns {any}
|
|
762
|
+
*/
|
|
763
|
+
export function pearsonCorrelation(x, y, conf_level) {
|
|
764
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
765
|
+
const len0 = WASM_VECTOR_LEN;
|
|
766
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
767
|
+
const len1 = WASM_VECTOR_LEN;
|
|
768
|
+
const ret = wasm.pearsonCorrelation(ptr0, len0, ptr1, len1, !isLikeNone(conf_level), isLikeNone(conf_level) ? 0 : conf_level);
|
|
769
|
+
if (ret[2]) {
|
|
770
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
771
|
+
}
|
|
772
|
+
return takeFromExternrefTable0(ret[0]);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Permutation t-test.
|
|
777
|
+
*
|
|
778
|
+
* @param x - First sample as Float64Array
|
|
779
|
+
* @param y - Second sample as Float64Array
|
|
780
|
+
* @param alternative - Alternative hypothesis direction
|
|
781
|
+
* @param nPermutations - Number of permutations (default: 9999)
|
|
782
|
+
* @param seed - Random seed (optional)
|
|
783
|
+
* @returns Object with statistic, p_value, n_permutations
|
|
784
|
+
* @param {Float64Array} x
|
|
785
|
+
* @param {Float64Array} y
|
|
786
|
+
* @param {JsAlternative} alternative
|
|
787
|
+
* @param {number | null} [n_permutations]
|
|
788
|
+
* @param {bigint | null} [seed]
|
|
789
|
+
* @returns {any}
|
|
790
|
+
*/
|
|
791
|
+
export function permutationTTest(x, y, alternative, n_permutations, seed) {
|
|
792
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
793
|
+
const len0 = WASM_VECTOR_LEN;
|
|
794
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
795
|
+
const len1 = WASM_VECTOR_LEN;
|
|
796
|
+
const ret = wasm.permutationTTest(ptr0, len0, ptr1, len1, alternative, isLikeNone(n_permutations) ? 0x100000001 : (n_permutations) >>> 0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
797
|
+
if (ret[2]) {
|
|
798
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
799
|
+
}
|
|
800
|
+
return takeFromExternrefTable0(ret[0]);
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* Phi coefficient for 2x2 tables.
|
|
805
|
+
*
|
|
806
|
+
* @param table - 2x2 contingency table as [[a, b], [c, d]]
|
|
807
|
+
* @returns Object with estimate (phi coefficient)
|
|
808
|
+
* @param {Array<any>} table
|
|
809
|
+
* @returns {any}
|
|
810
|
+
*/
|
|
811
|
+
export function phiCoefficient(table) {
|
|
812
|
+
const ret = wasm.phiCoefficient(table);
|
|
813
|
+
if (ret[2]) {
|
|
814
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
815
|
+
}
|
|
816
|
+
return takeFromExternrefTable0(ret[0]);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* One-sample proportion test.
|
|
821
|
+
*
|
|
822
|
+
* @param successes - Number of successes
|
|
823
|
+
* @param trials - Number of trials
|
|
824
|
+
* @param p0 - Hypothesized probability
|
|
825
|
+
* @param alternative - Alternative hypothesis direction
|
|
826
|
+
* @returns Object with statistic, p_value, estimate, conf_int_lower, conf_int_upper
|
|
827
|
+
* @param {number} successes
|
|
828
|
+
* @param {number} trials
|
|
829
|
+
* @param {number} p0
|
|
830
|
+
* @param {JsAlternative} alternative
|
|
831
|
+
* @returns {any}
|
|
832
|
+
*/
|
|
833
|
+
export function propTestOne(successes, trials, p0, alternative) {
|
|
834
|
+
const ret = wasm.propTestOne(successes, trials, p0, alternative);
|
|
835
|
+
if (ret[2]) {
|
|
836
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
837
|
+
}
|
|
838
|
+
return takeFromExternrefTable0(ret[0]);
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Two-sample proportion test.
|
|
843
|
+
*
|
|
844
|
+
* @param successes1 - Number of successes in group 1
|
|
845
|
+
* @param trials1 - Number of trials in group 1
|
|
846
|
+
* @param successes2 - Number of successes in group 2
|
|
847
|
+
* @param trials2 - Number of trials in group 2
|
|
848
|
+
* @param alternative - Alternative hypothesis direction
|
|
849
|
+
* @param correction - Apply Yates' continuity correction (default: false)
|
|
850
|
+
* @returns Object with statistic, p_value, estimates, conf_int_lower, conf_int_upper
|
|
851
|
+
* @param {number} successes1
|
|
852
|
+
* @param {number} trials1
|
|
853
|
+
* @param {number} successes2
|
|
854
|
+
* @param {number} trials2
|
|
855
|
+
* @param {JsAlternative} alternative
|
|
856
|
+
* @param {boolean | null} [correction]
|
|
857
|
+
* @returns {any}
|
|
858
|
+
*/
|
|
859
|
+
export function propTestTwo(successes1, trials1, successes2, trials2, alternative, correction) {
|
|
860
|
+
const ret = wasm.propTestTwo(successes1, trials1, successes2, trials2, alternative, isLikeNone(correction) ? 0xFFFFFF : correction ? 1 : 0);
|
|
861
|
+
if (ret[2]) {
|
|
862
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
863
|
+
}
|
|
864
|
+
return takeFromExternrefTable0(ret[0]);
|
|
865
|
+
}
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* Semi-partial (part) correlation.
|
|
869
|
+
*
|
|
870
|
+
* @param x - First variable as Float64Array
|
|
871
|
+
* @param y - Second variable as Float64Array
|
|
872
|
+
* @param z - Array of confounding variables to control for x only (each as Float64Array)
|
|
873
|
+
* @returns Object with estimate, statistic, df, p_value
|
|
874
|
+
* @param {Float64Array} x
|
|
875
|
+
* @param {Float64Array} y
|
|
876
|
+
* @param {Array<any>} z
|
|
877
|
+
* @returns {any}
|
|
878
|
+
*/
|
|
879
|
+
export function semiPartialCorrelation(x, y, z) {
|
|
880
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
881
|
+
const len0 = WASM_VECTOR_LEN;
|
|
882
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
883
|
+
const len1 = WASM_VECTOR_LEN;
|
|
884
|
+
const ret = wasm.semiPartialCorrelation(ptr0, len0, ptr1, len1, z);
|
|
885
|
+
if (ret[2]) {
|
|
886
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
887
|
+
}
|
|
888
|
+
return takeFromExternrefTable0(ret[0]);
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* Shapiro-Wilk test for normality.
|
|
893
|
+
*
|
|
894
|
+
* @param x - Sample data as Float64Array
|
|
895
|
+
* @returns Object with statistic (W) and p_value
|
|
896
|
+
* @param {Float64Array} x
|
|
897
|
+
* @returns {any}
|
|
898
|
+
*/
|
|
899
|
+
export function shapiroWilk(x) {
|
|
900
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
901
|
+
const len0 = WASM_VECTOR_LEN;
|
|
902
|
+
const ret = wasm.shapiroWilk(ptr0, len0);
|
|
903
|
+
if (ret[2]) {
|
|
904
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
905
|
+
}
|
|
906
|
+
return takeFromExternrefTable0(ret[0]);
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
/**
|
|
910
|
+
* Superior Predictive Ability (SPA) test.
|
|
911
|
+
*
|
|
912
|
+
* Tests if a benchmark forecast is not inferior to a set of alternative forecasts.
|
|
913
|
+
*
|
|
914
|
+
* @param benchmarkLosses - Loss values from benchmark model as Float64Array
|
|
915
|
+
* @param modelLosses - Array of loss value arrays from competing models
|
|
916
|
+
* @param nBootstrap - Number of bootstrap samples (default: 1000)
|
|
917
|
+
* @param blockLength - Expected block length for stationary bootstrap
|
|
918
|
+
* @param seed - Random seed (optional)
|
|
919
|
+
* @returns Object with statistic, p_values, best_model_idx
|
|
920
|
+
* @param {Float64Array} benchmark_losses
|
|
921
|
+
* @param {Array<any>} model_losses
|
|
922
|
+
* @param {number | null | undefined} n_bootstrap
|
|
923
|
+
* @param {number} block_length
|
|
924
|
+
* @param {bigint | null} [seed]
|
|
925
|
+
* @returns {any}
|
|
926
|
+
*/
|
|
927
|
+
export function spaTest(benchmark_losses, model_losses, n_bootstrap, block_length, seed) {
|
|
928
|
+
const ptr0 = passArrayF64ToWasm0(benchmark_losses, wasm.__wbindgen_malloc);
|
|
929
|
+
const len0 = WASM_VECTOR_LEN;
|
|
930
|
+
const ret = wasm.spaTest(ptr0, len0, model_losses, isLikeNone(n_bootstrap) ? 0x100000001 : (n_bootstrap) >>> 0, block_length, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
931
|
+
if (ret[2]) {
|
|
932
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
933
|
+
}
|
|
934
|
+
return takeFromExternrefTable0(ret[0]);
|
|
935
|
+
}
|
|
936
|
+
|
|
937
|
+
/**
|
|
938
|
+
* Spearman rank correlation coefficient with significance test.
|
|
939
|
+
*
|
|
940
|
+
* @param x - First variable as Float64Array
|
|
941
|
+
* @param y - Second variable as Float64Array
|
|
942
|
+
* @param confLevel - Confidence level for CI (optional)
|
|
943
|
+
* @returns Object with estimate, statistic, df, p_value, conf_int
|
|
944
|
+
* @param {Float64Array} x
|
|
945
|
+
* @param {Float64Array} y
|
|
946
|
+
* @param {number | null} [conf_level]
|
|
947
|
+
* @returns {any}
|
|
948
|
+
*/
|
|
949
|
+
export function spearmanCorrelation(x, y, conf_level) {
|
|
950
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
951
|
+
const len0 = WASM_VECTOR_LEN;
|
|
952
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
953
|
+
const len1 = WASM_VECTOR_LEN;
|
|
954
|
+
const ret = wasm.spearmanCorrelation(ptr0, len0, ptr1, len1, !isLikeNone(conf_level), isLikeNone(conf_level) ? 0 : conf_level);
|
|
955
|
+
if (ret[2]) {
|
|
956
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
957
|
+
}
|
|
958
|
+
return takeFromExternrefTable0(ret[0]);
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
export function start() {
|
|
962
|
+
wasm.start();
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
/**
|
|
966
|
+
* Perform a t-test comparing two samples.
|
|
967
|
+
*
|
|
968
|
+
* @param x - First sample as Float64Array
|
|
969
|
+
* @param y - Second sample as Float64Array
|
|
970
|
+
* @param kind - Type of t-test (Welch, Student, or Paired)
|
|
971
|
+
* @param alternative - Alternative hypothesis direction
|
|
972
|
+
* @param mu - Null hypothesis value (default: 0.0)
|
|
973
|
+
* @param confLevel - Confidence level for CI (optional, e.g., 0.95)
|
|
974
|
+
* @returns Object with statistic, df, p_value, mean_x, mean_y, conf_int
|
|
975
|
+
* @param {Float64Array} x
|
|
976
|
+
* @param {Float64Array} y
|
|
977
|
+
* @param {JsTTestKind} kind
|
|
978
|
+
* @param {JsAlternative} alternative
|
|
979
|
+
* @param {number | null} [mu]
|
|
980
|
+
* @param {number | null} [conf_level]
|
|
981
|
+
* @returns {any}
|
|
982
|
+
*/
|
|
983
|
+
export function tTest(x, y, kind, alternative, mu, conf_level) {
|
|
984
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
985
|
+
const len0 = WASM_VECTOR_LEN;
|
|
986
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
987
|
+
const len1 = WASM_VECTOR_LEN;
|
|
988
|
+
const ret = wasm.tTest(ptr0, len0, ptr1, len1, kind, alternative, !isLikeNone(mu), isLikeNone(mu) ? 0 : mu, !isLikeNone(conf_level), isLikeNone(conf_level) ? 0 : conf_level);
|
|
989
|
+
if (ret[2]) {
|
|
990
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
991
|
+
}
|
|
992
|
+
return takeFromExternrefTable0(ret[0]);
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
/**
|
|
996
|
+
* TOST using bootstrap resampling.
|
|
997
|
+
*
|
|
998
|
+
* @param x - First sample as Float64Array
|
|
999
|
+
* @param y - Second sample as Float64Array
|
|
1000
|
+
* @param lowerBound - Lower equivalence bound
|
|
1001
|
+
* @param upperBound - Upper equivalence bound
|
|
1002
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1003
|
+
* @param nBootstrap - Number of bootstrap samples (default: 1000)
|
|
1004
|
+
* @param seed - Random seed (optional)
|
|
1005
|
+
* @returns TOST result object
|
|
1006
|
+
* @param {Float64Array} x
|
|
1007
|
+
* @param {Float64Array} y
|
|
1008
|
+
* @param {number} lower_bound
|
|
1009
|
+
* @param {number} upper_bound
|
|
1010
|
+
* @param {number | null} [alpha]
|
|
1011
|
+
* @param {number | null} [n_bootstrap]
|
|
1012
|
+
* @param {bigint | null} [seed]
|
|
1013
|
+
* @returns {any}
|
|
1014
|
+
*/
|
|
1015
|
+
export function tostBootstrap(x, y, lower_bound, upper_bound, alpha, n_bootstrap, seed) {
|
|
1016
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1017
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1018
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1019
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1020
|
+
const ret = wasm.tostBootstrap(ptr0, len0, ptr1, len1, lower_bound, upper_bound, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha, isLikeNone(n_bootstrap) ? 0x100000001 : (n_bootstrap) >>> 0, !isLikeNone(seed), isLikeNone(seed) ? BigInt(0) : seed);
|
|
1021
|
+
if (ret[2]) {
|
|
1022
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1023
|
+
}
|
|
1024
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* TOST for correlation equivalence.
|
|
1029
|
+
*
|
|
1030
|
+
* @param x - First variable as Float64Array
|
|
1031
|
+
* @param y - Second variable as Float64Array
|
|
1032
|
+
* @param rhoNull - Null value for correlation (usually 0)
|
|
1033
|
+
* @param lowerBound - Lower equivalence bound for correlation (e.g., -0.1)
|
|
1034
|
+
* @param upperBound - Upper equivalence bound for correlation (e.g., 0.1)
|
|
1035
|
+
* @param method - Correlation method (Pearson or Spearman)
|
|
1036
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1037
|
+
* @returns TOST result object
|
|
1038
|
+
* @param {Float64Array} x
|
|
1039
|
+
* @param {Float64Array} y
|
|
1040
|
+
* @param {number} rho_null
|
|
1041
|
+
* @param {number} lower_bound
|
|
1042
|
+
* @param {number} upper_bound
|
|
1043
|
+
* @param {JsCorrelationTostMethod} method
|
|
1044
|
+
* @param {number | null} [alpha]
|
|
1045
|
+
* @returns {any}
|
|
1046
|
+
*/
|
|
1047
|
+
export function tostCorrelation(x, y, rho_null, lower_bound, upper_bound, method, alpha) {
|
|
1048
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1049
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1050
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1051
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1052
|
+
const ret = wasm.tostCorrelation(ptr0, len0, ptr1, len1, rho_null, lower_bound, upper_bound, method, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
1053
|
+
if (ret[2]) {
|
|
1054
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1055
|
+
}
|
|
1056
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1057
|
+
}
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* TOST for one-sample proportion.
|
|
1061
|
+
*
|
|
1062
|
+
* @param successes - Number of successes
|
|
1063
|
+
* @param trials - Number of trials
|
|
1064
|
+
* @param p0 - Hypothesized proportion
|
|
1065
|
+
* @param lowerBound - Lower equivalence bound
|
|
1066
|
+
* @param upperBound - Upper equivalence bound
|
|
1067
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1068
|
+
* @returns TOST result object
|
|
1069
|
+
* @param {number} successes
|
|
1070
|
+
* @param {number} trials
|
|
1071
|
+
* @param {number} p0
|
|
1072
|
+
* @param {number} lower_bound
|
|
1073
|
+
* @param {number} upper_bound
|
|
1074
|
+
* @param {number | null} [alpha]
|
|
1075
|
+
* @returns {any}
|
|
1076
|
+
*/
|
|
1077
|
+
export function tostPropOne(successes, trials, p0, lower_bound, upper_bound, alpha) {
|
|
1078
|
+
const ret = wasm.tostPropOne(successes, trials, p0, lower_bound, upper_bound, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
1079
|
+
if (ret[2]) {
|
|
1080
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1081
|
+
}
|
|
1082
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* TOST for two-sample proportions.
|
|
1087
|
+
*
|
|
1088
|
+
* @param successes1 - Successes in group 1
|
|
1089
|
+
* @param trials1 - Trials in group 1
|
|
1090
|
+
* @param successes2 - Successes in group 2
|
|
1091
|
+
* @param trials2 - Trials in group 2
|
|
1092
|
+
* @param lowerBound - Lower equivalence bound
|
|
1093
|
+
* @param upperBound - Upper equivalence bound
|
|
1094
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1095
|
+
* @returns TOST result object
|
|
1096
|
+
* @param {number} successes1
|
|
1097
|
+
* @param {number} trials1
|
|
1098
|
+
* @param {number} successes2
|
|
1099
|
+
* @param {number} trials2
|
|
1100
|
+
* @param {number} lower_bound
|
|
1101
|
+
* @param {number} upper_bound
|
|
1102
|
+
* @param {number | null} [alpha]
|
|
1103
|
+
* @returns {any}
|
|
1104
|
+
*/
|
|
1105
|
+
export function tostPropTwo(successes1, trials1, successes2, trials2, lower_bound, upper_bound, alpha) {
|
|
1106
|
+
const ret = wasm.tostPropTwo(successes1, trials1, successes2, trials2, lower_bound, upper_bound, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
1107
|
+
if (ret[2]) {
|
|
1108
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1109
|
+
}
|
|
1110
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
/**
|
|
1114
|
+
* TOST t-test for one sample.
|
|
1115
|
+
*
|
|
1116
|
+
* @param x - Sample data as Float64Array
|
|
1117
|
+
* @param mu - Hypothesized mean
|
|
1118
|
+
* @param lowerBound - Lower equivalence bound (e.g., -0.5)
|
|
1119
|
+
* @param upperBound - Upper equivalence bound (e.g., 0.5)
|
|
1120
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1121
|
+
* @returns TOST result object
|
|
1122
|
+
* @param {Float64Array} x
|
|
1123
|
+
* @param {number} mu
|
|
1124
|
+
* @param {number} lower_bound
|
|
1125
|
+
* @param {number} upper_bound
|
|
1126
|
+
* @param {number | null} [alpha]
|
|
1127
|
+
* @returns {any}
|
|
1128
|
+
*/
|
|
1129
|
+
export function tostTTestOneSample(x, mu, lower_bound, upper_bound, alpha) {
|
|
1130
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1131
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1132
|
+
const ret = wasm.tostTTestOneSample(ptr0, len0, mu, lower_bound, upper_bound, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
1133
|
+
if (ret[2]) {
|
|
1134
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1135
|
+
}
|
|
1136
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
/**
|
|
1140
|
+
* TOST t-test for paired samples.
|
|
1141
|
+
*
|
|
1142
|
+
* @param x - First sample as Float64Array
|
|
1143
|
+
* @param y - Second sample as Float64Array
|
|
1144
|
+
* @param lowerBound - Lower equivalence bound
|
|
1145
|
+
* @param upperBound - Upper equivalence bound
|
|
1146
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1147
|
+
* @returns TOST result object
|
|
1148
|
+
* @param {Float64Array} x
|
|
1149
|
+
* @param {Float64Array} y
|
|
1150
|
+
* @param {number} lower_bound
|
|
1151
|
+
* @param {number} upper_bound
|
|
1152
|
+
* @param {number | null} [alpha]
|
|
1153
|
+
* @returns {any}
|
|
1154
|
+
*/
|
|
1155
|
+
export function tostTTestPaired(x, y, lower_bound, upper_bound, alpha) {
|
|
1156
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1157
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1158
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1159
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1160
|
+
const ret = wasm.tostTTestPaired(ptr0, len0, ptr1, len1, lower_bound, upper_bound, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
1161
|
+
if (ret[2]) {
|
|
1162
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1163
|
+
}
|
|
1164
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* TOST t-test for two independent samples.
|
|
1169
|
+
*
|
|
1170
|
+
* @param x - First sample as Float64Array
|
|
1171
|
+
* @param y - Second sample as Float64Array
|
|
1172
|
+
* @param lowerBound - Lower equivalence bound
|
|
1173
|
+
* @param upperBound - Upper equivalence bound
|
|
1174
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1175
|
+
* @param pooled - Use pooled variance (default: false for Welch)
|
|
1176
|
+
* @returns TOST result object
|
|
1177
|
+
* @param {Float64Array} x
|
|
1178
|
+
* @param {Float64Array} y
|
|
1179
|
+
* @param {number} lower_bound
|
|
1180
|
+
* @param {number} upper_bound
|
|
1181
|
+
* @param {number | null} [alpha]
|
|
1182
|
+
* @param {boolean | null} [pooled]
|
|
1183
|
+
* @returns {any}
|
|
1184
|
+
*/
|
|
1185
|
+
export function tostTTestTwoSample(x, y, lower_bound, upper_bound, alpha, pooled) {
|
|
1186
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1187
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1188
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1189
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1190
|
+
const ret = wasm.tostTTestTwoSample(ptr0, len0, ptr1, len1, lower_bound, upper_bound, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha, isLikeNone(pooled) ? 0xFFFFFF : pooled ? 1 : 0);
|
|
1191
|
+
if (ret[2]) {
|
|
1192
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1193
|
+
}
|
|
1194
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* TOST Wilcoxon test for paired samples.
|
|
1199
|
+
*
|
|
1200
|
+
* @param x - First sample as Float64Array
|
|
1201
|
+
* @param y - Second sample as Float64Array
|
|
1202
|
+
* @param lowerBound - Lower equivalence bound
|
|
1203
|
+
* @param upperBound - Upper equivalence bound
|
|
1204
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1205
|
+
* @returns TOST result object
|
|
1206
|
+
* @param {Float64Array} x
|
|
1207
|
+
* @param {Float64Array} y
|
|
1208
|
+
* @param {number} lower_bound
|
|
1209
|
+
* @param {number} upper_bound
|
|
1210
|
+
* @param {number | null} [alpha]
|
|
1211
|
+
* @returns {any}
|
|
1212
|
+
*/
|
|
1213
|
+
export function tostWilcoxonPaired(x, y, lower_bound, upper_bound, alpha) {
|
|
1214
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1215
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1216
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1217
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1218
|
+
const ret = wasm.tostWilcoxonPaired(ptr0, len0, ptr1, len1, lower_bound, upper_bound, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
1219
|
+
if (ret[2]) {
|
|
1220
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1221
|
+
}
|
|
1222
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1223
|
+
}
|
|
1224
|
+
|
|
1225
|
+
/**
|
|
1226
|
+
* TOST Wilcoxon test for two independent samples.
|
|
1227
|
+
*
|
|
1228
|
+
* @param x - First sample as Float64Array
|
|
1229
|
+
* @param y - Second sample as Float64Array
|
|
1230
|
+
* @param lowerBound - Lower equivalence bound
|
|
1231
|
+
* @param upperBound - Upper equivalence bound
|
|
1232
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1233
|
+
* @returns TOST result object
|
|
1234
|
+
* @param {Float64Array} x
|
|
1235
|
+
* @param {Float64Array} y
|
|
1236
|
+
* @param {number} lower_bound
|
|
1237
|
+
* @param {number} upper_bound
|
|
1238
|
+
* @param {number | null} [alpha]
|
|
1239
|
+
* @returns {any}
|
|
1240
|
+
*/
|
|
1241
|
+
export function tostWilcoxonTwoSample(x, y, lower_bound, upper_bound, alpha) {
|
|
1242
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1243
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1244
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1245
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1246
|
+
const ret = wasm.tostWilcoxonTwoSample(ptr0, len0, ptr1, len1, lower_bound, upper_bound, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
1247
|
+
if (ret[2]) {
|
|
1248
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1249
|
+
}
|
|
1250
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* TOST Yuen test using trimmed means.
|
|
1255
|
+
*
|
|
1256
|
+
* @param x - First sample as Float64Array
|
|
1257
|
+
* @param y - Second sample as Float64Array
|
|
1258
|
+
* @param lowerBound - Lower equivalence bound
|
|
1259
|
+
* @param upperBound - Upper equivalence bound
|
|
1260
|
+
* @param trim - Trim proportion (default: 0.2)
|
|
1261
|
+
* @param alpha - Significance level (default: 0.05)
|
|
1262
|
+
* @returns TOST result object
|
|
1263
|
+
* @param {Float64Array} x
|
|
1264
|
+
* @param {Float64Array} y
|
|
1265
|
+
* @param {number} lower_bound
|
|
1266
|
+
* @param {number} upper_bound
|
|
1267
|
+
* @param {number | null} [trim]
|
|
1268
|
+
* @param {number | null} [alpha]
|
|
1269
|
+
* @returns {any}
|
|
1270
|
+
*/
|
|
1271
|
+
export function tostYuen(x, y, lower_bound, upper_bound, trim, alpha) {
|
|
1272
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1273
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1274
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1275
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1276
|
+
const ret = wasm.tostYuen(ptr0, len0, ptr1, len1, lower_bound, upper_bound, !isLikeNone(trim), isLikeNone(trim) ? 0 : trim, !isLikeNone(alpha), isLikeNone(alpha) ? 0 : alpha);
|
|
1277
|
+
if (ret[2]) {
|
|
1278
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1279
|
+
}
|
|
1280
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1281
|
+
}
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Wilcoxon signed-rank test.
|
|
1285
|
+
*
|
|
1286
|
+
* @param x - First sample as Float64Array
|
|
1287
|
+
* @param y - Second sample as Float64Array (optional, for paired test)
|
|
1288
|
+
* @param alternative - Alternative hypothesis direction
|
|
1289
|
+
* @param continuityCorrectionParam - Whether to apply continuity correction (default: true)
|
|
1290
|
+
* @param exact - Whether to compute exact p-value (default: false)
|
|
1291
|
+
* @param confLevel - Confidence level for CI (optional)
|
|
1292
|
+
* @param mu - Null hypothesis value (default: 0.0)
|
|
1293
|
+
* @returns Object with statistic, p_value, estimate, null_value, conf_int
|
|
1294
|
+
* @param {Float64Array} x
|
|
1295
|
+
* @param {Float64Array} y
|
|
1296
|
+
* @param {JsAlternative} alternative
|
|
1297
|
+
* @param {boolean | null} [continuity_correction]
|
|
1298
|
+
* @param {boolean | null} [exact]
|
|
1299
|
+
* @param {number | null} [conf_level]
|
|
1300
|
+
* @param {number | null} [mu]
|
|
1301
|
+
* @returns {any}
|
|
1302
|
+
*/
|
|
1303
|
+
export function wilcoxonSignedRank(x, y, alternative, continuity_correction, exact, conf_level, mu) {
|
|
1304
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1305
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1306
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1307
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1308
|
+
const ret = wasm.wilcoxonSignedRank(ptr0, len0, ptr1, len1, alternative, isLikeNone(continuity_correction) ? 0xFFFFFF : continuity_correction ? 1 : 0, isLikeNone(exact) ? 0xFFFFFF : exact ? 1 : 0, !isLikeNone(conf_level), isLikeNone(conf_level) ? 0 : conf_level, !isLikeNone(mu), isLikeNone(mu) ? 0 : mu);
|
|
1309
|
+
if (ret[2]) {
|
|
1310
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1311
|
+
}
|
|
1312
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
/**
|
|
1316
|
+
* Yuen's test for trimmed means (robust alternative to t-test).
|
|
1317
|
+
*
|
|
1318
|
+
* @param x - First sample as Float64Array
|
|
1319
|
+
* @param y - Second sample as Float64Array
|
|
1320
|
+
* @param trim - Trim proportion (default: 0.2 for 20% trimming)
|
|
1321
|
+
* @param alternative - Alternative hypothesis direction
|
|
1322
|
+
* @param confLevel - Confidence level for CI (optional)
|
|
1323
|
+
* @returns Object with statistic, df, p_value, diff, trimmed_mean_x, trimmed_mean_y
|
|
1324
|
+
* @param {Float64Array} x
|
|
1325
|
+
* @param {Float64Array} y
|
|
1326
|
+
* @param {number | null | undefined} trim
|
|
1327
|
+
* @param {JsAlternative} alternative
|
|
1328
|
+
* @param {number | null} [conf_level]
|
|
1329
|
+
* @returns {any}
|
|
1330
|
+
*/
|
|
1331
|
+
export function yuenTest(x, y, trim, alternative, conf_level) {
|
|
1332
|
+
const ptr0 = passArrayF64ToWasm0(x, wasm.__wbindgen_malloc);
|
|
1333
|
+
const len0 = WASM_VECTOR_LEN;
|
|
1334
|
+
const ptr1 = passArrayF64ToWasm0(y, wasm.__wbindgen_malloc);
|
|
1335
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1336
|
+
const ret = wasm.yuenTest(ptr0, len0, ptr1, len1, !isLikeNone(trim), isLikeNone(trim) ? 0 : trim, alternative, !isLikeNone(conf_level), isLikeNone(conf_level) ? 0 : conf_level);
|
|
1337
|
+
if (ret[2]) {
|
|
1338
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
1339
|
+
}
|
|
1340
|
+
return takeFromExternrefTable0(ret[0]);
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
function __wbg_get_imports() {
|
|
1344
|
+
const import0 = {
|
|
1345
|
+
__proto__: null,
|
|
1346
|
+
__wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
|
|
1347
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
1348
|
+
return ret;
|
|
1349
|
+
},
|
|
1350
|
+
__wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
|
|
1351
|
+
const ret = String(arg1);
|
|
1352
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1353
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1354
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1355
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1356
|
+
},
|
|
1357
|
+
__wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
|
|
1358
|
+
const ret = typeof(arg0) === 'function';
|
|
1359
|
+
return ret;
|
|
1360
|
+
},
|
|
1361
|
+
__wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
|
|
1362
|
+
const val = arg0;
|
|
1363
|
+
const ret = typeof(val) === 'object' && val !== null;
|
|
1364
|
+
return ret;
|
|
1365
|
+
},
|
|
1366
|
+
__wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
|
|
1367
|
+
const ret = typeof(arg0) === 'string';
|
|
1368
|
+
return ret;
|
|
1369
|
+
},
|
|
1370
|
+
__wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
|
|
1371
|
+
const ret = arg0 === undefined;
|
|
1372
|
+
return ret;
|
|
1373
|
+
},
|
|
1374
|
+
__wbg___wbindgen_number_get_8ff4255516ccad3e: function(arg0, arg1) {
|
|
1375
|
+
const obj = arg1;
|
|
1376
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
1377
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
1378
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
1379
|
+
},
|
|
1380
|
+
__wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
|
|
1381
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
1382
|
+
},
|
|
1383
|
+
__wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
|
|
1384
|
+
const ret = arg0.call(arg1);
|
|
1385
|
+
return ret;
|
|
1386
|
+
}, arguments); },
|
|
1387
|
+
__wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1388
|
+
const ret = arg0.call(arg1, arg2);
|
|
1389
|
+
return ret;
|
|
1390
|
+
}, arguments); },
|
|
1391
|
+
__wbg_crypto_86f2631e91b51511: function(arg0) {
|
|
1392
|
+
const ret = arg0.crypto;
|
|
1393
|
+
return ret;
|
|
1394
|
+
},
|
|
1395
|
+
__wbg_from_bddd64e7d5ff6941: function(arg0) {
|
|
1396
|
+
const ret = Array.from(arg0);
|
|
1397
|
+
return ret;
|
|
1398
|
+
},
|
|
1399
|
+
__wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
|
|
1400
|
+
arg0.getRandomValues(arg1);
|
|
1401
|
+
}, arguments); },
|
|
1402
|
+
__wbg_get_9b94d73e6221f75c: function(arg0, arg1) {
|
|
1403
|
+
const ret = arg0[arg1 >>> 0];
|
|
1404
|
+
return ret;
|
|
1405
|
+
},
|
|
1406
|
+
__wbg_length_32ed9a279acd054c: function(arg0) {
|
|
1407
|
+
const ret = arg0.length;
|
|
1408
|
+
return ret;
|
|
1409
|
+
},
|
|
1410
|
+
__wbg_length_35a7bace40f36eac: function(arg0) {
|
|
1411
|
+
const ret = arg0.length;
|
|
1412
|
+
return ret;
|
|
1413
|
+
},
|
|
1414
|
+
__wbg_length_f7386240689107f3: function(arg0) {
|
|
1415
|
+
const ret = arg0.length;
|
|
1416
|
+
return ret;
|
|
1417
|
+
},
|
|
1418
|
+
__wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
|
|
1419
|
+
const ret = arg0.msCrypto;
|
|
1420
|
+
return ret;
|
|
1421
|
+
},
|
|
1422
|
+
__wbg_new_361308b2356cecd0: function() {
|
|
1423
|
+
const ret = new Object();
|
|
1424
|
+
return ret;
|
|
1425
|
+
},
|
|
1426
|
+
__wbg_new_3eb36ae241fe6f44: function() {
|
|
1427
|
+
const ret = new Array();
|
|
1428
|
+
return ret;
|
|
1429
|
+
},
|
|
1430
|
+
__wbg_new_d17d15ba1d2042a1: function(arg0) {
|
|
1431
|
+
const ret = new Float64Array(arg0);
|
|
1432
|
+
return ret;
|
|
1433
|
+
},
|
|
1434
|
+
__wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
|
|
1435
|
+
const ret = new Function(getStringFromWasm0(arg0, arg1));
|
|
1436
|
+
return ret;
|
|
1437
|
+
},
|
|
1438
|
+
__wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
|
|
1439
|
+
const ret = new Uint8Array(arg0 >>> 0);
|
|
1440
|
+
return ret;
|
|
1441
|
+
},
|
|
1442
|
+
__wbg_node_e1f24f89a7336c2e: function(arg0) {
|
|
1443
|
+
const ret = arg0.node;
|
|
1444
|
+
return ret;
|
|
1445
|
+
},
|
|
1446
|
+
__wbg_process_3975fd6c72f520aa: function(arg0) {
|
|
1447
|
+
const ret = arg0.process;
|
|
1448
|
+
return ret;
|
|
1449
|
+
},
|
|
1450
|
+
__wbg_prototypesetcall_aefe6319f589ab4b: function(arg0, arg1, arg2) {
|
|
1451
|
+
Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
|
|
1452
|
+
},
|
|
1453
|
+
__wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
|
|
1454
|
+
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1455
|
+
},
|
|
1456
|
+
__wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
|
|
1457
|
+
arg0.randomFillSync(arg1);
|
|
1458
|
+
}, arguments); },
|
|
1459
|
+
__wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
|
|
1460
|
+
const ret = module.require;
|
|
1461
|
+
return ret;
|
|
1462
|
+
}, arguments); },
|
|
1463
|
+
__wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
|
|
1464
|
+
arg0[arg1] = arg2;
|
|
1465
|
+
},
|
|
1466
|
+
__wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
|
|
1467
|
+
arg0[arg1 >>> 0] = arg2;
|
|
1468
|
+
},
|
|
1469
|
+
__wbg_static_accessor_GLOBAL_12837167ad935116: function() {
|
|
1470
|
+
const ret = typeof global === 'undefined' ? null : global;
|
|
1471
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1472
|
+
},
|
|
1473
|
+
__wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
|
|
1474
|
+
const ret = typeof globalThis === 'undefined' ? null : globalThis;
|
|
1475
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1476
|
+
},
|
|
1477
|
+
__wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
|
|
1478
|
+
const ret = typeof self === 'undefined' ? null : self;
|
|
1479
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1480
|
+
},
|
|
1481
|
+
__wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
|
|
1482
|
+
const ret = typeof window === 'undefined' ? null : window;
|
|
1483
|
+
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1484
|
+
},
|
|
1485
|
+
__wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
|
|
1486
|
+
const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
|
|
1487
|
+
return ret;
|
|
1488
|
+
},
|
|
1489
|
+
__wbg_versions_4e31226f5e8dc909: function(arg0) {
|
|
1490
|
+
const ret = arg0.versions;
|
|
1491
|
+
return ret;
|
|
1492
|
+
},
|
|
1493
|
+
__wbindgen_cast_0000000000000001: function(arg0) {
|
|
1494
|
+
// Cast intrinsic for `F64 -> Externref`.
|
|
1495
|
+
const ret = arg0;
|
|
1496
|
+
return ret;
|
|
1497
|
+
},
|
|
1498
|
+
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1499
|
+
// Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
|
|
1500
|
+
const ret = getArrayU8FromWasm0(arg0, arg1);
|
|
1501
|
+
return ret;
|
|
1502
|
+
},
|
|
1503
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1504
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1505
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
1506
|
+
return ret;
|
|
1507
|
+
},
|
|
1508
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
1509
|
+
// Cast intrinsic for `U64 -> Externref`.
|
|
1510
|
+
const ret = BigInt.asUintN(64, arg0);
|
|
1511
|
+
return ret;
|
|
1512
|
+
},
|
|
1513
|
+
__wbindgen_init_externref_table: function() {
|
|
1514
|
+
const table = wasm.__wbindgen_externrefs;
|
|
1515
|
+
const offset = table.grow(4);
|
|
1516
|
+
table.set(0, undefined);
|
|
1517
|
+
table.set(offset + 0, undefined);
|
|
1518
|
+
table.set(offset + 1, null);
|
|
1519
|
+
table.set(offset + 2, true);
|
|
1520
|
+
table.set(offset + 3, false);
|
|
1521
|
+
},
|
|
1522
|
+
};
|
|
1523
|
+
return {
|
|
1524
|
+
__proto__: null,
|
|
1525
|
+
"./anofox_statistics_js_bg.js": import0,
|
|
1526
|
+
};
|
|
1527
|
+
}
|
|
1528
|
+
|
|
1529
|
+
function addToExternrefTable0(obj) {
|
|
1530
|
+
const idx = wasm.__externref_table_alloc();
|
|
1531
|
+
wasm.__wbindgen_externrefs.set(idx, obj);
|
|
1532
|
+
return idx;
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
1536
|
+
ptr = ptr >>> 0;
|
|
1537
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1540
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
1541
|
+
ptr = ptr >>> 0;
|
|
1542
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
let cachedDataViewMemory0 = null;
|
|
1546
|
+
function getDataViewMemory0() {
|
|
1547
|
+
if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
|
|
1548
|
+
cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
|
|
1549
|
+
}
|
|
1550
|
+
return cachedDataViewMemory0;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1553
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
1554
|
+
function getFloat64ArrayMemory0() {
|
|
1555
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
1556
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
1557
|
+
}
|
|
1558
|
+
return cachedFloat64ArrayMemory0;
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1561
|
+
function getStringFromWasm0(ptr, len) {
|
|
1562
|
+
ptr = ptr >>> 0;
|
|
1563
|
+
return decodeText(ptr, len);
|
|
1564
|
+
}
|
|
1565
|
+
|
|
1566
|
+
let cachedUint8ArrayMemory0 = null;
|
|
1567
|
+
function getUint8ArrayMemory0() {
|
|
1568
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
1569
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
1570
|
+
}
|
|
1571
|
+
return cachedUint8ArrayMemory0;
|
|
1572
|
+
}
|
|
1573
|
+
|
|
1574
|
+
function handleError(f, args) {
|
|
1575
|
+
try {
|
|
1576
|
+
return f.apply(this, args);
|
|
1577
|
+
} catch (e) {
|
|
1578
|
+
const idx = addToExternrefTable0(e);
|
|
1579
|
+
wasm.__wbindgen_exn_store(idx);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
|
|
1583
|
+
function isLikeNone(x) {
|
|
1584
|
+
return x === undefined || x === null;
|
|
1585
|
+
}
|
|
1586
|
+
|
|
1587
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
1588
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
1589
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
1590
|
+
WASM_VECTOR_LEN = arg.length;
|
|
1591
|
+
return ptr;
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
1595
|
+
if (realloc === undefined) {
|
|
1596
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1597
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
1598
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
1599
|
+
WASM_VECTOR_LEN = buf.length;
|
|
1600
|
+
return ptr;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
let len = arg.length;
|
|
1604
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
1605
|
+
|
|
1606
|
+
const mem = getUint8ArrayMemory0();
|
|
1607
|
+
|
|
1608
|
+
let offset = 0;
|
|
1609
|
+
|
|
1610
|
+
for (; offset < len; offset++) {
|
|
1611
|
+
const code = arg.charCodeAt(offset);
|
|
1612
|
+
if (code > 0x7F) break;
|
|
1613
|
+
mem[ptr + offset] = code;
|
|
1614
|
+
}
|
|
1615
|
+
if (offset !== len) {
|
|
1616
|
+
if (offset !== 0) {
|
|
1617
|
+
arg = arg.slice(offset);
|
|
1618
|
+
}
|
|
1619
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
1620
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
1621
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
1622
|
+
|
|
1623
|
+
offset += ret.written;
|
|
1624
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
WASM_VECTOR_LEN = offset;
|
|
1628
|
+
return ptr;
|
|
1629
|
+
}
|
|
1630
|
+
|
|
1631
|
+
function takeFromExternrefTable0(idx) {
|
|
1632
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
1633
|
+
wasm.__externref_table_dealloc(idx);
|
|
1634
|
+
return value;
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1638
|
+
cachedTextDecoder.decode();
|
|
1639
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
1640
|
+
let numBytesDecoded = 0;
|
|
1641
|
+
function decodeText(ptr, len) {
|
|
1642
|
+
numBytesDecoded += len;
|
|
1643
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
1644
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
1645
|
+
cachedTextDecoder.decode();
|
|
1646
|
+
numBytesDecoded = len;
|
|
1647
|
+
}
|
|
1648
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
const cachedTextEncoder = new TextEncoder();
|
|
1652
|
+
|
|
1653
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
1654
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
1655
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
1656
|
+
view.set(buf);
|
|
1657
|
+
return {
|
|
1658
|
+
read: arg.length,
|
|
1659
|
+
written: buf.length
|
|
1660
|
+
};
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
let WASM_VECTOR_LEN = 0;
|
|
1665
|
+
|
|
1666
|
+
let wasmModule, wasm;
|
|
1667
|
+
function __wbg_finalize_init(instance, module) {
|
|
1668
|
+
wasm = instance.exports;
|
|
1669
|
+
wasmModule = module;
|
|
1670
|
+
cachedDataViewMemory0 = null;
|
|
1671
|
+
cachedFloat64ArrayMemory0 = null;
|
|
1672
|
+
cachedUint8ArrayMemory0 = null;
|
|
1673
|
+
wasm.__wbindgen_start();
|
|
1674
|
+
return wasm;
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
async function __wbg_load(module, imports) {
|
|
1678
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
1679
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
1680
|
+
try {
|
|
1681
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
1682
|
+
} catch (e) {
|
|
1683
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
1684
|
+
|
|
1685
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
1686
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
1687
|
+
|
|
1688
|
+
} else { throw e; }
|
|
1689
|
+
}
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
const bytes = await module.arrayBuffer();
|
|
1693
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
1694
|
+
} else {
|
|
1695
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
1696
|
+
|
|
1697
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
1698
|
+
return { instance, module };
|
|
1699
|
+
} else {
|
|
1700
|
+
return instance;
|
|
1701
|
+
}
|
|
1702
|
+
}
|
|
1703
|
+
|
|
1704
|
+
function expectedResponseType(type) {
|
|
1705
|
+
switch (type) {
|
|
1706
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
1707
|
+
}
|
|
1708
|
+
return false;
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
|
|
1712
|
+
function initSync(module) {
|
|
1713
|
+
if (wasm !== undefined) return wasm;
|
|
1714
|
+
|
|
1715
|
+
|
|
1716
|
+
if (module !== undefined) {
|
|
1717
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
1718
|
+
({module} = module)
|
|
1719
|
+
} else {
|
|
1720
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
const imports = __wbg_get_imports();
|
|
1725
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
1726
|
+
module = new WebAssembly.Module(module);
|
|
1727
|
+
}
|
|
1728
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
1729
|
+
return __wbg_finalize_init(instance, module);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
async function __wbg_init(module_or_path) {
|
|
1733
|
+
if (wasm !== undefined) return wasm;
|
|
1734
|
+
|
|
1735
|
+
|
|
1736
|
+
if (module_or_path !== undefined) {
|
|
1737
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
1738
|
+
({module_or_path} = module_or_path)
|
|
1739
|
+
} else {
|
|
1740
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
1741
|
+
}
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
if (module_or_path === undefined) {
|
|
1745
|
+
module_or_path = new URL('anofox_statistics_js_bg.wasm', import.meta.url);
|
|
1746
|
+
}
|
|
1747
|
+
const imports = __wbg_get_imports();
|
|
1748
|
+
|
|
1749
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
1750
|
+
module_or_path = fetch(module_or_path);
|
|
1751
|
+
}
|
|
1752
|
+
|
|
1753
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
1754
|
+
|
|
1755
|
+
return __wbg_finalize_init(instance, module);
|
|
1756
|
+
}
|
|
1757
|
+
|
|
1758
|
+
export { initSync, __wbg_init as default };
|