@stdlib/stats-array 0.1.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 +177 -0
- package/NOTICE +1 -0
- package/README.md +385 -0
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +1105 -0
- package/lib/index.js +582 -0
- package/package.json +123 -0
|
@@ -0,0 +1,1105 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* @license Apache-2.0
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 The Stdlib Authors.
|
|
5
|
+
*
|
|
6
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License.
|
|
8
|
+
* You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
* See the License for the specific language governing permissions and
|
|
16
|
+
* limitations under the License.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
|
+
|
|
21
|
+
/* eslint-disable max-lines */
|
|
22
|
+
|
|
23
|
+
import max = require( '@stdlib/stats-array-max' );
|
|
24
|
+
import maxBy = require( '@stdlib/stats-array-max-by' );
|
|
25
|
+
import maxabs = require( '@stdlib/stats-array-maxabs' );
|
|
26
|
+
import maxsorted = require( '@stdlib/stats-array-maxsorted' );
|
|
27
|
+
import mean = require( '@stdlib/stats-array-mean' );
|
|
28
|
+
import meankbn = require( '@stdlib/stats-array-meankbn' );
|
|
29
|
+
import meankbn2 = require( '@stdlib/stats-array-meankbn2' );
|
|
30
|
+
import meanors = require( '@stdlib/stats-array-meanors' );
|
|
31
|
+
import meanpn = require( '@stdlib/stats-array-meanpn' );
|
|
32
|
+
import meanpw = require( '@stdlib/stats-array-meanpw' );
|
|
33
|
+
import meanwd = require( '@stdlib/stats-array-meanwd' );
|
|
34
|
+
import mediansorted = require( '@stdlib/stats-array-mediansorted' );
|
|
35
|
+
import min = require( '@stdlib/stats-array-min' );
|
|
36
|
+
import minBy = require( '@stdlib/stats-array-min-by' );
|
|
37
|
+
import minabs = require( '@stdlib/stats-array-minabs' );
|
|
38
|
+
import minsorted = require( '@stdlib/stats-array-minsorted' );
|
|
39
|
+
import mskmax = require( '@stdlib/stats-array-mskmax' );
|
|
40
|
+
import mskmin = require( '@stdlib/stats-array-mskmin' );
|
|
41
|
+
import mskrange = require( '@stdlib/stats-array-mskrange' );
|
|
42
|
+
import nanmax = require( '@stdlib/stats-array-nanmax' );
|
|
43
|
+
import nanmaxBy = require( '@stdlib/stats-array-nanmax-by' );
|
|
44
|
+
import nanmaxabs = require( '@stdlib/stats-array-nanmaxabs' );
|
|
45
|
+
import nanmean = require( '@stdlib/stats-array-nanmean' );
|
|
46
|
+
import nanmeanors = require( '@stdlib/stats-array-nanmeanors' );
|
|
47
|
+
import nanmeanpn = require( '@stdlib/stats-array-nanmeanpn' );
|
|
48
|
+
import nanmeanwd = require( '@stdlib/stats-array-nanmeanwd' );
|
|
49
|
+
import nanmin = require( '@stdlib/stats-array-nanmin' );
|
|
50
|
+
import nanminBy = require( '@stdlib/stats-array-nanmin-by' );
|
|
51
|
+
import nanminabs = require( '@stdlib/stats-array-nanminabs' );
|
|
52
|
+
import nanmskmax = require( '@stdlib/stats-array-nanmskmax' );
|
|
53
|
+
import nanmskmin = require( '@stdlib/stats-array-nanmskmin' );
|
|
54
|
+
import nanmskrange = require( '@stdlib/stats-array-nanmskrange' );
|
|
55
|
+
import nanrange = require( '@stdlib/stats-array-nanrange' );
|
|
56
|
+
import nanrangeBy = require( '@stdlib/stats-array-nanrange-by' );
|
|
57
|
+
import nanstdev = require( '@stdlib/stats-array-nanstdev' );
|
|
58
|
+
import nanstdevch = require( '@stdlib/stats-array-nanstdevch' );
|
|
59
|
+
import nanstdevpn = require( '@stdlib/stats-array-nanstdevpn' );
|
|
60
|
+
import nanstdevtk = require( '@stdlib/stats-array-nanstdevtk' );
|
|
61
|
+
import nanstdevwd = require( '@stdlib/stats-array-nanstdevwd' );
|
|
62
|
+
import nanstdevyc = require( '@stdlib/stats-array-nanstdevyc' );
|
|
63
|
+
import nanvariance = require( '@stdlib/stats-array-nanvariance' );
|
|
64
|
+
import nanvariancech = require( '@stdlib/stats-array-nanvariancech' );
|
|
65
|
+
import nanvariancepn = require( '@stdlib/stats-array-nanvariancepn' );
|
|
66
|
+
import nanvariancetk = require( '@stdlib/stats-array-nanvariancetk' );
|
|
67
|
+
import nanvariancewd = require( '@stdlib/stats-array-nanvariancewd' );
|
|
68
|
+
import nanvarianceyc = require( '@stdlib/stats-array-nanvarianceyc' );
|
|
69
|
+
import range = require( '@stdlib/stats-array-range' );
|
|
70
|
+
import rangeBy = require( '@stdlib/stats-array-range-by' );
|
|
71
|
+
import stdev = require( '@stdlib/stats-array-stdev' );
|
|
72
|
+
import stdevch = require( '@stdlib/stats-array-stdevch' );
|
|
73
|
+
import stdevpn = require( '@stdlib/stats-array-stdevpn' );
|
|
74
|
+
import stdevtk = require( '@stdlib/stats-array-stdevtk' );
|
|
75
|
+
import stdevwd = require( '@stdlib/stats-array-stdevwd' );
|
|
76
|
+
import stdevyc = require( '@stdlib/stats-array-stdevyc' );
|
|
77
|
+
import variance = require( '@stdlib/stats-array-variance' );
|
|
78
|
+
import variancech = require( '@stdlib/stats-array-variancech' );
|
|
79
|
+
import variancepn = require( '@stdlib/stats-array-variancepn' );
|
|
80
|
+
import variancetk = require( '@stdlib/stats-array-variancetk' );
|
|
81
|
+
import variancewd = require( '@stdlib/stats-array-variancewd' );
|
|
82
|
+
import varianceyc = require( '@stdlib/stats-array-varianceyc' );
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Interface describing the `array` namespace.
|
|
86
|
+
*/
|
|
87
|
+
interface Namespace {
|
|
88
|
+
/**
|
|
89
|
+
* Computes the maximum value of an array.
|
|
90
|
+
*
|
|
91
|
+
* @param x - input array
|
|
92
|
+
* @returns maximum value
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
96
|
+
*
|
|
97
|
+
* var v = ns.max( x );
|
|
98
|
+
* // returns 2.0
|
|
99
|
+
*/
|
|
100
|
+
max: typeof max;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Computes the maximum value of an array via a callback function.
|
|
104
|
+
*
|
|
105
|
+
* @param x - input array
|
|
106
|
+
* @param clbk - callback
|
|
107
|
+
* @param thisArg - execution context
|
|
108
|
+
* @returns maximum value
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
|
|
112
|
+
*
|
|
113
|
+
* function accessor( v ) {
|
|
114
|
+
* return v * 2.0;
|
|
115
|
+
* }
|
|
116
|
+
*
|
|
117
|
+
* var v = ns.maxBy( x, accessor );
|
|
118
|
+
* // returns 8.0
|
|
119
|
+
*/
|
|
120
|
+
maxBy: typeof maxBy;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Computes the maximum absolute value of an array.
|
|
124
|
+
*
|
|
125
|
+
* @param x - input array
|
|
126
|
+
* @returns maximum absolute value
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
130
|
+
*
|
|
131
|
+
* var v = ns.maxabs( x );
|
|
132
|
+
* // returns 2.0
|
|
133
|
+
*/
|
|
134
|
+
maxabs: typeof maxabs;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Computes the maximum value of a sorted array.
|
|
138
|
+
*
|
|
139
|
+
* @param x - input array
|
|
140
|
+
* @returns maximum value
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* var x = [ 1.0, 2.0, 3.0 ];
|
|
144
|
+
*
|
|
145
|
+
* var v = ns.maxsorted( x );
|
|
146
|
+
* // returns 3.0
|
|
147
|
+
*/
|
|
148
|
+
maxsorted: typeof maxsorted;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Computes the arithmetic mean of an array.
|
|
152
|
+
*
|
|
153
|
+
* @param x - input array
|
|
154
|
+
* @returns arithmetic mean
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
158
|
+
*
|
|
159
|
+
* var v = ns.mean( x );
|
|
160
|
+
* // returns ~0.3333
|
|
161
|
+
*/
|
|
162
|
+
mean: typeof mean;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Computes the arithmetic mean of an array using an improved Kahan–Babuška algorithm.
|
|
166
|
+
*
|
|
167
|
+
* @param x - input array
|
|
168
|
+
* @returns arithmetic mean
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
172
|
+
*
|
|
173
|
+
* var v = ns.meankbn( x );
|
|
174
|
+
* // returns ~0.3333
|
|
175
|
+
*/
|
|
176
|
+
meankbn: typeof meankbn;
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Computes the arithmetic mean of an array using a second-order iterative Kahan–Babuška algorithm.
|
|
180
|
+
*
|
|
181
|
+
* @param x - input array
|
|
182
|
+
* @returns arithmetic mean
|
|
183
|
+
*
|
|
184
|
+
* @example
|
|
185
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
186
|
+
*
|
|
187
|
+
* var v = ns.meankbn2( x );
|
|
188
|
+
* // returns ~0.3333
|
|
189
|
+
*/
|
|
190
|
+
meankbn2: typeof meankbn2;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Computes the arithmetic mean of an array using ordinary recursive summation.
|
|
194
|
+
*
|
|
195
|
+
* @param x - input array
|
|
196
|
+
* @returns arithmetic mean
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
200
|
+
*
|
|
201
|
+
* var v = ns.meanors( x );
|
|
202
|
+
* // returns ~0.3333
|
|
203
|
+
*/
|
|
204
|
+
meanors: typeof meanors;
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Computes the arithmetic mean of an array using a two-pass error correction algorithm.
|
|
208
|
+
*
|
|
209
|
+
* @param x - input array
|
|
210
|
+
* @returns arithmetic mean
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
214
|
+
*
|
|
215
|
+
* var v = ns.meanpn( x );
|
|
216
|
+
* // returns ~0.3333
|
|
217
|
+
*/
|
|
218
|
+
meanpn: typeof meanpn;
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Computes the arithmetic mean of an array using pairwise summation.
|
|
222
|
+
*
|
|
223
|
+
* @param x - input array
|
|
224
|
+
* @returns arithmetic mean
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
228
|
+
*
|
|
229
|
+
* var v = ns.meanpw( x );
|
|
230
|
+
* // returns ~0.3333
|
|
231
|
+
*/
|
|
232
|
+
meanpw: typeof meanpw;
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* Computes the arithmetic mean of an array using Welford's algorithm.
|
|
236
|
+
*
|
|
237
|
+
* @param x - input array
|
|
238
|
+
* @returns arithmetic mean
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
242
|
+
*
|
|
243
|
+
* var v = ns.meanwd( x );
|
|
244
|
+
* // returns ~0.3333
|
|
245
|
+
*/
|
|
246
|
+
meanwd: typeof meanwd;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Computes the median value of a sorted array.
|
|
250
|
+
*
|
|
251
|
+
* @param x - input array
|
|
252
|
+
* @returns median value
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* var x = [ 1.0, 2.0, 3.0 ];
|
|
256
|
+
*
|
|
257
|
+
* var v = ns.mediansorted( x );
|
|
258
|
+
* // returns 2.0
|
|
259
|
+
*/
|
|
260
|
+
mediansorted: typeof mediansorted;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Computes the minimum value of an array.
|
|
264
|
+
*
|
|
265
|
+
* @param x - input array
|
|
266
|
+
* @returns minimum value
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
270
|
+
*
|
|
271
|
+
* var v = ns.min( x );
|
|
272
|
+
* // returns -2.0
|
|
273
|
+
*/
|
|
274
|
+
min: typeof min;
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Computes the minimum value of an array via a callback function.
|
|
278
|
+
*
|
|
279
|
+
* @param x - input array
|
|
280
|
+
* @param clbk - callback
|
|
281
|
+
* @param thisArg - execution context
|
|
282
|
+
* @returns minimum value
|
|
283
|
+
*
|
|
284
|
+
* @example
|
|
285
|
+
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
|
|
286
|
+
*
|
|
287
|
+
* function accessor( v ) {
|
|
288
|
+
* return v * 2.0;
|
|
289
|
+
* }
|
|
290
|
+
*
|
|
291
|
+
* var v = ns.minBy( x, accessor );
|
|
292
|
+
* // returns -10.0
|
|
293
|
+
*/
|
|
294
|
+
minBy: typeof minBy;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Computes the minimum absolute value of an array.
|
|
298
|
+
*
|
|
299
|
+
* @param x - input array
|
|
300
|
+
* @returns minimum absolute value
|
|
301
|
+
*
|
|
302
|
+
* @example
|
|
303
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
304
|
+
*
|
|
305
|
+
* var v = ns.minabs( x );
|
|
306
|
+
* // returns 1.0
|
|
307
|
+
*/
|
|
308
|
+
minabs: typeof minabs;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Computes the minimum value of a sorted array.
|
|
312
|
+
*
|
|
313
|
+
* @param x - input array
|
|
314
|
+
* @returns minimum value
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* var x = [ 1.0, 2.0, 3.0 ];
|
|
318
|
+
*
|
|
319
|
+
* var v = ns.minsorted( x );
|
|
320
|
+
* // returns 1.0
|
|
321
|
+
*/
|
|
322
|
+
minsorted: typeof minsorted;
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Computes the maximum value of an array according to a mask.
|
|
326
|
+
*
|
|
327
|
+
* @param x - input array
|
|
328
|
+
* @param mask - mask array
|
|
329
|
+
* @returns maximum value
|
|
330
|
+
*
|
|
331
|
+
* @example
|
|
332
|
+
* var x = [ 1.0, -2.0, 4.0, 2.0 ];
|
|
333
|
+
* var mask = [ 0, 0, 1, 0 ];
|
|
334
|
+
*
|
|
335
|
+
* var v = ns.mskmax( x, mask );
|
|
336
|
+
* // returns 2.0
|
|
337
|
+
*/
|
|
338
|
+
mskmax: typeof mskmax;
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Computes the minimum value of an array according to a mask.
|
|
342
|
+
*
|
|
343
|
+
* @param x - input array
|
|
344
|
+
* @param mask - mask array
|
|
345
|
+
* @returns minimum value
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* var x = [ 1.0, -2.0, -4.0, 2.0 ];
|
|
349
|
+
* var mask = [ 0, 0, 1, 0 ];
|
|
350
|
+
*
|
|
351
|
+
* var v = ns.mskmin( x, mask );
|
|
352
|
+
* // returns -2.0
|
|
353
|
+
*/
|
|
354
|
+
mskmin: typeof mskmin;
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Computes the range of an array according to a mask.
|
|
358
|
+
*
|
|
359
|
+
* @param x - input array
|
|
360
|
+
* @param mask - mask array
|
|
361
|
+
* @returns range
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* var x = [ 1.0, -2.0, 4.0, 2.0 ];
|
|
365
|
+
* var mask = [ 0, 0, 1, 0 ];
|
|
366
|
+
*
|
|
367
|
+
* var v = ns.mskrange( x, mask );
|
|
368
|
+
* // returns 4.0
|
|
369
|
+
*/
|
|
370
|
+
mskrange: typeof mskrange;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Computes the maximum value of an array, ignoring `NaN` values.
|
|
374
|
+
*
|
|
375
|
+
* @param x - input array
|
|
376
|
+
* @returns maximum value
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
380
|
+
*
|
|
381
|
+
* var v = ns.nanmax( x );
|
|
382
|
+
* // returns 2.0
|
|
383
|
+
*/
|
|
384
|
+
nanmax: typeof nanmax;
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Computes the maximum value of an array via a callback function, ignoring `NaN` values.
|
|
388
|
+
*
|
|
389
|
+
* @param x - input array
|
|
390
|
+
* @param clbk - callback
|
|
391
|
+
* @param thisArg - execution context
|
|
392
|
+
* @returns maximum value
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
|
|
396
|
+
*
|
|
397
|
+
* function accessor( v ) {
|
|
398
|
+
* return v * 2.0;
|
|
399
|
+
* }
|
|
400
|
+
*
|
|
401
|
+
* var v = ns.nanmaxBy( x, accessor );
|
|
402
|
+
* // returns 8.0
|
|
403
|
+
*/
|
|
404
|
+
nanmaxBy: typeof nanmaxBy;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Computes the maximum absolute value of an array, ignoring `NaN` values.
|
|
408
|
+
*
|
|
409
|
+
* @param x - input array
|
|
410
|
+
* @returns maximum absolute value
|
|
411
|
+
*
|
|
412
|
+
* @example
|
|
413
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
414
|
+
*
|
|
415
|
+
* var v = ns.nanmaxabs( x );
|
|
416
|
+
* // returns 2.0
|
|
417
|
+
*/
|
|
418
|
+
nanmaxabs: typeof nanmaxabs;
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Computes the arithmetic mean of an array, ignoring `NaN` values.
|
|
422
|
+
*
|
|
423
|
+
* @param x - input array
|
|
424
|
+
* @returns arithmetic mean
|
|
425
|
+
*
|
|
426
|
+
* @example
|
|
427
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
428
|
+
*
|
|
429
|
+
* var v = ns.nanmean( x );
|
|
430
|
+
* // returns ~0.3333
|
|
431
|
+
*/
|
|
432
|
+
nanmean: typeof nanmean;
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Computes the arithmetic mean of an array, ignoring `NaN` values and using ordinary recursive summation.
|
|
436
|
+
*
|
|
437
|
+
* @param x - input array
|
|
438
|
+
* @returns arithmetic mean
|
|
439
|
+
*
|
|
440
|
+
* @example
|
|
441
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
442
|
+
*
|
|
443
|
+
* var v = ns.nanmeanors( x );
|
|
444
|
+
* // returns ~0.3333
|
|
445
|
+
*/
|
|
446
|
+
nanmeanors: typeof nanmeanors;
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Computes the arithmetic mean of an array, ignoring `NaN` values and using a two-pass error correction algorithm.
|
|
450
|
+
*
|
|
451
|
+
* @param x - input array
|
|
452
|
+
* @returns arithmetic mean
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
456
|
+
*
|
|
457
|
+
* var v = ns.nanmeanpn( x );
|
|
458
|
+
* // returns ~0.3333
|
|
459
|
+
*/
|
|
460
|
+
nanmeanpn: typeof nanmeanpn;
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Computes the arithmetic mean of an array, ignoring `NaN` values and using Welford's algorithm.
|
|
464
|
+
*
|
|
465
|
+
* @param x - input array
|
|
466
|
+
* @returns arithmetic mean
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
470
|
+
*
|
|
471
|
+
* var v = ns.nanmeanwd( x );
|
|
472
|
+
* // returns ~0.3333
|
|
473
|
+
*/
|
|
474
|
+
nanmeanwd: typeof nanmeanwd;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Computes the minimum value of an array, ignoring `NaN` values.
|
|
478
|
+
*
|
|
479
|
+
* @param x - input array
|
|
480
|
+
* @returns minimum value
|
|
481
|
+
*
|
|
482
|
+
* @example
|
|
483
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
484
|
+
*
|
|
485
|
+
* var v = ns.nanmin( x );
|
|
486
|
+
* // returns -2.0
|
|
487
|
+
*/
|
|
488
|
+
nanmin: typeof nanmin;
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* Computes the minimum value of an array via a callback function, ignoring `NaN` values.
|
|
492
|
+
*
|
|
493
|
+
* @param x - input array
|
|
494
|
+
* @param clbk - callback
|
|
495
|
+
* @param thisArg - execution context
|
|
496
|
+
* @returns minimum value
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
|
|
500
|
+
*
|
|
501
|
+
* function accessor( v ) {
|
|
502
|
+
* return v * 2.0;
|
|
503
|
+
* }
|
|
504
|
+
*
|
|
505
|
+
* var v = ns.nanminBy( x, accessor );
|
|
506
|
+
* // returns -10.0
|
|
507
|
+
*/
|
|
508
|
+
nanminBy: typeof nanminBy;
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
* Computes the minimum absolute value of an array, ignoring `NaN` values.
|
|
512
|
+
*
|
|
513
|
+
* @param x - input array
|
|
514
|
+
* @returns minimum absolute value
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
518
|
+
*
|
|
519
|
+
* var v = ns.nanminabs( x );
|
|
520
|
+
* // returns 1.0
|
|
521
|
+
*/
|
|
522
|
+
nanminabs: typeof nanminabs;
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Computes the maximum value of an array according to a mask, ignoring `NaN` values.
|
|
526
|
+
*
|
|
527
|
+
* @param x - input array
|
|
528
|
+
* @param mask - mask array
|
|
529
|
+
* @returns maximum value
|
|
530
|
+
*
|
|
531
|
+
* @example
|
|
532
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
533
|
+
* var mask = [ 0, 1, 0, 0 ];
|
|
534
|
+
*
|
|
535
|
+
* var v = ns.nanmskmax( x, mask );
|
|
536
|
+
* // returns 2.0
|
|
537
|
+
*/
|
|
538
|
+
nanmskmax: typeof nanmskmax;
|
|
539
|
+
|
|
540
|
+
/**
|
|
541
|
+
* Computes the minimum value of an array according to a mask, ignoring `NaN` values.
|
|
542
|
+
*
|
|
543
|
+
* @param x - input array
|
|
544
|
+
* @param mask - mask array
|
|
545
|
+
* @returns minimum value
|
|
546
|
+
*
|
|
547
|
+
* @example
|
|
548
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
549
|
+
* var mask = [ 0, 1, 0, 0 ];
|
|
550
|
+
*
|
|
551
|
+
* var v = ns.nanmskmin( x, mask );
|
|
552
|
+
* // returns 1.0
|
|
553
|
+
*/
|
|
554
|
+
nanmskmin: typeof nanmskmin;
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Computes the range of an array according to a mask, ignoring `NaN` values.
|
|
558
|
+
*
|
|
559
|
+
* @param x - input array
|
|
560
|
+
* @param mask - mask array
|
|
561
|
+
* @returns range
|
|
562
|
+
*
|
|
563
|
+
* @example
|
|
564
|
+
* var x = [ 1.0, -2.0, 4.0, 2.0, NaN, NaN ];
|
|
565
|
+
* var mask = [ 0, 0, 1, 0, 0, 0 ];
|
|
566
|
+
*
|
|
567
|
+
* var v = ns.nanmskrange( x, mask );
|
|
568
|
+
* // returns 4.0
|
|
569
|
+
*/
|
|
570
|
+
nanmskrange: typeof nanmskrange;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Computes the range of an array, ignoring `NaN` values.
|
|
574
|
+
*
|
|
575
|
+
* @param x - input array
|
|
576
|
+
* @returns range
|
|
577
|
+
*
|
|
578
|
+
* @example
|
|
579
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
580
|
+
*
|
|
581
|
+
* var v = ns.nanrange( x );
|
|
582
|
+
* // returns 4.0
|
|
583
|
+
*/
|
|
584
|
+
nanrange: typeof nanrange;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Computes the range of an array via a callback function, ignoring `NaN` values.
|
|
588
|
+
*
|
|
589
|
+
* @param x - input array
|
|
590
|
+
* @param clbk - callback
|
|
591
|
+
* @param thisArg - execution context
|
|
592
|
+
* @returns range
|
|
593
|
+
*
|
|
594
|
+
* @example
|
|
595
|
+
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, NaN, 0.0, -1.0, -3.0 ];
|
|
596
|
+
*
|
|
597
|
+
* function accessor( v ) {
|
|
598
|
+
* return v * 2.0;
|
|
599
|
+
* }
|
|
600
|
+
*
|
|
601
|
+
* var v = ns.nanrangeBy( x, accessor );
|
|
602
|
+
* // returns 18.0
|
|
603
|
+
*/
|
|
604
|
+
nanrangeBy: typeof nanrangeBy;
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* Computes the standard deviation of an array ignoring `NaN` values.
|
|
608
|
+
*
|
|
609
|
+
* ## Notes
|
|
610
|
+
*
|
|
611
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
612
|
+
*
|
|
613
|
+
* @param x - input array
|
|
614
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
615
|
+
* @returns standard deviation
|
|
616
|
+
*
|
|
617
|
+
* @example
|
|
618
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
619
|
+
*
|
|
620
|
+
* var v = ns.nanstdev( x, 1.0 );
|
|
621
|
+
* // returns ~2.0817
|
|
622
|
+
*/
|
|
623
|
+
nanstdev: typeof nanstdev;
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Computes the standard deviation of an array ignoring `NaN` values and using a one-pass trial mean algorithm.
|
|
627
|
+
*
|
|
628
|
+
* ## Notes
|
|
629
|
+
*
|
|
630
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
631
|
+
*
|
|
632
|
+
* @param x - input array
|
|
633
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
634
|
+
* @returns standard deviation
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
638
|
+
*
|
|
639
|
+
* var v = ns.nanstdevch( x, 1.0 );
|
|
640
|
+
* // returns ~2.0817
|
|
641
|
+
*/
|
|
642
|
+
nanstdevch: typeof nanstdevch;
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* Computes the standard deviation of an array ignoring `NaN` values and using a two-pass algorithm.
|
|
646
|
+
*
|
|
647
|
+
* ## Notes
|
|
648
|
+
*
|
|
649
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
650
|
+
*
|
|
651
|
+
* @param x - input array
|
|
652
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
653
|
+
* @returns standard deviation
|
|
654
|
+
*
|
|
655
|
+
* @example
|
|
656
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
657
|
+
*
|
|
658
|
+
* var v = ns.nanstdevpn( x, 1.0 );
|
|
659
|
+
* // returns ~2.0817
|
|
660
|
+
*/
|
|
661
|
+
nanstdevpn: typeof nanstdevpn;
|
|
662
|
+
|
|
663
|
+
/**
|
|
664
|
+
* Computes the standard deviation of an array ignoring `NaN` values and using a one-pass textbook algorithm.
|
|
665
|
+
*
|
|
666
|
+
* ## Notes
|
|
667
|
+
*
|
|
668
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
669
|
+
*
|
|
670
|
+
* @param x - input array
|
|
671
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
672
|
+
* @returns standard deviation
|
|
673
|
+
*
|
|
674
|
+
* @example
|
|
675
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
676
|
+
*
|
|
677
|
+
* var v = ns.nanstdevtk( x, 1.0 );
|
|
678
|
+
* // returns ~2.0817
|
|
679
|
+
*/
|
|
680
|
+
nanstdevtk: typeof nanstdevtk;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Computes the standard deviation of an array ignoring `NaN` values and using Welford's algorithm.
|
|
684
|
+
*
|
|
685
|
+
* ## Notes
|
|
686
|
+
*
|
|
687
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
688
|
+
*
|
|
689
|
+
* @param x - input array
|
|
690
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
691
|
+
* @returns standard deviation
|
|
692
|
+
*
|
|
693
|
+
* @example
|
|
694
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
695
|
+
*
|
|
696
|
+
* var v = ns.nanstdevwd( x, 1.0 );
|
|
697
|
+
* // returns ~2.0817
|
|
698
|
+
*/
|
|
699
|
+
nanstdevwd: typeof nanstdevwd;
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Computes the standard deviation of an array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
|
|
703
|
+
*
|
|
704
|
+
* ## Notes
|
|
705
|
+
*
|
|
706
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
707
|
+
*
|
|
708
|
+
* @param x - input array
|
|
709
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
710
|
+
* @returns standard deviation
|
|
711
|
+
*
|
|
712
|
+
* @example
|
|
713
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
714
|
+
*
|
|
715
|
+
* var v = ns.nanstdevyc( x, 1.0 );
|
|
716
|
+
* // returns ~2.0817
|
|
717
|
+
*/
|
|
718
|
+
nanstdevyc: typeof nanstdevyc;
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* Computes the variance of an array ignoring `NaN` values.
|
|
722
|
+
*
|
|
723
|
+
* ## Notes
|
|
724
|
+
*
|
|
725
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
726
|
+
*
|
|
727
|
+
* @param x - input array
|
|
728
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
729
|
+
* @returns variance
|
|
730
|
+
*
|
|
731
|
+
* @example
|
|
732
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
733
|
+
*
|
|
734
|
+
* var v = ns.nanvariance( x, 1.0 );
|
|
735
|
+
* // returns ~4.3333
|
|
736
|
+
*/
|
|
737
|
+
nanvariance: typeof nanvariance;
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* Computes the variance of an array ignoring `NaN` values and using a one-pass trial mean algorithm.
|
|
741
|
+
*
|
|
742
|
+
* ## Notes
|
|
743
|
+
*
|
|
744
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
745
|
+
*
|
|
746
|
+
* @param x - input array
|
|
747
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
748
|
+
* @returns variance
|
|
749
|
+
*
|
|
750
|
+
* @example
|
|
751
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
752
|
+
*
|
|
753
|
+
* var v = ns.nanvariancech( x, 1.0 );
|
|
754
|
+
* // returns ~4.3333
|
|
755
|
+
*/
|
|
756
|
+
nanvariancech: typeof nanvariancech;
|
|
757
|
+
|
|
758
|
+
/**
|
|
759
|
+
* Computes the variance of an array ignoring `NaN` values and using a two-pass algorithm.
|
|
760
|
+
*
|
|
761
|
+
* ## Notes
|
|
762
|
+
*
|
|
763
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
764
|
+
*
|
|
765
|
+
* @param x - input array
|
|
766
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
767
|
+
* @returns variance
|
|
768
|
+
*
|
|
769
|
+
* @example
|
|
770
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
771
|
+
*
|
|
772
|
+
* var v = ns.nanvariancepn( x, 1.0 );
|
|
773
|
+
* // returns ~4.3333
|
|
774
|
+
*/
|
|
775
|
+
nanvariancepn: typeof nanvariancepn;
|
|
776
|
+
|
|
777
|
+
/**
|
|
778
|
+
* Computes the variance of an array ignoring `NaN` values and using a one-pass textbook algorithm.
|
|
779
|
+
*
|
|
780
|
+
* ## Notes
|
|
781
|
+
*
|
|
782
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
783
|
+
*
|
|
784
|
+
* @param x - input array
|
|
785
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
786
|
+
* @returns variance
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
790
|
+
*
|
|
791
|
+
* var v = ns.nanvariancetk( x, 1.0 );
|
|
792
|
+
* // returns ~4.3333
|
|
793
|
+
*/
|
|
794
|
+
nanvariancetk: typeof nanvariancetk;
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* Computes the variance of an array ignoring `NaN` values and using Welford's algorithm.
|
|
798
|
+
*
|
|
799
|
+
* ## Notes
|
|
800
|
+
*
|
|
801
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
802
|
+
*
|
|
803
|
+
* @param x - input array
|
|
804
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
805
|
+
* @returns variance
|
|
806
|
+
*
|
|
807
|
+
* @example
|
|
808
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
809
|
+
*
|
|
810
|
+
* var v = ns.nanvariancewd( x, 1.0 );
|
|
811
|
+
* // returns ~4.3333
|
|
812
|
+
*/
|
|
813
|
+
nanvariancewd: typeof nanvariancewd;
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Computes the variance of an array ignoring `NaN` values and using a one-pass algorithm proposed by Youngs and Cramer.
|
|
817
|
+
*
|
|
818
|
+
* ## Notes
|
|
819
|
+
*
|
|
820
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `N` corresponds to the number of non-`NaN` array elements and `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
821
|
+
*
|
|
822
|
+
* @param x - input array
|
|
823
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
824
|
+
* @returns variance
|
|
825
|
+
*
|
|
826
|
+
* @example
|
|
827
|
+
* var x = [ 1.0, -2.0, NaN, 2.0 ];
|
|
828
|
+
*
|
|
829
|
+
* var v = ns.nanvarianceyc( x, 1.0 );
|
|
830
|
+
* // returns ~4.3333
|
|
831
|
+
*/
|
|
832
|
+
nanvarianceyc: typeof nanvarianceyc;
|
|
833
|
+
|
|
834
|
+
/**
|
|
835
|
+
* Computes the range of an array.
|
|
836
|
+
*
|
|
837
|
+
* @param x - input array
|
|
838
|
+
* @returns range
|
|
839
|
+
*
|
|
840
|
+
* @example
|
|
841
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
842
|
+
*
|
|
843
|
+
* var v = ns.range( x );
|
|
844
|
+
* // returns 4.0
|
|
845
|
+
*/
|
|
846
|
+
range: typeof range;
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Computes the range of an array via a callback function.
|
|
850
|
+
*
|
|
851
|
+
* @param x - input array
|
|
852
|
+
* @param clbk - callback
|
|
853
|
+
* @param thisArg - execution context
|
|
854
|
+
* @returns range
|
|
855
|
+
*
|
|
856
|
+
* @example
|
|
857
|
+
* var x = [ -2.0, 1.0, 3.0, -5.0, 4.0, 0.0, -1.0, -3.0 ];
|
|
858
|
+
*
|
|
859
|
+
* function accessor( v ) {
|
|
860
|
+
* return v * 2.0;
|
|
861
|
+
* }
|
|
862
|
+
*
|
|
863
|
+
* var v = ns.rangeBy( x, accessor );
|
|
864
|
+
* // returns 18.0
|
|
865
|
+
*/
|
|
866
|
+
rangeBy: typeof rangeBy;
|
|
867
|
+
|
|
868
|
+
/**
|
|
869
|
+
* Computes the standard deviation of an array.
|
|
870
|
+
*
|
|
871
|
+
* ## Notes
|
|
872
|
+
*
|
|
873
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
874
|
+
*
|
|
875
|
+
* @param x - input array
|
|
876
|
+
* @param correction - degrees of freedom adjustment
|
|
877
|
+
* @returns standard deviation
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
881
|
+
*
|
|
882
|
+
* var v = ns.stdev( x, 1.0 );
|
|
883
|
+
* // returns ~2.0817
|
|
884
|
+
*/
|
|
885
|
+
stdev: typeof stdev;
|
|
886
|
+
|
|
887
|
+
/**
|
|
888
|
+
* Computes the standard deviation of an array using a one-pass trial mean algorithm.
|
|
889
|
+
*
|
|
890
|
+
* ## Notes
|
|
891
|
+
*
|
|
892
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
893
|
+
*
|
|
894
|
+
* @param x - input array
|
|
895
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
896
|
+
* @returns standard deviation
|
|
897
|
+
*
|
|
898
|
+
* @example
|
|
899
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
900
|
+
*
|
|
901
|
+
* var v = ns.stdevch( x, 1.0 );
|
|
902
|
+
* // returns ~2.0817
|
|
903
|
+
*/
|
|
904
|
+
stdevch: typeof stdevch;
|
|
905
|
+
|
|
906
|
+
/**
|
|
907
|
+
* Computes the standard deviation of an array using a two-pass algorithm.
|
|
908
|
+
*
|
|
909
|
+
* ## Notes
|
|
910
|
+
*
|
|
911
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
912
|
+
*
|
|
913
|
+
* @param x - input array
|
|
914
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
915
|
+
* @returns standard deviation
|
|
916
|
+
*
|
|
917
|
+
* @example
|
|
918
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
919
|
+
*
|
|
920
|
+
* var v = ns.stdevpn( x, 1.0 );
|
|
921
|
+
* // returns ~2.0817
|
|
922
|
+
*/
|
|
923
|
+
stdevpn: typeof stdevpn;
|
|
924
|
+
|
|
925
|
+
/**
|
|
926
|
+
* Computes the standard deviation of an array using a one-pass textbook algorithm.
|
|
927
|
+
*
|
|
928
|
+
* ## Notes
|
|
929
|
+
*
|
|
930
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
931
|
+
*
|
|
932
|
+
* @param x - input array
|
|
933
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
934
|
+
* @returns standard deviation
|
|
935
|
+
*
|
|
936
|
+
* @example
|
|
937
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
938
|
+
*
|
|
939
|
+
* var v = ns.stdevtk( x, 1.0 );
|
|
940
|
+
* // returns ~2.0817
|
|
941
|
+
*/
|
|
942
|
+
stdevtk: typeof stdevtk;
|
|
943
|
+
|
|
944
|
+
/**
|
|
945
|
+
* Computes the standard deviation of an array using Welford's algorithm.
|
|
946
|
+
*
|
|
947
|
+
* ## Notes
|
|
948
|
+
*
|
|
949
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
950
|
+
*
|
|
951
|
+
* @param x - input array
|
|
952
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
953
|
+
* @returns standard deviation
|
|
954
|
+
*
|
|
955
|
+
* @example
|
|
956
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
957
|
+
*
|
|
958
|
+
* var v = ns.stdevwd( x, 1.0 );
|
|
959
|
+
* // returns ~2.0817
|
|
960
|
+
*/
|
|
961
|
+
stdevwd: typeof stdevwd;
|
|
962
|
+
|
|
963
|
+
/**
|
|
964
|
+
* Computes the standard deviation of an array using a one-pass algorithm proposed by Youngs and Cramer.
|
|
965
|
+
*
|
|
966
|
+
* ## Notes
|
|
967
|
+
*
|
|
968
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the standard deviation according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the standard deviation of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample standard deviation, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
969
|
+
*
|
|
970
|
+
* @param x - input array
|
|
971
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
972
|
+
* @returns standard deviation
|
|
973
|
+
*
|
|
974
|
+
* @example
|
|
975
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
976
|
+
*
|
|
977
|
+
* var v = ns.stdevyc( x, 1.0 );
|
|
978
|
+
* // returns ~2.0817
|
|
979
|
+
*/
|
|
980
|
+
stdevyc: typeof stdevyc;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Computes the variance of an array.
|
|
984
|
+
*
|
|
985
|
+
* ## Notes
|
|
986
|
+
*
|
|
987
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
988
|
+
*
|
|
989
|
+
* @param x - input array
|
|
990
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
991
|
+
* @returns variance
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
995
|
+
*
|
|
996
|
+
* var v = ns.variance( x, 1.0 );
|
|
997
|
+
* // returns ~4.3333
|
|
998
|
+
*/
|
|
999
|
+
variance: typeof variance;
|
|
1000
|
+
|
|
1001
|
+
/**
|
|
1002
|
+
* Computes the variance of an array using a one-pass trial mean algorithm.
|
|
1003
|
+
*
|
|
1004
|
+
* ## Notes
|
|
1005
|
+
*
|
|
1006
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
1007
|
+
*
|
|
1008
|
+
* @param x - input array
|
|
1009
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
1010
|
+
* @returns variance
|
|
1011
|
+
*
|
|
1012
|
+
* @example
|
|
1013
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
1014
|
+
*
|
|
1015
|
+
* var v = ns.variancech( x, 1.0 );
|
|
1016
|
+
* // returns ~4.3333
|
|
1017
|
+
*/
|
|
1018
|
+
variancech: typeof variancech;
|
|
1019
|
+
|
|
1020
|
+
/**
|
|
1021
|
+
* Computes the variance of an array using a two-pass algorithm.
|
|
1022
|
+
*
|
|
1023
|
+
* ## Notes
|
|
1024
|
+
*
|
|
1025
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
1026
|
+
*
|
|
1027
|
+
* @param x - input array
|
|
1028
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
1029
|
+
* @returns variance
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
1033
|
+
*
|
|
1034
|
+
* var v = ns.variancepn( x, 1.0 );
|
|
1035
|
+
* // returns ~4.3333
|
|
1036
|
+
*/
|
|
1037
|
+
variancepn: typeof variancepn;
|
|
1038
|
+
|
|
1039
|
+
/**
|
|
1040
|
+
* Computes the variance of an array using a one-pass textbook algorithm.
|
|
1041
|
+
*
|
|
1042
|
+
* ## Notes
|
|
1043
|
+
*
|
|
1044
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
1045
|
+
*
|
|
1046
|
+
* @param x - input array
|
|
1047
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
1048
|
+
* @returns variance
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
1052
|
+
*
|
|
1053
|
+
* var v = ns.variancetk( x, 1.0 );
|
|
1054
|
+
* // returns ~4.3333
|
|
1055
|
+
*/
|
|
1056
|
+
variancetk: typeof variancetk;
|
|
1057
|
+
|
|
1058
|
+
/**
|
|
1059
|
+
* Computes the variance of an array using Welford's algorithm.
|
|
1060
|
+
*
|
|
1061
|
+
* ## Notes
|
|
1062
|
+
*
|
|
1063
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
1064
|
+
*
|
|
1065
|
+
* @param x - input array
|
|
1066
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
1067
|
+
* @returns variance
|
|
1068
|
+
*
|
|
1069
|
+
* @example
|
|
1070
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
1071
|
+
*
|
|
1072
|
+
* var v = ns.variancewd( x, 1.0 );
|
|
1073
|
+
* // returns ~4.3333
|
|
1074
|
+
*/
|
|
1075
|
+
variancewd: typeof variancewd;
|
|
1076
|
+
|
|
1077
|
+
/**
|
|
1078
|
+
* Computes the variance of an array using a one-pass algorithm proposed by Youngs and Cramer.
|
|
1079
|
+
*
|
|
1080
|
+
* ## Notes
|
|
1081
|
+
*
|
|
1082
|
+
* - Setting the correction parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the variance according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the variance of a population, setting the correction parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample variance, setting the correction parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
|
|
1083
|
+
*
|
|
1084
|
+
* @param x - input array
|
|
1085
|
+
* @param correction - degrees of freedom adjustment (default: 1.0)
|
|
1086
|
+
* @returns variance
|
|
1087
|
+
*
|
|
1088
|
+
* @example
|
|
1089
|
+
* var x = [ 1.0, -2.0, 2.0 ];
|
|
1090
|
+
*
|
|
1091
|
+
* var v = ns.varianceyc( x, 1.0 );
|
|
1092
|
+
* // returns ~4.3333
|
|
1093
|
+
*/
|
|
1094
|
+
varianceyc: typeof varianceyc;
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
/**
|
|
1098
|
+
* Statistical functions for arrays.
|
|
1099
|
+
*/
|
|
1100
|
+
declare var ns: Namespace;
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
// EXPORTS //
|
|
1104
|
+
|
|
1105
|
+
export = ns;
|