@iyulab/u-numflow 0.7.0 → 0.8.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/README.md +17 -8
- package/node/u_numflow.cjs +95 -39
- package/node/u_numflow.d.cts +17 -9
- package/node/u_numflow_bg.wasm +0 -0
- package/package.json +1 -1
- package/u_numflow.d.ts +17 -9
- package/u_numflow_bg.js +95 -39
- package/u_numflow_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ u-numflow provides foundational mathematical, statistical, and probabilistic bui
|
|
|
34
34
|
|
|
35
35
|
```toml
|
|
36
36
|
[dependencies]
|
|
37
|
-
u-numflow = "0.
|
|
37
|
+
u-numflow = "0.8"
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
```rust
|
|
@@ -112,6 +112,12 @@ Exported functions: `mean`, `std_dev`, `variance`, `normal_cdf`, `normal_sf` (up
|
|
|
112
112
|
`rfft(data) -> Float64Array` — the DFT of a real sequence of any length, interleaved as
|
|
113
113
|
`[re0, im0, re1, im1, …]` (bins `k` and `n − k` are conjugates, so `0..=n/2` describes the spectrum).
|
|
114
114
|
|
|
115
|
+
Every `data` argument is a `number[]` or a `Float64Array`, read exactly as sent: an
|
|
116
|
+
element that is not a number (`null`, `undefined`, a string) throws `malformed_input`
|
|
117
|
+
and a NaN or ±Infinity throws `value_not_finite`, each with the element's `index` —
|
|
118
|
+
`mean([1, null, 3])` throws rather than averaging the `null` as 0. `mean` of no values
|
|
119
|
+
throws `empty_input`; `std_dev` and `variance` of fewer than 2 throw `insufficient_data`.
|
|
120
|
+
|
|
115
121
|
Distribution functions for critical values and p-values — each returns a `number` and
|
|
116
122
|
**throws** (an `Error` naming the argument — see *Errors* below) when an argument is outside the domain,
|
|
117
123
|
rather than returning `NaN`:
|
|
@@ -146,9 +152,11 @@ try {
|
|
|
146
152
|
| `code` | Fields | Meaning |
|
|
147
153
|
|---|---|---|
|
|
148
154
|
| `parameter_out_of_range` | `parameter`, `min`, `max` (or `null`), `got` | `p` not strictly inside (0, 1), or a degrees of freedom that is not a finite number `> 0` (both bounds excluded) |
|
|
149
|
-
| `
|
|
155
|
+
| `malformed_input` | `parameter`, `index` (or absent) | A `data` argument that is not an array or `Float64Array`, or an element that is not a number |
|
|
156
|
+
| `value_not_finite` | `parameter`, `index` for an array element | A NaN argument, or a NaN or infinity in any `data` array |
|
|
157
|
+
| `empty_input` | `parameter` | `mean` of no values |
|
|
150
158
|
| `non_positive_data` | — | Box-Cox data with a value `≤ 0` |
|
|
151
|
-
| `insufficient_data` | —
|
|
159
|
+
| `insufficient_data` | `parameter`, `min`, `got` for `std_dev`/`variance`; — for Box-Cox | Fewer values than the function needs (`std_dev`/`variance` 2, Box-Cox 2) |
|
|
152
160
|
| `invalid_transform` | — | A Box-Cox result that is not finite |
|
|
153
161
|
| `invalid_lambda_range` | — | `estimate_lambda` bounds that are not finite with `lambda_min < lambda_max` |
|
|
154
162
|
|
|
@@ -159,17 +167,18 @@ declarations are generated from the same structs the binding reads and
|
|
|
159
167
|
serialises, so they cannot drift from what it actually accepts and returns:
|
|
160
168
|
|
|
161
169
|
```ts
|
|
162
|
-
export function
|
|
170
|
+
export function mean(data: number[] | Float64Array): number;
|
|
171
|
+
export function estimate_lambda(data: number[] | Float64Array, lambda_min: number, lambda_max: number): LambdaEstimateDto;
|
|
163
172
|
```
|
|
164
173
|
|
|
165
174
|
An absent optional value is declared `T | undefined`, which is what the binding
|
|
166
175
|
sends. Nothing needs an `as` cast -- and a wrong assumption about a result's
|
|
167
176
|
shape is a compile error rather than something that fails at run time.
|
|
168
177
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
178
|
+
A `data` parameter is declared `number[] | Float64Array` and read by the
|
|
179
|
+
binding itself rather than copied into a typed array by the generated glue, so
|
|
180
|
+
a value the declaration does not allow is refused where it sits instead of
|
|
181
|
+
being converted. The publishing workflow keeps every declaration free of `any`.
|
|
173
182
|
|
|
174
183
|
## Related
|
|
175
184
|
|
package/node/u_numflow.cjs
CHANGED
|
@@ -9,20 +9,18 @@
|
|
|
9
9
|
* Throws `non_positive_data`, `value_not_finite` or `insufficient_data` when
|
|
10
10
|
* data contains a value ≤ 0, a NaN or infinity, or fewer than 2 elements, and
|
|
11
11
|
* `invalid_transform` when a result is not finite.
|
|
12
|
-
* @param {Float64Array} data
|
|
12
|
+
* @param {number[] | Float64Array} data
|
|
13
13
|
* @param {number} lambda
|
|
14
14
|
* @returns {Float64Array}
|
|
15
15
|
*/
|
|
16
16
|
function box_cox(data, lambda) {
|
|
17
|
-
const
|
|
18
|
-
const len0 = WASM_VECTOR_LEN;
|
|
19
|
-
const ret = wasm.box_cox(ptr0, len0, lambda);
|
|
17
|
+
const ret = wasm.box_cox(data, lambda);
|
|
20
18
|
if (ret[3]) {
|
|
21
19
|
throw takeFromExternrefTable0(ret[2]);
|
|
22
20
|
}
|
|
23
|
-
var
|
|
21
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
24
22
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
25
|
-
return
|
|
23
|
+
return v1;
|
|
26
24
|
}
|
|
27
25
|
exports.box_cox = box_cox;
|
|
28
26
|
|
|
@@ -75,15 +73,13 @@ exports.chi_squared_quantile = chi_squared_quantile;
|
|
|
75
73
|
* # Errors
|
|
76
74
|
* Throws as [`box_cox`] does for the data, and `invalid_lambda_range` when the
|
|
77
75
|
* range is not finite with `lambda_min < lambda_max`.
|
|
78
|
-
* @param {Float64Array} data
|
|
76
|
+
* @param {number[] | Float64Array} data
|
|
79
77
|
* @param {number} lambda_min
|
|
80
78
|
* @param {number} lambda_max
|
|
81
79
|
* @returns {LambdaEstimateDto}
|
|
82
80
|
*/
|
|
83
81
|
function estimate_lambda(data, lambda_min, lambda_max) {
|
|
84
|
-
const
|
|
85
|
-
const len0 = WASM_VECTOR_LEN;
|
|
86
|
-
const ret = wasm.estimate_lambda(ptr0, len0, lambda_min, lambda_max);
|
|
82
|
+
const ret = wasm.estimate_lambda(data, lambda_min, lambda_max);
|
|
87
83
|
if (ret[2]) {
|
|
88
84
|
throw takeFromExternrefTable0(ret[1]);
|
|
89
85
|
}
|
|
@@ -150,15 +146,18 @@ exports.inverse_normal_cdf = inverse_normal_cdf;
|
|
|
150
146
|
/**
|
|
151
147
|
* Arithmetic mean of `data` using Kahan compensated summation.
|
|
152
148
|
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
149
|
+
* # Errors
|
|
150
|
+
* Throws `empty_input` when `data` is empty, and as every `data` argument
|
|
151
|
+
* does for an element that is not a finite number.
|
|
152
|
+
* @param {number[] | Float64Array} data
|
|
155
153
|
* @returns {number}
|
|
156
154
|
*/
|
|
157
155
|
function mean(data) {
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
156
|
+
const ret = wasm.mean(data);
|
|
157
|
+
if (ret[2]) {
|
|
158
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
159
|
+
}
|
|
160
|
+
return ret[0];
|
|
162
161
|
}
|
|
163
162
|
exports.mean = mean;
|
|
164
163
|
|
|
@@ -199,31 +198,38 @@ exports.normal_sf = normal_sf;
|
|
|
199
198
|
* Returns the `n` complex bins interleaved as `[re0, im0, re1, im1, …]`
|
|
200
199
|
* (length `2n`). Bins `k` and `n − k` are conjugates, so the spectrum of a
|
|
201
200
|
* real signal is fully described by bins `0..=n/2`.
|
|
202
|
-
*
|
|
201
|
+
*
|
|
202
|
+
* # Errors
|
|
203
|
+
* Throws as every `data` argument does for an element that is not a finite
|
|
204
|
+
* number.
|
|
205
|
+
* @param {number[] | Float64Array} data
|
|
203
206
|
* @returns {Float64Array}
|
|
204
207
|
*/
|
|
205
208
|
function rfft(data) {
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
209
|
+
const ret = wasm.rfft(data);
|
|
210
|
+
if (ret[3]) {
|
|
211
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
212
|
+
}
|
|
213
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
210
214
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
211
|
-
return
|
|
215
|
+
return v1;
|
|
212
216
|
}
|
|
213
217
|
exports.rfft = rfft;
|
|
214
218
|
|
|
215
219
|
/**
|
|
216
220
|
* Sample standard deviation of `data` (Bessel-corrected, denominator n−1).
|
|
217
221
|
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
222
|
+
* # Errors
|
|
223
|
+
* Throws `insufficient_data` below 2 values.
|
|
224
|
+
* @param {number[] | Float64Array} data
|
|
220
225
|
* @returns {number}
|
|
221
226
|
*/
|
|
222
227
|
function std_dev(data) {
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
228
|
+
const ret = wasm.std_dev(data);
|
|
229
|
+
if (ret[2]) {
|
|
230
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
231
|
+
}
|
|
232
|
+
return ret[0];
|
|
227
233
|
}
|
|
228
234
|
exports.std_dev = std_dev;
|
|
229
235
|
|
|
@@ -268,15 +274,17 @@ exports.t_distribution_quantile = t_distribution_quantile;
|
|
|
268
274
|
/**
|
|
269
275
|
* Sample variance of `data` (Bessel-corrected, denominator n−1).
|
|
270
276
|
*
|
|
271
|
-
*
|
|
272
|
-
*
|
|
277
|
+
* # Errors
|
|
278
|
+
* Throws `insufficient_data` below 2 values.
|
|
279
|
+
* @param {number[] | Float64Array} data
|
|
273
280
|
* @returns {number}
|
|
274
281
|
*/
|
|
275
282
|
function variance(data) {
|
|
276
|
-
const
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
283
|
+
const ret = wasm.variance(data);
|
|
284
|
+
if (ret[2]) {
|
|
285
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
286
|
+
}
|
|
287
|
+
return ret[0];
|
|
280
288
|
}
|
|
281
289
|
exports.variance = variance;
|
|
282
290
|
function __wbg_get_imports() {
|
|
@@ -289,9 +297,57 @@ function __wbg_get_imports() {
|
|
|
289
297
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
290
298
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
291
299
|
},
|
|
300
|
+
__wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
|
|
301
|
+
const ret = arg0 === null;
|
|
302
|
+
return ret;
|
|
303
|
+
},
|
|
304
|
+
__wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
|
|
305
|
+
const obj = arg1;
|
|
306
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
307
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
308
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
309
|
+
},
|
|
310
|
+
__wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
|
|
311
|
+
const obj = arg1;
|
|
312
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
313
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
314
|
+
var len1 = WASM_VECTOR_LEN;
|
|
315
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
316
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
317
|
+
},
|
|
292
318
|
__wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
|
|
293
319
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
294
320
|
},
|
|
321
|
+
__wbg___wbindgen_typeof_e777a26e115d416b: function(arg0) {
|
|
322
|
+
const ret = typeof arg0;
|
|
323
|
+
return ret;
|
|
324
|
+
},
|
|
325
|
+
__wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
|
|
326
|
+
const ret = arg0[arg1 >>> 0];
|
|
327
|
+
return ret;
|
|
328
|
+
},
|
|
329
|
+
__wbg_instanceof_Float64Array_8a59377f9eec1b8b: function(arg0) {
|
|
330
|
+
let result;
|
|
331
|
+
try {
|
|
332
|
+
result = arg0 instanceof Float64Array;
|
|
333
|
+
} catch (_) {
|
|
334
|
+
result = false;
|
|
335
|
+
}
|
|
336
|
+
const ret = result;
|
|
337
|
+
return ret;
|
|
338
|
+
},
|
|
339
|
+
__wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
|
|
340
|
+
const ret = Array.isArray(arg0);
|
|
341
|
+
return ret;
|
|
342
|
+
},
|
|
343
|
+
__wbg_length_b5f0008bbf60cf59: function(arg0) {
|
|
344
|
+
const ret = arg0.length;
|
|
345
|
+
return ret;
|
|
346
|
+
},
|
|
347
|
+
__wbg_length_d4bdea10311bd9cf: function(arg0) {
|
|
348
|
+
const ret = arg0.length;
|
|
349
|
+
return ret;
|
|
350
|
+
},
|
|
295
351
|
__wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
|
|
296
352
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
297
353
|
return ret;
|
|
@@ -300,6 +356,9 @@ function __wbg_get_imports() {
|
|
|
300
356
|
const ret = new Object();
|
|
301
357
|
return ret;
|
|
302
358
|
},
|
|
359
|
+
__wbg_prototypesetcall_d49a4fab5ca427bc: function(arg0, arg1, arg2) {
|
|
360
|
+
Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
|
|
361
|
+
},
|
|
303
362
|
__wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
|
|
304
363
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
305
364
|
return ret;
|
|
@@ -381,11 +440,8 @@ function handleError(f, args) {
|
|
|
381
440
|
}
|
|
382
441
|
}
|
|
383
442
|
|
|
384
|
-
function
|
|
385
|
-
|
|
386
|
-
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
387
|
-
WASM_VECTOR_LEN = arg.length;
|
|
388
|
-
return ptr;
|
|
443
|
+
function isLikeNone(x) {
|
|
444
|
+
return x === undefined || x === null;
|
|
389
445
|
}
|
|
390
446
|
|
|
391
447
|
function passStringToWasm0(arg, malloc, realloc) {
|
package/node/u_numflow.d.cts
CHANGED
|
@@ -19,7 +19,7 @@ export interface LambdaEstimateDto {
|
|
|
19
19
|
* data contains a value ≤ 0, a NaN or infinity, or fewer than 2 elements, and
|
|
20
20
|
* `invalid_transform` when a result is not finite.
|
|
21
21
|
*/
|
|
22
|
-
export function box_cox(data: Float64Array, lambda: number): Float64Array;
|
|
22
|
+
export function box_cox(data: number[] | Float64Array, lambda: number): Float64Array;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Chi-squared CDF: `P(X ≤ x)` for `X ~ χ²(k)` (`0` for `x ≤ 0`).
|
|
@@ -51,7 +51,7 @@ export function chi_squared_quantile(p: number, k: number): number;
|
|
|
51
51
|
* Throws as [`box_cox`] does for the data, and `invalid_lambda_range` when the
|
|
52
52
|
* range is not finite with `lambda_min < lambda_max`.
|
|
53
53
|
*/
|
|
54
|
-
export function estimate_lambda(data: Float64Array, lambda_min: number, lambda_max: number): LambdaEstimateDto;
|
|
54
|
+
export function estimate_lambda(data: number[] | Float64Array, lambda_min: number, lambda_max: number): LambdaEstimateDto;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* F CDF: `P(X ≤ x)` for `X ~ F(df1, df2)` (`0` for `x ≤ 0`).
|
|
@@ -81,9 +81,11 @@ export function inverse_normal_cdf(p: number): number;
|
|
|
81
81
|
/**
|
|
82
82
|
* Arithmetic mean of `data` using Kahan compensated summation.
|
|
83
83
|
*
|
|
84
|
-
*
|
|
84
|
+
* # Errors
|
|
85
|
+
* Throws `empty_input` when `data` is empty, and as every `data` argument
|
|
86
|
+
* does for an element that is not a finite number.
|
|
85
87
|
*/
|
|
86
|
-
export function mean(data: Float64Array): number;
|
|
88
|
+
export function mean(data: number[] | Float64Array): number;
|
|
87
89
|
|
|
88
90
|
/**
|
|
89
91
|
* Standard normal CDF Φ(x) = P(Z ≤ x) for Z ~ N(0, 1).
|
|
@@ -110,15 +112,20 @@ export function normal_sf(x: number): number;
|
|
|
110
112
|
* Returns the `n` complex bins interleaved as `[re0, im0, re1, im1, …]`
|
|
111
113
|
* (length `2n`). Bins `k` and `n − k` are conjugates, so the spectrum of a
|
|
112
114
|
* real signal is fully described by bins `0..=n/2`.
|
|
115
|
+
*
|
|
116
|
+
* # Errors
|
|
117
|
+
* Throws as every `data` argument does for an element that is not a finite
|
|
118
|
+
* number.
|
|
113
119
|
*/
|
|
114
|
-
export function rfft(data: Float64Array): Float64Array;
|
|
120
|
+
export function rfft(data: number[] | Float64Array): Float64Array;
|
|
115
121
|
|
|
116
122
|
/**
|
|
117
123
|
* Sample standard deviation of `data` (Bessel-corrected, denominator n−1).
|
|
118
124
|
*
|
|
119
|
-
*
|
|
125
|
+
* # Errors
|
|
126
|
+
* Throws `insufficient_data` below 2 values.
|
|
120
127
|
*/
|
|
121
|
-
export function std_dev(data: Float64Array): number;
|
|
128
|
+
export function std_dev(data: number[] | Float64Array): number;
|
|
122
129
|
|
|
123
130
|
/**
|
|
124
131
|
* Student's t CDF: `P(T ≤ t)` for `T ~ t(df)`. `df` may be fractional.
|
|
@@ -141,6 +148,7 @@ export function t_distribution_quantile(p: number, df: number): number;
|
|
|
141
148
|
/**
|
|
142
149
|
* Sample variance of `data` (Bessel-corrected, denominator n−1).
|
|
143
150
|
*
|
|
144
|
-
*
|
|
151
|
+
* # Errors
|
|
152
|
+
* Throws `insufficient_data` below 2 values.
|
|
145
153
|
*/
|
|
146
|
-
export function variance(data: Float64Array): number;
|
|
154
|
+
export function variance(data: number[] | Float64Array): number;
|
package/node/u_numflow_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
package/u_numflow.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface LambdaEstimateDto {
|
|
|
19
19
|
* data contains a value ≤ 0, a NaN or infinity, or fewer than 2 elements, and
|
|
20
20
|
* `invalid_transform` when a result is not finite.
|
|
21
21
|
*/
|
|
22
|
-
export function box_cox(data: Float64Array, lambda: number): Float64Array;
|
|
22
|
+
export function box_cox(data: number[] | Float64Array, lambda: number): Float64Array;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Chi-squared CDF: `P(X ≤ x)` for `X ~ χ²(k)` (`0` for `x ≤ 0`).
|
|
@@ -51,7 +51,7 @@ export function chi_squared_quantile(p: number, k: number): number;
|
|
|
51
51
|
* Throws as [`box_cox`] does for the data, and `invalid_lambda_range` when the
|
|
52
52
|
* range is not finite with `lambda_min < lambda_max`.
|
|
53
53
|
*/
|
|
54
|
-
export function estimate_lambda(data: Float64Array, lambda_min: number, lambda_max: number): LambdaEstimateDto;
|
|
54
|
+
export function estimate_lambda(data: number[] | Float64Array, lambda_min: number, lambda_max: number): LambdaEstimateDto;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* F CDF: `P(X ≤ x)` for `X ~ F(df1, df2)` (`0` for `x ≤ 0`).
|
|
@@ -81,9 +81,11 @@ export function inverse_normal_cdf(p: number): number;
|
|
|
81
81
|
/**
|
|
82
82
|
* Arithmetic mean of `data` using Kahan compensated summation.
|
|
83
83
|
*
|
|
84
|
-
*
|
|
84
|
+
* # Errors
|
|
85
|
+
* Throws `empty_input` when `data` is empty, and as every `data` argument
|
|
86
|
+
* does for an element that is not a finite number.
|
|
85
87
|
*/
|
|
86
|
-
export function mean(data: Float64Array): number;
|
|
88
|
+
export function mean(data: number[] | Float64Array): number;
|
|
87
89
|
|
|
88
90
|
/**
|
|
89
91
|
* Standard normal CDF Φ(x) = P(Z ≤ x) for Z ~ N(0, 1).
|
|
@@ -110,15 +112,20 @@ export function normal_sf(x: number): number;
|
|
|
110
112
|
* Returns the `n` complex bins interleaved as `[re0, im0, re1, im1, …]`
|
|
111
113
|
* (length `2n`). Bins `k` and `n − k` are conjugates, so the spectrum of a
|
|
112
114
|
* real signal is fully described by bins `0..=n/2`.
|
|
115
|
+
*
|
|
116
|
+
* # Errors
|
|
117
|
+
* Throws as every `data` argument does for an element that is not a finite
|
|
118
|
+
* number.
|
|
113
119
|
*/
|
|
114
|
-
export function rfft(data: Float64Array): Float64Array;
|
|
120
|
+
export function rfft(data: number[] | Float64Array): Float64Array;
|
|
115
121
|
|
|
116
122
|
/**
|
|
117
123
|
* Sample standard deviation of `data` (Bessel-corrected, denominator n−1).
|
|
118
124
|
*
|
|
119
|
-
*
|
|
125
|
+
* # Errors
|
|
126
|
+
* Throws `insufficient_data` below 2 values.
|
|
120
127
|
*/
|
|
121
|
-
export function std_dev(data: Float64Array): number;
|
|
128
|
+
export function std_dev(data: number[] | Float64Array): number;
|
|
122
129
|
|
|
123
130
|
/**
|
|
124
131
|
* Student's t CDF: `P(T ≤ t)` for `T ~ t(df)`. `df` may be fractional.
|
|
@@ -141,6 +148,7 @@ export function t_distribution_quantile(p: number, df: number): number;
|
|
|
141
148
|
/**
|
|
142
149
|
* Sample variance of `data` (Bessel-corrected, denominator n−1).
|
|
143
150
|
*
|
|
144
|
-
*
|
|
151
|
+
* # Errors
|
|
152
|
+
* Throws `insufficient_data` below 2 values.
|
|
145
153
|
*/
|
|
146
|
-
export function variance(data: Float64Array): number;
|
|
154
|
+
export function variance(data: number[] | Float64Array): number;
|
package/u_numflow_bg.js
CHANGED
|
@@ -7,20 +7,18 @@
|
|
|
7
7
|
* Throws `non_positive_data`, `value_not_finite` or `insufficient_data` when
|
|
8
8
|
* data contains a value ≤ 0, a NaN or infinity, or fewer than 2 elements, and
|
|
9
9
|
* `invalid_transform` when a result is not finite.
|
|
10
|
-
* @param {Float64Array} data
|
|
10
|
+
* @param {number[] | Float64Array} data
|
|
11
11
|
* @param {number} lambda
|
|
12
12
|
* @returns {Float64Array}
|
|
13
13
|
*/
|
|
14
14
|
export function box_cox(data, lambda) {
|
|
15
|
-
const
|
|
16
|
-
const len0 = WASM_VECTOR_LEN;
|
|
17
|
-
const ret = wasm.box_cox(ptr0, len0, lambda);
|
|
15
|
+
const ret = wasm.box_cox(data, lambda);
|
|
18
16
|
if (ret[3]) {
|
|
19
17
|
throw takeFromExternrefTable0(ret[2]);
|
|
20
18
|
}
|
|
21
|
-
var
|
|
19
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
22
20
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
23
|
-
return
|
|
21
|
+
return v1;
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
/**
|
|
@@ -70,15 +68,13 @@ export function chi_squared_quantile(p, k) {
|
|
|
70
68
|
* # Errors
|
|
71
69
|
* Throws as [`box_cox`] does for the data, and `invalid_lambda_range` when the
|
|
72
70
|
* range is not finite with `lambda_min < lambda_max`.
|
|
73
|
-
* @param {Float64Array} data
|
|
71
|
+
* @param {number[] | Float64Array} data
|
|
74
72
|
* @param {number} lambda_min
|
|
75
73
|
* @param {number} lambda_max
|
|
76
74
|
* @returns {LambdaEstimateDto}
|
|
77
75
|
*/
|
|
78
76
|
export function estimate_lambda(data, lambda_min, lambda_max) {
|
|
79
|
-
const
|
|
80
|
-
const len0 = WASM_VECTOR_LEN;
|
|
81
|
-
const ret = wasm.estimate_lambda(ptr0, len0, lambda_min, lambda_max);
|
|
77
|
+
const ret = wasm.estimate_lambda(data, lambda_min, lambda_max);
|
|
82
78
|
if (ret[2]) {
|
|
83
79
|
throw takeFromExternrefTable0(ret[1]);
|
|
84
80
|
}
|
|
@@ -141,15 +137,18 @@ export function inverse_normal_cdf(p) {
|
|
|
141
137
|
/**
|
|
142
138
|
* Arithmetic mean of `data` using Kahan compensated summation.
|
|
143
139
|
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
140
|
+
* # Errors
|
|
141
|
+
* Throws `empty_input` when `data` is empty, and as every `data` argument
|
|
142
|
+
* does for an element that is not a finite number.
|
|
143
|
+
* @param {number[] | Float64Array} data
|
|
146
144
|
* @returns {number}
|
|
147
145
|
*/
|
|
148
146
|
export function mean(data) {
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
const ret = wasm.mean(data);
|
|
148
|
+
if (ret[2]) {
|
|
149
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
150
|
+
}
|
|
151
|
+
return ret[0];
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
/**
|
|
@@ -187,30 +186,37 @@ export function normal_sf(x) {
|
|
|
187
186
|
* Returns the `n` complex bins interleaved as `[re0, im0, re1, im1, …]`
|
|
188
187
|
* (length `2n`). Bins `k` and `n − k` are conjugates, so the spectrum of a
|
|
189
188
|
* real signal is fully described by bins `0..=n/2`.
|
|
190
|
-
*
|
|
189
|
+
*
|
|
190
|
+
* # Errors
|
|
191
|
+
* Throws as every `data` argument does for an element that is not a finite
|
|
192
|
+
* number.
|
|
193
|
+
* @param {number[] | Float64Array} data
|
|
191
194
|
* @returns {Float64Array}
|
|
192
195
|
*/
|
|
193
196
|
export function rfft(data) {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
197
|
+
const ret = wasm.rfft(data);
|
|
198
|
+
if (ret[3]) {
|
|
199
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
200
|
+
}
|
|
201
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
198
202
|
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
199
|
-
return
|
|
203
|
+
return v1;
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
/**
|
|
203
207
|
* Sample standard deviation of `data` (Bessel-corrected, denominator n−1).
|
|
204
208
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
209
|
+
* # Errors
|
|
210
|
+
* Throws `insufficient_data` below 2 values.
|
|
211
|
+
* @param {number[] | Float64Array} data
|
|
207
212
|
* @returns {number}
|
|
208
213
|
*/
|
|
209
214
|
export function std_dev(data) {
|
|
210
|
-
const
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
const ret = wasm.std_dev(data);
|
|
216
|
+
if (ret[2]) {
|
|
217
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
218
|
+
}
|
|
219
|
+
return ret[0];
|
|
214
220
|
}
|
|
215
221
|
|
|
216
222
|
/**
|
|
@@ -252,15 +258,17 @@ export function t_distribution_quantile(p, df) {
|
|
|
252
258
|
/**
|
|
253
259
|
* Sample variance of `data` (Bessel-corrected, denominator n−1).
|
|
254
260
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
261
|
+
* # Errors
|
|
262
|
+
* Throws `insufficient_data` below 2 values.
|
|
263
|
+
* @param {number[] | Float64Array} data
|
|
257
264
|
* @returns {number}
|
|
258
265
|
*/
|
|
259
266
|
export function variance(data) {
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
267
|
+
const ret = wasm.variance(data);
|
|
268
|
+
if (ret[2]) {
|
|
269
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
270
|
+
}
|
|
271
|
+
return ret[0];
|
|
264
272
|
}
|
|
265
273
|
export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
266
274
|
const ret = String(arg1);
|
|
@@ -269,9 +277,57 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
|
|
|
269
277
|
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
270
278
|
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
271
279
|
}
|
|
280
|
+
export function __wbg___wbindgen_is_null_e343b7d08827ba72(arg0) {
|
|
281
|
+
const ret = arg0 === null;
|
|
282
|
+
return ret;
|
|
283
|
+
}
|
|
284
|
+
export function __wbg___wbindgen_number_get_2e0e7dee9f701a71(arg0, arg1) {
|
|
285
|
+
const obj = arg1;
|
|
286
|
+
const ret = typeof(obj) === 'number' ? obj : undefined;
|
|
287
|
+
getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
|
|
288
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
|
|
289
|
+
}
|
|
290
|
+
export function __wbg___wbindgen_string_get_0380ccaa2f57f0d9(arg0, arg1) {
|
|
291
|
+
const obj = arg1;
|
|
292
|
+
const ret = typeof(obj) === 'string' ? obj : undefined;
|
|
293
|
+
var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
294
|
+
var len1 = WASM_VECTOR_LEN;
|
|
295
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
296
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
297
|
+
}
|
|
272
298
|
export function __wbg___wbindgen_throw_41e9ee4f547fc59a(arg0, arg1) {
|
|
273
299
|
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
274
300
|
}
|
|
301
|
+
export function __wbg___wbindgen_typeof_e777a26e115d416b(arg0) {
|
|
302
|
+
const ret = typeof arg0;
|
|
303
|
+
return ret;
|
|
304
|
+
}
|
|
305
|
+
export function __wbg_get_unchecked_288889d017702237(arg0, arg1) {
|
|
306
|
+
const ret = arg0[arg1 >>> 0];
|
|
307
|
+
return ret;
|
|
308
|
+
}
|
|
309
|
+
export function __wbg_instanceof_Float64Array_8a59377f9eec1b8b(arg0) {
|
|
310
|
+
let result;
|
|
311
|
+
try {
|
|
312
|
+
result = arg0 instanceof Float64Array;
|
|
313
|
+
} catch (_) {
|
|
314
|
+
result = false;
|
|
315
|
+
}
|
|
316
|
+
const ret = result;
|
|
317
|
+
return ret;
|
|
318
|
+
}
|
|
319
|
+
export function __wbg_isArray_e15a2ff68ffdbef2(arg0) {
|
|
320
|
+
const ret = Array.isArray(arg0);
|
|
321
|
+
return ret;
|
|
322
|
+
}
|
|
323
|
+
export function __wbg_length_b5f0008bbf60cf59(arg0) {
|
|
324
|
+
const ret = arg0.length;
|
|
325
|
+
return ret;
|
|
326
|
+
}
|
|
327
|
+
export function __wbg_length_d4bdea10311bd9cf(arg0) {
|
|
328
|
+
const ret = arg0.length;
|
|
329
|
+
return ret;
|
|
330
|
+
}
|
|
275
331
|
export function __wbg_new_343a093a3c2ffb4e(arg0, arg1) {
|
|
276
332
|
const ret = new Error(getStringFromWasm0(arg0, arg1));
|
|
277
333
|
return ret;
|
|
@@ -280,6 +336,9 @@ export function __wbg_new_617a8cdb8bb1130e() {
|
|
|
280
336
|
const ret = new Object();
|
|
281
337
|
return ret;
|
|
282
338
|
}
|
|
339
|
+
export function __wbg_prototypesetcall_d49a4fab5ca427bc(arg0, arg1, arg2) {
|
|
340
|
+
Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
|
|
341
|
+
}
|
|
283
342
|
export function __wbg_set_145a351398b48c65() { return handleError(function (arg0, arg1, arg2) {
|
|
284
343
|
const ret = Reflect.set(arg0, arg1, arg2);
|
|
285
344
|
return ret;
|
|
@@ -354,11 +413,8 @@ function handleError(f, args) {
|
|
|
354
413
|
}
|
|
355
414
|
}
|
|
356
415
|
|
|
357
|
-
function
|
|
358
|
-
|
|
359
|
-
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
360
|
-
WASM_VECTOR_LEN = arg.length;
|
|
361
|
-
return ptr;
|
|
416
|
+
function isLikeNone(x) {
|
|
417
|
+
return x === undefined || x === null;
|
|
362
418
|
}
|
|
363
419
|
|
|
364
420
|
function passStringToWasm0(arg, malloc, realloc) {
|
package/u_numflow_bg.wasm
CHANGED
|
Binary file
|