@stdlib/stats-incr-covmat 0.0.7 → 0.2.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 +0 -304
- package/NOTICE +1 -1
- package/README.md +29 -14
- package/SECURITY.md +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/docs/types/index.d.ts +4 -4
- package/lib/index.js +2 -2
- package/lib/main.js +8 -7
- package/package.json +20 -17
- package/docs/repl.txt +0 -46
- package/docs/types/test.ts +0 -161
package/LICENSE
CHANGED
|
@@ -175,307 +175,3 @@
|
|
|
175
175
|
of your accepting any such warranty or additional liability.
|
|
176
176
|
|
|
177
177
|
END OF TERMS AND CONDITIONS
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
182
|
-
|
|
183
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
184
|
-
obtaining a copy of the software and accompanying documentation covered by this
|
|
185
|
-
license (the "Software") to use, reproduce, display, distribute, execute, and
|
|
186
|
-
transmit the Software, and to prepare derivative works of the Software, and to
|
|
187
|
-
permit third-parties to whom the Software is furnished to do so, all subject to
|
|
188
|
-
the following:
|
|
189
|
-
|
|
190
|
-
The copyright notices in the Software and this entire statement, including the
|
|
191
|
-
above license grant, this restriction and the following disclaimer, must be
|
|
192
|
-
included in all copies of the Software, in whole or in part, and all derivative
|
|
193
|
-
works of the Software, unless such copies or derivative works are solely in the
|
|
194
|
-
form of machine-executable object code generated by a source language processor.
|
|
195
|
-
|
|
196
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
197
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
198
|
-
FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
199
|
-
COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
|
|
200
|
-
OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
|
|
201
|
-
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
DEPENDENCIES
|
|
207
|
-
|
|
208
|
-
The library links against the following external libraries, which have their own
|
|
209
|
-
licenses:
|
|
210
|
-
|
|
211
|
-
* OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
|
|
212
|
-
def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
|
|
213
|
-
|
|
214
|
-
Copyright (c) 2011-2014, The OpenBLAS Project
|
|
215
|
-
All rights reserved.
|
|
216
|
-
|
|
217
|
-
Redistribution and use in source and binary forms, with or without
|
|
218
|
-
modification, are permitted provided that the following conditions are
|
|
219
|
-
met:
|
|
220
|
-
|
|
221
|
-
1. Redistributions of source code must retain the above copyright
|
|
222
|
-
notice, this list of conditions and the following disclaimer.
|
|
223
|
-
|
|
224
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
225
|
-
notice, this list of conditions and the following disclaimer in
|
|
226
|
-
the documentation and/or other materials provided with the
|
|
227
|
-
distribution.
|
|
228
|
-
|
|
229
|
-
3. Neither the name of the OpenBLAS project nor the names of
|
|
230
|
-
its contributors may be used to endorse or promote products
|
|
231
|
-
derived from this software without specific prior written
|
|
232
|
-
permission.
|
|
233
|
-
|
|
234
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
235
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
236
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
237
|
-
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
238
|
-
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
239
|
-
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
|
240
|
-
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
241
|
-
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
242
|
-
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
243
|
-
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
* Electron <https://raw.githubusercontent.com/electron/electron/
|
|
247
|
-
c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
|
|
248
|
-
|
|
249
|
-
Copyright (c) 2013-2017 GitHub Inc.
|
|
250
|
-
|
|
251
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
252
|
-
a copy of this software and associated documentation files (the
|
|
253
|
-
"Software"), to deal in the Software without restriction, including
|
|
254
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
255
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
256
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
257
|
-
the following conditions:
|
|
258
|
-
|
|
259
|
-
The above copyright notice and this permission notice shall be
|
|
260
|
-
included in all copies or substantial portions of the Software.
|
|
261
|
-
|
|
262
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
263
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
264
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
265
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
266
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
267
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
268
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
* Boost <http://www.boost.org/LICENSE_1_0.txt>
|
|
272
|
-
|
|
273
|
-
Boost Software License - Version 1.0 - August 17th, 2003
|
|
274
|
-
|
|
275
|
-
Permission is hereby granted, free of charge, to any person or organization
|
|
276
|
-
obtaining a copy of the software and accompanying documentation covered by
|
|
277
|
-
this license (the "Software") to use, reproduce, display, distribute,
|
|
278
|
-
execute, and transmit the Software, and to prepare derivative works of the
|
|
279
|
-
Software, and to permit third-parties to whom the Software is furnished to
|
|
280
|
-
do so, all subject to the following:
|
|
281
|
-
|
|
282
|
-
The copyright notices in the Software and this entire statement, including
|
|
283
|
-
the above license grant, this restriction and the following disclaimer,
|
|
284
|
-
must be included in all copies of the Software, in whole or in part, and
|
|
285
|
-
all derivative works of the Software, unless such copies or derivative
|
|
286
|
-
works are solely in the form of machine-executable object code generated by
|
|
287
|
-
a source language processor.
|
|
288
|
-
|
|
289
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
290
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
291
|
-
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
|
292
|
-
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
|
293
|
-
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
|
294
|
-
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
295
|
-
DEALINGS IN THE SOFTWARE.
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* Cephes <http://www.netlib.org/cephes/readme>
|
|
299
|
-
|
|
300
|
-
Copyright (c) 1984-2000 Stephen L. Moshier
|
|
301
|
-
|
|
302
|
-
Some software in this archive may be from the book _Methods and Programs for
|
|
303
|
-
Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
|
|
304
|
-
or from the Cephes Mathematical Library, a commercial product. In either event,
|
|
305
|
-
it is copyrighted by the author. What you see here may be used freely but it
|
|
306
|
-
comes with no support or guarantee.
|
|
307
|
-
|
|
308
|
-
Stephen L. Moshier
|
|
309
|
-
moshier@na-net.ornl.gov
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
ATTRIBUTION
|
|
314
|
-
|
|
315
|
-
The library contains implementations from the following external libraries,
|
|
316
|
-
which have their own licenses:
|
|
317
|
-
|
|
318
|
-
* FreeBSD <https://svnweb.freebsd.org/>
|
|
319
|
-
|
|
320
|
-
Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
|
|
321
|
-
|
|
322
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
323
|
-
Permission to use, copy, modify, and distribute this
|
|
324
|
-
software is freely granted, provided that this notice
|
|
325
|
-
is preserved.
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
* FDLIBM <http://www.netlib.org/fdlibm/>
|
|
329
|
-
|
|
330
|
-
Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
|
|
331
|
-
|
|
332
|
-
Developed at SunPro, a Sun Microsystems, Inc. business.
|
|
333
|
-
Permission to use, copy, modify, and distribute this
|
|
334
|
-
software is freely granted, provided that this notice
|
|
335
|
-
is preserved.
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
* Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
|
|
339
|
-
|
|
340
|
-
Copyright (c) 2009 The Go Authors. All rights reserved.
|
|
341
|
-
|
|
342
|
-
Redistribution and use in source and binary forms, with or without
|
|
343
|
-
modification, are permitted provided that the following conditions are
|
|
344
|
-
met:
|
|
345
|
-
|
|
346
|
-
* Redistributions of source code must retain the above copyright
|
|
347
|
-
notice, this list of conditions and the following disclaimer.
|
|
348
|
-
* Redistributions in binary form must reproduce the above
|
|
349
|
-
copyright notice, this list of conditions and the following disclaimer
|
|
350
|
-
in the documentation and/or other materials provided with the
|
|
351
|
-
distribution.
|
|
352
|
-
* Neither the name of Google Inc. nor the names of its
|
|
353
|
-
contributors may be used to endorse or promote products derived from
|
|
354
|
-
this software without specific prior written permission.
|
|
355
|
-
|
|
356
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
357
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
358
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
359
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
360
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
361
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
362
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
363
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
364
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
365
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
366
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
* SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
|
|
370
|
-
|
|
371
|
-
Public domain.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
* ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
|
|
375
|
-
|
|
376
|
-
Copyright JS Foundation and other contributors, https://js.foundation
|
|
377
|
-
|
|
378
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
379
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
380
|
-
in the Software without restriction, including without limitation the rights
|
|
381
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
382
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
383
|
-
furnished to do so, subject to the following conditions:
|
|
384
|
-
|
|
385
|
-
The above copyright notice and this permission notice shall be included in
|
|
386
|
-
all copies or substantial portions of the Software.
|
|
387
|
-
|
|
388
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
389
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
390
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
391
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
392
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
393
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
394
|
-
THE SOFTWARE.
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
* StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
|
|
398
|
-
e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
|
|
399
|
-
|
|
400
|
-
Copyright (c) 2015: Dahua Lin.
|
|
401
|
-
|
|
402
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
403
|
-
a copy of this software and associated documentation files (the
|
|
404
|
-
"Software"), to deal in the Software without restriction, including
|
|
405
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
406
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
407
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
408
|
-
the following conditions:
|
|
409
|
-
|
|
410
|
-
The above copyright notice and this permission notice shall be
|
|
411
|
-
included in all copies or substantial portions of the Software.
|
|
412
|
-
|
|
413
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
414
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
415
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
416
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
417
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
418
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
419
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
* SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
|
|
423
|
-
SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
|
|
424
|
-
|
|
425
|
-
The MIT License (MIT)
|
|
426
|
-
|
|
427
|
-
Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
|
|
428
|
-
|
|
429
|
-
https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
|
|
430
|
-
|
|
431
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
432
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
433
|
-
in the Software without restriction, including without limitation the rights
|
|
434
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
435
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
436
|
-
furnished to do so, subject to the following conditions:
|
|
437
|
-
|
|
438
|
-
The above copyright notice and this permission notice shall be included in all
|
|
439
|
-
copies or substantial portions of the Software.
|
|
440
|
-
|
|
441
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
442
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
443
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
444
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
445
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
446
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
447
|
-
SOFTWARE.
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
* MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
|
|
451
|
-
mt19937ar.c>
|
|
452
|
-
|
|
453
|
-
Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
|
|
454
|
-
All rights reserved.
|
|
455
|
-
|
|
456
|
-
Redistribution and use in source and binary forms, with or without
|
|
457
|
-
modification, are permitted provided that the following conditions
|
|
458
|
-
are met:
|
|
459
|
-
|
|
460
|
-
1. Redistributions of source code must retain the above copyright
|
|
461
|
-
notice, this list of conditions and the following disclaimer.
|
|
462
|
-
|
|
463
|
-
2. Redistributions in binary form must reproduce the above copyright
|
|
464
|
-
notice, this list of conditions and the following disclaimer in the
|
|
465
|
-
documentation and/or other materials provided with the distribution.
|
|
466
|
-
|
|
467
|
-
3. The names of its contributors may not be used to endorse or promote
|
|
468
|
-
products derived from this software without specific prior written
|
|
469
|
-
permission.
|
|
470
|
-
|
|
471
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
472
|
-
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
473
|
-
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
474
|
-
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
475
|
-
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
476
|
-
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
477
|
-
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
478
|
-
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
479
|
-
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
480
|
-
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
481
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2024 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -18,6 +18,17 @@ limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
-->
|
|
20
20
|
|
|
21
|
+
|
|
22
|
+
<details>
|
|
23
|
+
<summary>
|
|
24
|
+
About stdlib...
|
|
25
|
+
</summary>
|
|
26
|
+
<p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
|
|
27
|
+
<p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
|
|
28
|
+
<p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
|
|
29
|
+
<p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
|
|
30
|
+
</details>
|
|
31
|
+
|
|
21
32
|
# incrcovmat
|
|
22
33
|
|
|
23
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
@@ -33,7 +44,7 @@ A [covariance matrix][covariance-matrix] is an M-by-M matrix whose elements spec
|
|
|
33
44
|
<div class="equation" align="center" data-raw-text="\operatorname{cov_{jkn}} = \frac{1}{n-1} \sum_{i=0}^{n-1} (x_{ij} - \bar{x}_{jn})(x_{ik} - \bar{x}_{kn})" data-equation="eq:unbiased_sample_covariance_unknown_means">
|
|
34
45
|
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@49d8cabda84033d55d7b8069f19ee3dd8b8d1496/lib/node_modules/@stdlib/stats/incr/covmat/docs/img/equation_unbiased_sample_covariance_unknown_means.svg" alt="Equation for the unbiased sample covariance for unknown population means.">
|
|
35
46
|
<br>
|
|
36
|
-
</div>
|
|
47
|
+
</div> -->
|
|
37
48
|
|
|
38
49
|
<!-- </equation> -->
|
|
39
50
|
|
|
@@ -41,7 +52,7 @@ For known population means, the [unbiased sample covariance][covariance-matrix]
|
|
|
41
52
|
|
|
42
53
|
<!-- <equation class="equation" label="eq:unbiased_sample_covariance_known_means" align="center" raw="\operatorname{cov_{jkn}} = \frac{1}{n} \sum_{i=0}^{n-1} (x_{ij} - \mu_{j})(x_{ik} - \mu_{k})" alt="Equation for the unbiased sample covariance for known population means."> -->
|
|
43
54
|
|
|
44
|
-
<div class="equation" align="center" data-raw-text="\operatorname{cov_{jkn}} = \frac{1}{n} \sum_{i=0}^{n-1} (x_{ij} - \mu_{j})(x_{ik} - \mu_{k})" data-equation="eq:unbiased_sample_covariance_known_means">
|
|
55
|
+
<!-- <div class="equation" align="center" data-raw-text="\operatorname{cov_{jkn}} = \frac{1}{n} \sum_{i=0}^{n-1} (x_{ij} - \mu_{j})(x_{ik} - \mu_{k})" data-equation="eq:unbiased_sample_covariance_known_means">
|
|
45
56
|
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@566f739b0d9a5b720546f84f74de841b8d5e0c54/lib/node_modules/@stdlib/stats/incr/covmat/docs/img/equation_unbiased_sample_covariance_known_means.svg" alt="Equation for the unbiased sample covariance for known population means.">
|
|
46
57
|
<br>
|
|
47
58
|
</div>
|
|
@@ -224,8 +235,8 @@ for ( i = 0; i < 100; i++ ) {
|
|
|
224
235
|
|
|
225
236
|
## See Also
|
|
226
237
|
|
|
227
|
-
- <span class="package-name">[`@stdlib/stats
|
|
228
|
-
- <span class="package-name">[`@stdlib/stats
|
|
238
|
+
- <span class="package-name">[`@stdlib/stats-incr/covariance`][@stdlib/stats/incr/covariance]</span><span class="delimiter">: </span><span class="description">compute an unbiased sample covariance incrementally.</span>
|
|
239
|
+
- <span class="package-name">[`@stdlib/stats-incr/pcorrmat`][@stdlib/stats/incr/pcorrmat]</span><span class="delimiter">: </span><span class="description">compute a sample Pearson product-moment correlation matrix incrementally.</span>
|
|
229
240
|
|
|
230
241
|
</section>
|
|
231
242
|
|
|
@@ -257,7 +268,7 @@ See [LICENSE][stdlib-license].
|
|
|
257
268
|
|
|
258
269
|
## Copyright
|
|
259
270
|
|
|
260
|
-
Copyright © 2016-
|
|
271
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
261
272
|
|
|
262
273
|
</section>
|
|
263
274
|
|
|
@@ -270,8 +281,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
270
281
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-incr-covmat.svg
|
|
271
282
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-incr-covmat
|
|
272
283
|
|
|
273
|
-
[test-image]: https://github.com/stdlib-js/stats-incr-covmat/actions/workflows/test.yml/badge.svg
|
|
274
|
-
[test-url]: https://github.com/stdlib-js/stats-incr-covmat/actions/workflows/test.yml
|
|
284
|
+
[test-image]: https://github.com/stdlib-js/stats-incr-covmat/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
285
|
+
[test-url]: https://github.com/stdlib-js/stats-incr-covmat/actions/workflows/test.yml?query=branch:v0.2.0
|
|
275
286
|
|
|
276
287
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-incr-covmat/main.svg
|
|
277
288
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-incr-covmat?branch=main
|
|
@@ -283,19 +294,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
283
294
|
|
|
284
295
|
-->
|
|
285
296
|
|
|
297
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
298
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
299
|
+
|
|
300
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
301
|
+
|
|
302
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
303
|
+
|
|
286
304
|
[umd]: https://github.com/umdjs/umd
|
|
287
305
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
288
306
|
|
|
289
307
|
[deno-url]: https://github.com/stdlib-js/stats-incr-covmat/tree/deno
|
|
308
|
+
[deno-readme]: https://github.com/stdlib-js/stats-incr-covmat/blob/deno/README.md
|
|
290
309
|
[umd-url]: https://github.com/stdlib-js/stats-incr-covmat/tree/umd
|
|
310
|
+
[umd-readme]: https://github.com/stdlib-js/stats-incr-covmat/blob/umd/README.md
|
|
291
311
|
[esm-url]: https://github.com/stdlib-js/stats-incr-covmat/tree/esm
|
|
292
|
-
|
|
293
|
-
[
|
|
294
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
295
|
-
|
|
296
|
-
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
297
|
-
|
|
298
|
-
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
312
|
+
[esm-readme]: https://github.com/stdlib-js/stats-incr-covmat/blob/esm/README.md
|
|
313
|
+
[branches-url]: https://github.com/stdlib-js/stats-incr-covmat/blob/main/branches.md
|
|
299
314
|
|
|
300
315
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-incr-covmat/main/LICENSE
|
|
301
316
|
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var M=function(a,i){return function(){return i||a((i={exports:{}}).exports,i),i.exports}};var b=M(function(z,V){
|
|
2
|
+
var F=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,P=require('@stdlib/assert-is-square-matrix/dist'),w=require('@stdlib/assert-is-vector-like/dist'),x=require('@stdlib/array-float64/dist'),S=require('@stdlib/ndarray-ctor/dist'),j=require('@stdlib/ndarray-base-ctor/dist'),y=require('@stdlib/ndarray-base-numel/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function E(a,i){var r,t,m,u;return i?u=j:u=S,t=new x(a*a),m=[a,a],r=[a,1],u("float64",t,m,r,0,"row-major")}function k(a){var i,r,t;return r=new x(a),t=[a],i=[1],j("float64",r,t,i,0,"row-major")}function C(a,i){var r,t,m,u,l,c;if(c=0,F(a))r=a,t=E(r,!1);else if(P(a))r=a.shape[0],t=a;else throw new TypeError(h('1HBDb',a));if(l=new x(r),u=E(r,!0),arguments.length>1){if(!w(i))throw new TypeError(h('1HBDc',i));if(y(i.shape)!==r)throw new Error(h('1HB9V',r,y(i.shape)));return m=i,A}return m=k(r),T;function T(s){var f,d,g,e,o,p,q,n,v;if(arguments.length===0)return c===0?null:t;if(!w(s))throw new TypeError(h('1HBDd',s));if(s.shape[0]!==r)throw new Error(h('1HB9W',r,s.shape[0]));for(p=c,c+=1,q=p/c,d=p||1,n=0;n<r;n++)for(o=m.get(n),l[n]=s.get(n)-o,o+=l[n]/c,m.set(n,o),g=q*l[n],v=0;v<=n;v++)e=u.get(n,v)+g*l[v],u.set(n,v,e),u.set(v,n,e),f=e/d,t.set(n,v,f),t.set(v,n,f);return t}function A(s){var f,d,g,e,o;if(arguments.length===0)return c===0?null:t;if(!w(s))throw new TypeError(h('1HBDd',s));if(s.shape[0]!==r)throw new Error(h('1HB9W',r,s.shape[0]));for(c+=1,e=0;e<r;e++)for(l[e]=s.get(e)-m.get(e),g=l[e],o=0;o<=e;o++)d=u.get(e,o)+g*l[o],u.set(e,o,d),u.set(o,e,d),f=d/c,t.set(e,o,f),t.set(o,e,f);return t}}V.exports=C
|
|
3
|
+
});var I=b();module.exports=I;
|
|
4
|
+
/** @license Apache-2.0 */
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../lib/main.js", "../lib/index.js"],
|
|
4
|
+
"sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimitive;\nvar isSquareMatrix = require( '@stdlib/assert-is-square-matrix' );\nvar isVectorLike = require( '@stdlib/assert-is-vector-like' );\nvar Float64Array = require( '@stdlib/array-float64' );\nvar ctor = require( '@stdlib/ndarray-ctor' );\nvar bctor = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\nvar format = require( '@stdlib/string-format' );\n\n\n// FUNCTIONS //\n\n/**\n* Returns a matrix.\n*\n* @private\n* @param {PositiveInteger} n - matrix order\n* @param {boolean} bool - boolean indicating whether to create a low-level ndarray\n* @returns {ndarray} matrix\n*/\nfunction createMatrix( n, bool ) {\n\tvar strides;\n\tvar buffer;\n\tvar shape;\n\tvar f;\n\n\tif ( bool ) {\n\t\tf = bctor;\n\t} else {\n\t\tf = ctor;\n\t}\n\tbuffer = new Float64Array( n*n );\n\tshape = [ n, n ];\n\tstrides = [ n, 1 ];\n\treturn f( 'float64', buffer, shape, strides, 0, 'row-major' );\n}\n\n/**\n* Returns a vector.\n*\n* @private\n* @param {PositiveInteger} N - number of elements\n* @returns {ndarray} vector\n*/\nfunction createVector( N ) {\n\tvar strides;\n\tvar buffer;\n\tvar shape;\n\n\tbuffer = new Float64Array( N );\n\tshape = [ N ];\n\tstrides = [ 1 ];\n\n\treturn bctor( 'float64', buffer, shape, strides, 0, 'row-major' );\n}\n\n\n// MAIN //\n\n/**\n* Returns an accumulator function which incrementally computes an unbiased sample covariance matrix.\n*\n* ## Method\n*\n* - For each unbiased sample covariance, we begin by defining the co-moment \\\\(C_{jn}\\\\)\n*\n* ```tex\n* C_n = \\sum_{i=1}^{n} ( x_i - \\bar{x}_n ) ( y_i - \\bar{y}_n )\n* ```\n*\n* where \\\\(\\bar{x}_n\\\\) and \\\\(\\bar{y}_n\\\\) are the sample means for \\\\(x\\\\) and \\\\(y\\\\), respectively.\n*\n* - Based on Welford's method, we know the update formulas for the sample means are given by\n*\n* ```tex\n* \\bar{x}_n = \\bar{x}_{n-1} + \\frac{x_n - \\bar{x}_{n-1}}{n}\n* ```\n*\n* and\n*\n* ```tex\n* \\bar{y}_n = \\bar{y}_{n-1} + \\frac{y_n - \\bar{y}_{n-1}}{n}\n* ```\n*\n* - Substituting into the equation for \\\\(C_n\\\\) and rearranging terms\n*\n* ```tex\n* C_n = C_{n-1} + (x_n - \\bar{x}_n) (y_n - \\bar{y}_{n-1})\n* ```\n*\n* where the apparent asymmetry arises from\n*\n* ```tex\n* x_n - \\bar{x}_n = \\frac{n-1}{n} (x_n - \\bar{x}_{n-1})\n* ```\n*\n* and, hence, the update term can be equivalently expressed\n*\n* ```tex\n* \\frac{n-1}{n} (x_n - \\bar{x}_{n-1}) (y_n - \\bar{y}_{n-1})\n* ```\n*\n* - The covariance can be defined\n*\n* ```tex\n* \\begin{align*}\n* \\operatorname{cov}_n(x,y) &= \\frac{C_n}{n} \\\\\n* &= \\frac{C_{n-1} + \\frac{n-1}{n} (x_n - \\bar{x}_{n-1}) (y_n - \\bar{y}_{n-1})}{n} \\\\\n* &= \\frac{(n-1)\\operatorname{cov}_{n-1}(x,y) + \\frac{n-1}{n} (x_n - \\bar{x}_{n-1}) (y_n - \\bar{y}_{n-1})}{n}\n* \\end{align*}\n* ```\n*\n* - Applying Bessel's correction, we arrive at an update formula for calculating an unbiased sample covariance\n*\n* ```tex\n* \\begin{align*}\n* \\operatorname{cov}_n(x,y) &= \\frac{n}{n-1}\\cdot\\frac{(n-1)\\operatorname{cov}_{n-1}(x,y) + \\frac{n-1}{n} (x_n - \\bar{x}_{n-1}) (y_n - \\bar{y}_{n-1})}{n} \\\\\n* &= \\operatorname{cov}_{n-1}(x,y) + \\frac{(x_n - \\bar{x}_{n-1}) (y_n - \\bar{y}_{n-1})}{n} \\\\\n* &= \\frac{C_{n-1}}{n-1} + \\frac{(x_n - \\bar{x}_{n-1}) (y_n - \\bar{y}_{n-1})}{n}\n* &= \\frac{C_{n-1} + \\frac{n-1}{n} (x_n - \\bar{x}_{n-1}) (y_n - \\bar{y}_{n-1})}{n-1}\n* \\end{align*}\n* ```\n*\n* @param {(PositiveInteger|ndarray)} out - order of the covariance matrix or a square 2-dimensional output ndarray for storing the covariance matrix\n* @param {ndarray} [means] - mean values\n* @throws {TypeError} first argument must be either a positive integer or a 2-dimensional ndarray having equal dimensions\n* @throws {TypeError} second argument must be a 1-dimensional ndarray\n* @throws {Error} number of means must match covariance matrix dimensions\n* @returns {Function} accumulator function\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n*\n* // Create an output covariance matrix:\n* var buffer = new Float64Array( 4 );\n* var shape = [ 2, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n* var order = 'row-major';\n*\n* var cov = ndarray( 'float64', buffer, shape, strides, offset, order );\n*\n* // Create a covariance matrix accumulator:\n* var accumulator = incrcovmat( cov );\n*\n* var out = accumulator();\n* // returns null\n*\n* // Create a data vector:\n* buffer = new Float64Array( 2 );\n* shape = [ 2 ];\n* strides = [ 1 ];\n*\n* var vec = ndarray( 'float64', buffer, shape, strides, offset, order );\n*\n* // Provide data to the accumulator:\n* vec.set( 0, 2.0 );\n* vec.set( 1, 1.0 );\n*\n* out = accumulator( vec );\n* // returns <ndarray>\n*\n* var bool = ( out === cov );\n* // returns true\n*\n* vec.set( 0, -5.0 );\n* vec.set( 1, 3.14 );\n*\n* out = accumulator( vec );\n* // returns <ndarray>\n*\n* // Retrieve the covariance matrix:\n* out = accumulator();\n* // returns <ndarray>\n*/\nfunction incrcovmat( out, means ) {\n\tvar order;\n\tvar cov;\n\tvar mu;\n\tvar C;\n\tvar d;\n\tvar N;\n\n\tN = 0;\n\tif ( isPositiveInteger( out ) ) {\n\t\torder = out;\n\t\tcov = createMatrix( order, false );\n\t} else if ( isSquareMatrix( out ) ) {\n\t\torder = out.shape[ 0 ];\n\t\tcov = out;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must either specify the order of the covariance matrix or be a square two-dimensional ndarray for storing the covariance matrix. Value: `%s`.', out ) );\n\t}\n\t// Create a scratch array for storing residuals (i.e., `x_i - xbar_{i-1}`):\n\td = new Float64Array( order );\n\n\t// Create a low-level scratch matrix for storing co-moments:\n\tC = createMatrix( order, true );\n\n\tif ( arguments.length > 1 ) {\n\t\tif ( !isVectorLike( means ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Second argument must be a one-dimensional ndarray. Value: `%s`.', means ) );\n\t\t}\n\t\tif ( numel( means.shape ) !== order ) {\n\t\t\tthrow new Error( format( 'invalid argument. The number of elements (means) in the second argument must match covariance matrix dimensions. Expected: `%u`. Actual: `%u`.', order, numel( means.shape ) ) );\n\t\t}\n\t\tmu = means; // TODO: should we copy this? Otherwise, internal state could be \"corrupted\" due to mutation outside the accumulator\n\t\treturn accumulator2;\n\t}\n\t// Create an ndarray vector for storing sample means (note: an ndarray interface is not necessary, but it reduces implementation complexity by ensuring a consistent abstraction for accessing and updating sample means):\n\tmu = createVector( order );\n\n\treturn accumulator1;\n\n\t/**\n\t* If provided a data vector, the accumulator function returns an updated unbiased sample covariance matrix. If not provided a data vector, the accumulator function returns the current unbiased sample covariance matrix.\n\t*\n\t* @private\n\t* @param {ndarray} [v] - data vector\n\t* @throws {TypeError} must provide a 1-dimensional ndarray\n\t* @throws {Error} vector length must match covariance matrix dimensions\n\t* @returns {(ndarray|null)} unbiased sample covariance matrix or null\n\t*/\n\tfunction accumulator1( v ) {\n\t\tvar covij;\n\t\tvar denom;\n\t\tvar rdx;\n\t\tvar cij;\n\t\tvar m;\n\t\tvar n;\n\t\tvar r;\n\t\tvar i;\n\t\tvar j;\n\t\tif ( arguments.length === 0 ) {\n\t\t\tif ( N === 0 ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn cov;\n\t\t}\n\t\tif ( !isVectorLike( v ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a one-dimensional ndarray. Value: `%s`.', v ) );\n\t\t}\n\t\tif ( v.shape[ 0 ] !== order ) {\n\t\t\tthrow new Error( format( 'invalid argument. Vector length must match covariance matrix dimensions. Expected: `%u`. Actual: `%u`.', order, v.shape[ 0 ] ) );\n\t\t}\n\t\tn = N;\n\t\tN += 1;\n\t\tr = n / N;\n\n\t\tdenom = n || 1; // Bessel's correction (avoiding divide-by-zero below)\n\n\t\tfor ( i = 0; i < order; i++ ) {\n\t\t\tm = mu.get( i );\n\n\t\t\t// Compute the residual:\n\t\t\td[ i ] = v.get( i ) - m;\n\n\t\t\t// Update the sample mean:\n\t\t\tm += d[ i ] / N;\n\t\t\tmu.set( i, m );\n\n\t\t\t// Update the co-moments and covariance matrix, recognizing that the covariance matrix is symmetric...\n\t\t\trdx = r * d[ i ]; // if `n=0`, `r=0.0`\n\t\t\tfor ( j = 0; j <= i; j++ ) {\n\t\t\t\tcij = C.get( i, j ) + ( rdx*d[j] );\n\t\t\t\tC.set( i, j, cij );\n\t\t\t\tC.set( j, i, cij ); // via symmetry\n\n\t\t\t\tcovij = cij / denom;\n\t\t\t\tcov.set( i, j, covij );\n\t\t\t\tcov.set( j, i, covij ); // via symmetry\n\t\t\t}\n\t\t}\n\t\treturn cov;\n\t}\n\n\t/**\n\t* If provided a data vector, the accumulator function returns an updated unbiased sample covariance matrix. If not provided a data vector, the accumulator function returns the current unbiased sample covariance matrix.\n\t*\n\t* @private\n\t* @param {ndarray} [v] - data vector\n\t* @throws {TypeError} must provide a 1-dimensional ndarray\n\t* @throws {Error} vector length must match covariance matrix dimensions\n\t* @returns {(ndarray|null)} unbiased sample covariance matrix or null\n\t*/\n\tfunction accumulator2( v ) {\n\t\tvar covij;\n\t\tvar cij;\n\t\tvar di;\n\t\tvar i;\n\t\tvar j;\n\t\tif ( arguments.length === 0 ) {\n\t\t\tif ( N === 0 ) {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t\treturn cov;\n\t\t}\n\t\tif ( !isVectorLike( v ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a one-dimensional ndarray. Value: `%s`.', v ) );\n\t\t}\n\t\tif ( v.shape[ 0 ] !== order ) {\n\t\t\tthrow new Error( format( 'invalid argument. Vector length must match covariance matrix dimensions. Expected: `%u`. Actual: `%u`.', order, v.shape[ 0 ] ) );\n\t\t}\n\t\tN += 1;\n\t\tfor ( i = 0; i < order; i++ ) {\n\t\t\t// Compute the residual:\n\t\t\td[ i ] = v.get( i ) - mu.get( i );\n\n\t\t\t// Update the co-moments and covariance matrix, recognizing that the covariance matrix is symmetric...\n\t\t\tdi = d[ i ];\n\t\t\tfor ( j = 0; j <= i; j++ ) {\n\t\t\t\tcij = C.get( i, j ) + ( di*d[j] );\n\t\t\t\tC.set( i, j, cij );\n\t\t\t\tC.set( j, i, cij ); // via symmetry\n\n\t\t\t\tcovij = cij / N;\n\t\t\t\tcov.set( i, j, covij );\n\t\t\t\tcov.set( j, i, covij ); // via symmetry\n\t\t\t}\n\t\t}\n\t\treturn cov;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrcovmat;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2018 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Compute an unbiased sample covariance matrix incrementally.\n*\n* @module @stdlib/stats-incr-covmat\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var incrcovmat = require( '@stdlib/stats-incr-covmat' );\n*\n* // Create an output covariance matrix:\n* var buffer = new Float64Array( 4 );\n* var shape = [ 2, 2 ];\n* var strides = [ 2, 1 ];\n* var offset = 0;\n* var order = 'row-major';\n*\n* var cov = ndarray( 'float64', buffer, shape, strides, offset, order );\n*\n* // Create a covariance matrix accumulator:\n* var accumulator = incrcovmat( cov );\n*\n* var out = accumulator();\n* // returns null\n*\n* // Create a data vector:\n* buffer = new Float64Array( 2 );\n* shape = [ 2 ];\n* strides = [ 1 ];\n*\n* var vec = ndarray( 'float64', buffer, shape, strides, offset, order );\n*\n* // Provide data to the accumulator:\n* vec.set( 0, 2.0 );\n* vec.set( 1, 1.0 );\n*\n* out = accumulator( vec );\n* // returns <ndarray>\n*\n* var bool = ( out === cov );\n* // returns true\n*\n* vec.set( 0, -5.0 );\n* vec.set( 1, 3.14 );\n*\n* out = accumulator( vec );\n* // returns <ndarray>\n*\n* // Retrieve the covariance matrix:\n* out = accumulator();\n* // returns <ndarray>\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "isPositiveInteger", "isSquareMatrix", "isVectorLike", "Float64Array", "ctor", "bctor", "numel", "format", "createMatrix", "n", "bool", "strides", "buffer", "shape", "f", "createVector", "N", "incrcovmat", "out", "means", "order", "cov", "mu", "C", "d", "accumulator2", "accumulator1", "v", "covij", "denom", "rdx", "cij", "m", "r", "i", "j", "di", "main"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
// TypeScript Version:
|
|
19
|
+
// TypeScript Version: 4.1
|
|
20
20
|
|
|
21
21
|
/// <reference types="@stdlib/types"/>
|
|
22
22
|
|
|
@@ -43,8 +43,8 @@ type accumulator = ( vector?: ndarray ) => ndarray | null;
|
|
|
43
43
|
* @returns accumulator function
|
|
44
44
|
*
|
|
45
45
|
* @example
|
|
46
|
-
* var Float64Array = require(
|
|
47
|
-
* var ndarray = require(
|
|
46
|
+
* var Float64Array = require( '@stdlib/array-float64' );
|
|
47
|
+
* var ndarray = require( '@stdlib/ndarray-ctor' );
|
|
48
48
|
*
|
|
49
49
|
* // Create an output covariance matrix:
|
|
50
50
|
* var buffer = new Float64Array( 4 );
|
|
@@ -88,7 +88,7 @@ type accumulator = ( vector?: ndarray ) => ndarray | null;
|
|
|
88
88
|
* out = accumulator();
|
|
89
89
|
* // returns <ndarray>
|
|
90
90
|
*/
|
|
91
|
-
declare function incrcovmat( out: number | ndarray, means?: ndarray ): accumulator;
|
|
91
|
+
declare function incrcovmat( out: number | ndarray, means?: ndarray ): accumulator;
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
// EXPORTS //
|
package/lib/index.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -27,6 +27,7 @@ var Float64Array = require( '@stdlib/array-float64' );
|
|
|
27
27
|
var ctor = require( '@stdlib/ndarray-ctor' );
|
|
28
28
|
var bctor = require( '@stdlib/ndarray-base-ctor' );
|
|
29
29
|
var numel = require( '@stdlib/ndarray-base-numel' );
|
|
30
|
+
var format = require( '@stdlib/string-format' );
|
|
30
31
|
|
|
31
32
|
|
|
32
33
|
// FUNCTIONS //
|
|
@@ -211,7 +212,7 @@ function incrcovmat( out, means ) {
|
|
|
211
212
|
order = out.shape[ 0 ];
|
|
212
213
|
cov = out;
|
|
213
214
|
} else {
|
|
214
|
-
throw new TypeError( 'invalid argument. First argument must either specify the order of the covariance matrix or be a square
|
|
215
|
+
throw new TypeError( format( 'invalid argument. First argument must either specify the order of the covariance matrix or be a square two-dimensional ndarray for storing the covariance matrix. Value: `%s`.', out ) );
|
|
215
216
|
}
|
|
216
217
|
// Create a scratch array for storing residuals (i.e., `x_i - xbar_{i-1}`):
|
|
217
218
|
d = new Float64Array( order );
|
|
@@ -221,10 +222,10 @@ function incrcovmat( out, means ) {
|
|
|
221
222
|
|
|
222
223
|
if ( arguments.length > 1 ) {
|
|
223
224
|
if ( !isVectorLike( means ) ) {
|
|
224
|
-
throw new TypeError( 'invalid argument. Second argument must be a
|
|
225
|
+
throw new TypeError( format( 'invalid argument. Second argument must be a one-dimensional ndarray. Value: `%s`.', means ) );
|
|
225
226
|
}
|
|
226
227
|
if ( numel( means.shape ) !== order ) {
|
|
227
|
-
throw new Error( 'invalid argument. The number of elements (means) in the second argument must match covariance matrix dimensions. Expected:
|
|
228
|
+
throw new Error( format( 'invalid argument. The number of elements (means) in the second argument must match covariance matrix dimensions. Expected: `%u`. Actual: `%u`.', order, numel( means.shape ) ) );
|
|
228
229
|
}
|
|
229
230
|
mu = means; // TODO: should we copy this? Otherwise, internal state could be "corrupted" due to mutation outside the accumulator
|
|
230
231
|
return accumulator2;
|
|
@@ -260,10 +261,10 @@ function incrcovmat( out, means ) {
|
|
|
260
261
|
return cov;
|
|
261
262
|
}
|
|
262
263
|
if ( !isVectorLike( v ) ) {
|
|
263
|
-
throw new TypeError( 'invalid argument. Must provide a
|
|
264
|
+
throw new TypeError( format( 'invalid argument. Must provide a one-dimensional ndarray. Value: `%s`.', v ) );
|
|
264
265
|
}
|
|
265
266
|
if ( v.shape[ 0 ] !== order ) {
|
|
266
|
-
throw new Error( 'invalid argument. Vector length must match covariance matrix dimensions. Expected:
|
|
267
|
+
throw new Error( format( 'invalid argument. Vector length must match covariance matrix dimensions. Expected: `%u`. Actual: `%u`.', order, v.shape[ 0 ] ) );
|
|
267
268
|
}
|
|
268
269
|
n = N;
|
|
269
270
|
N += 1;
|
|
@@ -318,10 +319,10 @@ function incrcovmat( out, means ) {
|
|
|
318
319
|
return cov;
|
|
319
320
|
}
|
|
320
321
|
if ( !isVectorLike( v ) ) {
|
|
321
|
-
throw new TypeError( 'invalid argument. Must provide a
|
|
322
|
+
throw new TypeError( format( 'invalid argument. Must provide a one-dimensional ndarray. Value: `%s`.', v ) );
|
|
322
323
|
}
|
|
323
324
|
if ( v.shape[ 0 ] !== order ) {
|
|
324
|
-
throw new Error( 'invalid argument. Vector length must match covariance matrix dimensions. Expected:
|
|
325
|
+
throw new Error( format( 'invalid argument. Vector length must match covariance matrix dimensions. Expected: `%u`. Actual: `%u`.', order, v.shape[ 0 ] ) );
|
|
325
326
|
}
|
|
326
327
|
N += 1;
|
|
327
328
|
for ( i = 0; i < order; i++ ) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-incr-covmat",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Compute an unbiased sample covariance matrix incrementally.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,24 +37,27 @@
|
|
|
37
37
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@stdlib/array-float64": "^0.0
|
|
41
|
-
"@stdlib/assert-is-positive-integer": "^0.0
|
|
42
|
-
"@stdlib/assert-is-square-matrix": "^0.0
|
|
43
|
-
"@stdlib/assert-is-vector-like": "^0.0
|
|
44
|
-
"@stdlib/ndarray-base-ctor": "^0.0
|
|
45
|
-
"@stdlib/ndarray-base-numel": "^0.0
|
|
46
|
-
"@stdlib/ndarray-ctor": "^0.0
|
|
47
|
-
"@stdlib/
|
|
40
|
+
"@stdlib/array-float64": "^0.2.0",
|
|
41
|
+
"@stdlib/assert-is-positive-integer": "^0.2.0",
|
|
42
|
+
"@stdlib/assert-is-square-matrix": "^0.2.0",
|
|
43
|
+
"@stdlib/assert-is-vector-like": "^0.2.0",
|
|
44
|
+
"@stdlib/ndarray-base-ctor": "^0.2.0",
|
|
45
|
+
"@stdlib/ndarray-base-numel": "^0.2.0",
|
|
46
|
+
"@stdlib/ndarray-ctor": "^0.2.0",
|
|
47
|
+
"@stdlib/string-format": "^0.2.0",
|
|
48
|
+
"@stdlib/types": "^0.3.1",
|
|
49
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.2.0"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@stdlib/assert-is-symmetric-matrix": "^0.0
|
|
51
|
-
"@stdlib/
|
|
52
|
-
"@stdlib/
|
|
53
|
-
"@stdlib/
|
|
54
|
-
"@stdlib/random-base-randu": "^0.0.x",
|
|
52
|
+
"@stdlib/assert-is-symmetric-matrix": "^0.2.0",
|
|
53
|
+
"@stdlib/constants-float64-eps": "^0.2.0",
|
|
54
|
+
"@stdlib/math-base-special-abs": "^0.2.0",
|
|
55
|
+
"@stdlib/random-base-randu": "^0.1.0",
|
|
55
56
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
56
57
|
"istanbul": "^0.4.1",
|
|
57
|
-
"tap-
|
|
58
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
59
|
+
"@stdlib/bench-harness": "^0.2.0",
|
|
60
|
+
"@stdlib/bench": "^0.3.1"
|
|
58
61
|
},
|
|
59
62
|
"engines": {
|
|
60
63
|
"node": ">=0.10.0",
|
|
@@ -93,7 +96,7 @@
|
|
|
93
96
|
"accumulator"
|
|
94
97
|
],
|
|
95
98
|
"funding": {
|
|
96
|
-
"type": "
|
|
97
|
-
"url": "https://
|
|
99
|
+
"type": "opencollective",
|
|
100
|
+
"url": "https://opencollective.com/stdlib"
|
|
98
101
|
}
|
|
99
102
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( out[, means] )
|
|
3
|
-
Returns an accumulator function which incrementally computes an unbiased
|
|
4
|
-
sample covariance matrix.
|
|
5
|
-
|
|
6
|
-
If provided a data vector, the accumulator function returns an updated
|
|
7
|
-
unbiased sample covariance matrix. If not provided a data vector, the
|
|
8
|
-
accumulator function returns the current unbiased sample covariance matrix.
|
|
9
|
-
|
|
10
|
-
Parameters
|
|
11
|
-
----------
|
|
12
|
-
out: integer|ndarray
|
|
13
|
-
Order of the covariance matrix or a square 2-dimensional ndarray for
|
|
14
|
-
storing the covariance matrix.
|
|
15
|
-
|
|
16
|
-
means: ndarray (optional)
|
|
17
|
-
Known means.
|
|
18
|
-
|
|
19
|
-
Returns
|
|
20
|
-
-------
|
|
21
|
-
acc: Function
|
|
22
|
-
Accumulator function.
|
|
23
|
-
|
|
24
|
-
Examples
|
|
25
|
-
--------
|
|
26
|
-
> var accumulator = {{alias}}( 2 );
|
|
27
|
-
> var out = accumulator()
|
|
28
|
-
<ndarray>
|
|
29
|
-
> var buf = new {{alias:@stdlib/array/float64}}( 2 );
|
|
30
|
-
> var shape = [ 2 ];
|
|
31
|
-
> var strides = [ 1 ];
|
|
32
|
-
> var v = {{alias:@stdlib/ndarray/ctor}}( 'float64', buf, shape, strides, 0, 'row-major' );
|
|
33
|
-
> v.set( 0, 2.0 );
|
|
34
|
-
> v.set( 1, 1.0 );
|
|
35
|
-
> out = accumulator( v )
|
|
36
|
-
<ndarray>
|
|
37
|
-
> v.set( 0, -5.0 );
|
|
38
|
-
> v.set( 1, 3.14 );
|
|
39
|
-
> out = accumulator( v )
|
|
40
|
-
<ndarray>
|
|
41
|
-
> out = accumulator()
|
|
42
|
-
<ndarray>
|
|
43
|
-
|
|
44
|
-
See Also
|
|
45
|
-
--------
|
|
46
|
-
|
package/docs/types/test.ts
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @license Apache-2.0
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2021 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
|
-
import Float64Array = require( '@stdlib/array-float64' );
|
|
20
|
-
import ndarray = require( '@stdlib/ndarray-ctor' );
|
|
21
|
-
import incrcovmat = require( './index' );
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// TESTS //
|
|
25
|
-
|
|
26
|
-
// The function returns an accumulator function...
|
|
27
|
-
{
|
|
28
|
-
let buffer = new Float64Array( 4 );
|
|
29
|
-
let shape = [ 2, 2 ];
|
|
30
|
-
let strides = [ 2, 1 ];
|
|
31
|
-
|
|
32
|
-
// Create a 2-dimensional output covariance matrix:
|
|
33
|
-
const cov = ndarray( 'float64', buffer, shape, strides, 0, 'row-major' );
|
|
34
|
-
|
|
35
|
-
incrcovmat( cov ); // $ExpectType accumulator
|
|
36
|
-
incrcovmat( 2 ); // $ExpectType accumulator
|
|
37
|
-
|
|
38
|
-
buffer = new Float64Array( 2 );
|
|
39
|
-
shape = [ 2 ];
|
|
40
|
-
strides = [ 1 ];
|
|
41
|
-
|
|
42
|
-
const means = ndarray( 'float64', buffer, shape, strides, 0, 'row-major' );
|
|
43
|
-
means.set( 0, 3.0 );
|
|
44
|
-
means.set( 1, -5.5 );
|
|
45
|
-
incrcovmat( 2, means ); // $ExpectType accumulator
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// The compiler throws an error if the function is provided a first argument which is not an ndarray or number...
|
|
49
|
-
{
|
|
50
|
-
incrcovmat( '5' ); // $ExpectError
|
|
51
|
-
incrcovmat( true ); // $ExpectError
|
|
52
|
-
incrcovmat( false ); // $ExpectError
|
|
53
|
-
incrcovmat( null ); // $ExpectError
|
|
54
|
-
incrcovmat( undefined ); // $ExpectError
|
|
55
|
-
incrcovmat( [] ); // $ExpectError
|
|
56
|
-
incrcovmat( {} ); // $ExpectError
|
|
57
|
-
incrcovmat( ( x: number ): number => x ); // $ExpectError
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// The compiler throws an error if the function is provided a second argument which is not an ndarray...
|
|
61
|
-
{
|
|
62
|
-
incrcovmat( 2, '5' ); // $ExpectError
|
|
63
|
-
incrcovmat( 2, true ); // $ExpectError
|
|
64
|
-
incrcovmat( 2, false ); // $ExpectError
|
|
65
|
-
incrcovmat( 2, null ); // $ExpectError
|
|
66
|
-
incrcovmat( 2, [] ); // $ExpectError
|
|
67
|
-
incrcovmat( 2, {} ); // $ExpectError
|
|
68
|
-
incrcovmat( 2, ( x: number ): number => x ); // $ExpectError
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// The compiler throws an error if the function is provided an invalid number of arguments...
|
|
72
|
-
{
|
|
73
|
-
let buffer = new Float64Array( 4 );
|
|
74
|
-
let shape = [ 2, 2 ];
|
|
75
|
-
let strides = [ 2, 1 ];
|
|
76
|
-
|
|
77
|
-
// Create a 2-dimensional output covariance matrix:
|
|
78
|
-
const cov = ndarray( 'float64', buffer, shape, strides, 0, 'row-major' );
|
|
79
|
-
|
|
80
|
-
buffer = new Float64Array( 2 );
|
|
81
|
-
shape = [ 2 ];
|
|
82
|
-
strides = [ 1 ];
|
|
83
|
-
|
|
84
|
-
const means = ndarray( 'float64', buffer, shape, strides, 0, 'row-major' );
|
|
85
|
-
means.set( 0, 3.0 );
|
|
86
|
-
means.set( 1, -5.5 );
|
|
87
|
-
|
|
88
|
-
incrcovmat(); // $ExpectError
|
|
89
|
-
incrcovmat( cov, means, {} ); // $ExpectError
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// The function returns an accumulator function which returns an accumulated result...
|
|
93
|
-
{
|
|
94
|
-
const acc = incrcovmat( 2 );
|
|
95
|
-
acc(); // $ExpectType ndarray | null
|
|
96
|
-
|
|
97
|
-
const buffer = new Float64Array( 2 );
|
|
98
|
-
const shape = [ 2 ];
|
|
99
|
-
const strides = [ 1 ];
|
|
100
|
-
|
|
101
|
-
const vec = ndarray( 'float64', buffer, shape, strides, 0, 'row-major' );
|
|
102
|
-
vec.set( 0, 37.0 );
|
|
103
|
-
vec.set( 1, 45.0 );
|
|
104
|
-
acc( vec ); // $ExpectType ndarray | null
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// The function returns an accumulator function which returns an accumulated result (known means)...
|
|
108
|
-
{
|
|
109
|
-
let buffer = new Float64Array( 2 );
|
|
110
|
-
let shape = [ 2 ];
|
|
111
|
-
let strides = [ 1 ];
|
|
112
|
-
|
|
113
|
-
const means = ndarray( 'float64', buffer, shape, strides, 0, 'row-major' );
|
|
114
|
-
means.set( 0, 3.0 );
|
|
115
|
-
means.set( 1, -5.5 );
|
|
116
|
-
const acc = incrcovmat( 2, means );
|
|
117
|
-
|
|
118
|
-
acc(); // $ExpectType ndarray | null
|
|
119
|
-
buffer = new Float64Array( 2 );
|
|
120
|
-
shape = [ 2 ];
|
|
121
|
-
strides = [ 1 ];
|
|
122
|
-
|
|
123
|
-
const vec = ndarray( 'float64', buffer, shape, strides, 0, 'row-major' );
|
|
124
|
-
vec.set( 0, 37.0 );
|
|
125
|
-
vec.set( 1, 45.0 );
|
|
126
|
-
acc( vec ); // $ExpectType ndarray | null
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// The compiler throws an error if the returned accumulator function is provided an argument which is not an ndarray...
|
|
130
|
-
{
|
|
131
|
-
const acc = incrcovmat( 2 );
|
|
132
|
-
|
|
133
|
-
acc( 123 ); // $ExpectError
|
|
134
|
-
acc( 'abc' ); // $ExpectError
|
|
135
|
-
acc( true ); // $ExpectError
|
|
136
|
-
acc( false ); // $ExpectError
|
|
137
|
-
acc( null ); // $ExpectError
|
|
138
|
-
acc( [] ); // $ExpectError
|
|
139
|
-
acc( {} ); // $ExpectError
|
|
140
|
-
acc( ( x: number ): number => x ); // $ExpectError
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// The compiler throws an error if the returned accumulator function is provided invalid arguments (known means)...
|
|
144
|
-
{
|
|
145
|
-
const buffer = new Float64Array( 2 );
|
|
146
|
-
const shape = [ 2 ];
|
|
147
|
-
const strides = [ 1 ];
|
|
148
|
-
|
|
149
|
-
const means = ndarray( 'float64', buffer, shape, strides, 0, 'row-major' );
|
|
150
|
-
means.set( 0, 3.0 );
|
|
151
|
-
means.set( 1, -5.5 );
|
|
152
|
-
const acc = incrcovmat( 2, means );
|
|
153
|
-
|
|
154
|
-
acc( '5' ); // $ExpectError
|
|
155
|
-
acc( true ); // $ExpectError
|
|
156
|
-
acc( false ); // $ExpectError
|
|
157
|
-
acc( null ); // $ExpectError
|
|
158
|
-
acc( [] ); // $ExpectError
|
|
159
|
-
acc( {} ); // $ExpectError
|
|
160
|
-
acc( ( x: number ): number => x ); // $ExpectError
|
|
161
|
-
}
|