@stdlib/stats-incr-pcorrmat 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 +31 -16
- 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 +7 -6
- package/package.json +21 -18
- 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
|
# incrpcorrmat
|
|
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 [Pearson product-moment correlation matrix][pearson-correlation] is an M-by-M
|
|
|
33
44
|
<div class="equation" align="center" data-raw-text="\rho_{X,Y} = \frac{\operatorname{cov}(X,Y)}{\sigma_X \sigma_Y}" data-equation="eq:pearson_correlation_coefficient">
|
|
34
45
|
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@49d8cabda84033d55d7b8069f19ee3dd8b8d1496/lib/node_modules/@stdlib/stats/incr/pcorrmat/docs/img/equation_pearson_correlation_coefficient.svg" alt="Equation for the Pearson product-moment correlation coefficient.">
|
|
35
46
|
<br>
|
|
36
|
-
</div>
|
|
47
|
+
</div> -->
|
|
37
48
|
|
|
38
49
|
<!-- </equation> -->
|
|
39
50
|
|
|
@@ -41,9 +52,9 @@ where the numerator is the [covariance][covariance] and the denominator is the p
|
|
|
41
52
|
|
|
42
53
|
For a sample of size `n`, the [sample Pearson product-moment correlation coefficient][pearson-correlation] is defined as
|
|
43
54
|
|
|
44
|
-
<!-- <equation class="equation" label="eq:sample_pearson_correlation_coefficient" align="center" raw="r = \frac{\sum_{i=0}^{n-1} (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum_{i=0}^{n-1} (x_i - \bar{x})^2} \sqrt{\sum_{i=0}^{n-1} (y_i - \bar{y})^2}}" alt="Equation for the sample Pearson product-moment correlation coefficient."> -->
|
|
55
|
+
<!-- <equation class="equation" label="eq:sample_pearson_correlation_coefficient" align="center" raw="r = \frac{\displaystyle\sum_{i=0}^{n-1} (x_i - \bar{x})(y_i - \bar{y})}{\displaystyle\sqrt{\sum_{i=0}^{n-1} (x_i - \bar{x})^2} \sqrt{\sum_{i=0}^{n-1} (y_i - \bar{y})^2}}" alt="Equation for the sample Pearson product-moment correlation coefficient."> -->
|
|
45
56
|
|
|
46
|
-
<div class="equation" align="center" data-raw-text="r = \frac{\sum_{i=0}^{n-1} (x_i - \bar{x})(y_i - \bar{y})}{\sqrt{\sum_{i=0}^{n-1} (x_i - \bar{x})^2} \sqrt{\sum_{i=0}^{n-1} (y_i - \bar{y})^2}}" data-equation="eq:sample_pearson_correlation_coefficient">
|
|
57
|
+
<!-- <div class="equation" align="center" data-raw-text="r = \frac{\displaystyle\sum_{i=0}^{n-1} (x_i - \bar{x})(y_i - \bar{y})}{\displaystyle\sqrt{\sum_{i=0}^{n-1} (x_i - \bar{x})^2} \sqrt{\sum_{i=0}^{n-1} (y_i - \bar{y})^2}}" data-equation="eq:sample_pearson_correlation_coefficient">
|
|
47
58
|
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@49d8cabda84033d55d7b8069f19ee3dd8b8d1496/lib/node_modules/@stdlib/stats/incr/pcorrmat/docs/img/equation_sample_pearson_correlation_coefficient.svg" alt="Equation for the sample Pearson product-moment correlation coefficient.">
|
|
48
59
|
<br>
|
|
49
60
|
</div>
|
|
@@ -226,9 +237,9 @@ for ( i = 0; i < 100; i++ ) {
|
|
|
226
237
|
|
|
227
238
|
## See Also
|
|
228
239
|
|
|
229
|
-
- <span class="package-name">[`@stdlib/stats
|
|
230
|
-
- <span class="package-name">[`@stdlib/stats
|
|
231
|
-
- <span class="package-name">[`@stdlib/stats
|
|
240
|
+
- <span class="package-name">[`@stdlib/stats-incr/covmat`][@stdlib/stats/incr/covmat]</span><span class="delimiter">: </span><span class="description">compute an unbiased sample covariance matrix incrementally.</span>
|
|
241
|
+
- <span class="package-name">[`@stdlib/stats-incr/pcorr`][@stdlib/stats/incr/pcorr]</span><span class="delimiter">: </span><span class="description">compute a sample Pearson product-moment correlation coefficient.</span>
|
|
242
|
+
- <span class="package-name">[`@stdlib/stats-incr/pcorrdistmat`][@stdlib/stats/incr/pcorrdistmat]</span><span class="delimiter">: </span><span class="description">compute a sample Pearson product-moment correlation distance matrix incrementally.</span>
|
|
232
243
|
|
|
233
244
|
</section>
|
|
234
245
|
|
|
@@ -260,7 +271,7 @@ See [LICENSE][stdlib-license].
|
|
|
260
271
|
|
|
261
272
|
## Copyright
|
|
262
273
|
|
|
263
|
-
Copyright © 2016-
|
|
274
|
+
Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
264
275
|
|
|
265
276
|
</section>
|
|
266
277
|
|
|
@@ -273,8 +284,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
273
284
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-incr-pcorrmat.svg
|
|
274
285
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-incr-pcorrmat
|
|
275
286
|
|
|
276
|
-
[test-image]: https://github.com/stdlib-js/stats-incr-pcorrmat/actions/workflows/test.yml/badge.svg
|
|
277
|
-
[test-url]: https://github.com/stdlib-js/stats-incr-pcorrmat/actions/workflows/test.yml
|
|
287
|
+
[test-image]: https://github.com/stdlib-js/stats-incr-pcorrmat/actions/workflows/test.yml/badge.svg?branch=v0.2.0
|
|
288
|
+
[test-url]: https://github.com/stdlib-js/stats-incr-pcorrmat/actions/workflows/test.yml?query=branch:v0.2.0
|
|
278
289
|
|
|
279
290
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-incr-pcorrmat/main.svg
|
|
280
291
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-incr-pcorrmat?branch=main
|
|
@@ -286,19 +297,23 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
286
297
|
|
|
287
298
|
-->
|
|
288
299
|
|
|
300
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
301
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
302
|
+
|
|
303
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
304
|
+
|
|
305
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
306
|
+
|
|
289
307
|
[umd]: https://github.com/umdjs/umd
|
|
290
308
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
291
309
|
|
|
292
310
|
[deno-url]: https://github.com/stdlib-js/stats-incr-pcorrmat/tree/deno
|
|
311
|
+
[deno-readme]: https://github.com/stdlib-js/stats-incr-pcorrmat/blob/deno/README.md
|
|
293
312
|
[umd-url]: https://github.com/stdlib-js/stats-incr-pcorrmat/tree/umd
|
|
313
|
+
[umd-readme]: https://github.com/stdlib-js/stats-incr-pcorrmat/blob/umd/README.md
|
|
294
314
|
[esm-url]: https://github.com/stdlib-js/stats-incr-pcorrmat/tree/esm
|
|
295
|
-
|
|
296
|
-
[
|
|
297
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
298
|
-
|
|
299
|
-
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
300
|
-
|
|
301
|
-
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
315
|
+
[esm-readme]: https://github.com/stdlib-js/stats-incr-pcorrmat/blob/esm/README.md
|
|
316
|
+
[branches-url]: https://github.com/stdlib-js/stats-incr-pcorrmat/blob/main/branches.md
|
|
302
317
|
|
|
303
318
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-incr-pcorrmat/main/LICENSE
|
|
304
319
|
|
package/SECURITY.md
ADDED
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var I=function(t,o){return function(){return o||t((o={exports:{}}).exports,o),o.exports}};var S=I(function(N,P){
|
|
2
|
+
var L=require('@stdlib/assert-is-positive-integer/dist').isPrimitive,z=require('@stdlib/assert-is-square-matrix/dist'),b=require('@stdlib/assert-is-vector-like/dist'),E=require('@stdlib/array-float64/dist'),y=require('@stdlib/error-tools-fmtprodmsg/dist'),M=require('@stdlib/math-base-special-sqrt/dist'),B=require('@stdlib/ndarray-ctor/dist'),F=require('@stdlib/ndarray-base-ctor/dist'),T=require('@stdlib/ndarray-base-numel/dist');function A(t,o){var e,a,c,u;return o?u=F:u=B,a=new E(t*t),c=[t,t],e=[t,1],u("float64",a,c,e,0,"row-major")}function D(t,o){var e=t.shape[0],a;for(a=0;a<e;a++)t.set(a,a,o);return t}function G(t){var o,e,a;return e=new E(t),a=[t],o=[1],F("float64",e,a,o,0,"row-major")}function H(t,o){var e,a,c,u,q,m,h,v;if(v=0,L(t))e=t,a=A(e,!1);else if(z(t))e=t.shape[0],a=t;else throw new TypeError(y('1JfDf',t));if(a=D(a,1),h=new E(e),c=new E(e),u=new E(e),m=A(e,!0),arguments.length>1){if(!b(o))throw new TypeError(y('1JfDc',o));if(T(o.shape)!==e)throw new Error("invalid argument. The number of elements (means) in the second argument must match correlation matrix dimensions. Expected: "+e+". Actual: "+T(o.shape)+".");return q=o,C}return q=G(e),k;function k(l){var w,g,f,p,i,n,x,d,j,V,r,s;if(arguments.length===0)return v===0?null:a;if(!b(l))throw new TypeError(y('1JfDd',l));if(l.shape[0]!==e)throw new Error(y('1Jf9g',e,l.shape[0]));if(j=v,v+=1,V=j/v,w=j||1,v===1)for(r=0;r<e;r++)for(x=l.get(r),d=q.get(r),n=x-d,d+=n/v,q.set(r,d),h[r]=n,c[r]+=n*(x-d),u[r]=M(c[r]/w),g=V*h[r],s=0;s<r;s++)f=m.get(r,s)+g*h[s],m.set(r,s,f),m.set(s,r,f);else for(r=0;r<e;r++)for(x=l.get(r),d=q.get(r),n=x-d,d+=n/v,q.set(r,d),h[r]=n,c[r]+=n*(x-d),u[r]=M(c[r]/w),g=V*h[r],i=u[r],s=0;s<r;s++)f=m.get(r,s)+g*h[s],m.set(r,s,f),m.set(s,r,f),p=f/w/(i*u[s]),a.set(r,s,p),a.set(s,r,p);return a}function C(l){var w,g,f,p,i,n;if(arguments.length===0)return v===0?null:a;if(!b(l))throw new TypeError(y('1JfDd',l));if(l.shape[0]!==e)throw new Error(y('1Jf9g',e,l.shape[0]));for(v+=1,i=0;i<e;i++)for(p=l.get(i)-q.get(i),h[i]=p,c[i]+=p*p,u[i]=M(c[i]/v),f=u[i],n=0;n<i;n++)g=m.get(i,n)+p*h[n],m.set(i,n,g),m.set(n,i,g),w=g/v/(f*u[n]),a.set(i,n,w),a.set(n,i,w);return a}}P.exports=H
|
|
3
|
+
});var J=S();module.exports=J;
|
|
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 format = require( '@stdlib/string-format' );\nvar sqrt = require( '@stdlib/math-base-special-sqrt' );\nvar ctor = require( '@stdlib/ndarray-ctor' );\nvar bctor = require( '@stdlib/ndarray-base-ctor' );\nvar numel = require( '@stdlib/ndarray-base-numel' );\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* Sets the values along the main diagonal of a square matrix.\n*\n* @private\n* @param {ndarray} matrix - input square matrix\n* @param {number} v - value\n* @returns {ndarray} input matrix\n*/\nfunction diagonal( matrix, v ) {\n\tvar M = matrix.shape[ 0 ];\n\tvar i;\n\tfor ( i = 0; i < M; i++ ) {\n\t\tmatrix.set( i, i, v );\n\t}\n\treturn matrix;\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 a sample Pearson product-moment correlation matrix.\n*\n* ## Method\n*\n* - For each sample Pearson product-moment correlation coefficient, 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* - To calculate the corrected sample standard deviation, we can use Welford's method, which can be derived as follows. We can express the variance as\n*\n* ```tex\n* \\begin{align*}\n* S_n &= n \\sigma_n^2 \\\\\n* &= \\sum_{i=1}^{n} (x_i - \\mu_n)^2 \\\\\n* &= \\biggl(\\sum_{i=1}^{n} x_i^2 \\biggr) - n\\mu_n^2\n* \\end{align*}\n* ```\n*\n* Accordingly,\n*\n* ```tex\n* \\begin{align*}\n* S_n - S_{n-1} &= \\sum_{i=1}^{n} x_i^2 - n\\mu_n^2 - \\sum_{i=1}^{n-1} x_i^2 + (n-1)\\mu_{n-1}^2 \\\\\n* &= x_n^2 - n\\mu_n^2 + (n-1)\\mu_{n-1}^2 \\\\\n* &= x_n^2 - \\mu_{n-1}^2 + n(\\mu_{n-1}^2 - \\mu_n^2) \\\\\n* &= x_n^2 - \\mu_{n-1}^2 + n(\\mu_{n-1} - \\mu_n)(\\mu_{n-1} + \\mu_n) \\\\\n* &= x_n^2 - \\mu_{n-1}^2 + (\\mu_{n-1} - x_n)(\\mu_{n-1} + \\mu_n) \\\\\n* &= x_n^2 - \\mu_{n-1}^2 + \\mu_{n-1}^2 - x_n\\mu_n - x_n\\mu_{n-1} + \\mu_n\\mu_{n-1} \\\\\n* &= x_n^2 - x_n\\mu_n - x_n\\mu_{n-1} + \\mu_n\\mu_{n-1} \\\\\n* &= (x_n - \\mu_{n-1})(x_n - \\mu_n) \\\\\n* &= S_{n-1} + (x_n - \\mu_{n-1})(x_n - \\mu_n)\n* \\end{align*}\n* ```\n*\n* where we use the identity\n*\n* ```tex\n* x_n - \\mu_{n-1} = n (\\mu_n - \\mu_{n-1})\n* ```\n*\n* - To compute the corrected sample standard deviation, we apply Bessel's correction and take the square root.\n*\n* - The sample Pearson product-moment correlation coefficient can thus be calculated as\n*\n* ```tex\n* r = \\frac{\\operatorname{cov}_n(x,y)}{\\sigma_x \\sigma_y}\n* ```\n*\n* where \\\\(\\sigma_x\\\\) and \\\\(\\sigma_y\\\\) are the corrected sample standard deviations for \\\\(x\\\\) and \\\\(y\\\\), respectively.\n*\n* @param {(PositiveInteger|ndarray)} out - order of the correlation matrix or a square 2-dimensional output ndarray for storing the correlation 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 correlation 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 correlation 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 corr = ndarray( 'float64', buffer, shape, strides, offset, order );\n*\n* // Create a correlation matrix accumulator:\n* var accumulator = incrpcorrmat( corr );\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 === corr );\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 correlation matrix:\n* out = accumulator();\n* // returns <ndarray>\n*/\nfunction incrpcorrmat( out, means ) {\n\tvar order;\n\tvar corr;\n\tvar M2;\n\tvar sd;\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\tcorr = createMatrix( order, false );\n\t} else if ( isSquareMatrix( out ) ) {\n\t\torder = out.shape[ 0 ];\n\t\tcorr = out;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must either specify the order of the correlation matrix or be a square two-dimensional ndarray for storing the correlation matrix. Value: `%s`.', out ) );\n\t}\n\t// Set the values along the correlation matrix diagonal to `1` (i.e., a random variable is always perfectly correlated with itself):\n\tcorr = diagonal( corr, 1.0 );\n\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 scratch array for storing second moments:\n\tM2 = new Float64Array( order );\n\n\t// Create a scratch array for storing standard deviations:\n\tsd = 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( 'invalid argument. The number of elements (means) in the second argument must match correlation matrix dimensions. Expected: '+order+'. Actual: '+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 sample correlation matrix. If not provided a data vector, the accumulator function returns the current sample correlation 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 correlation matrix dimensions\n\t* @returns {(ndarray|null)} sample correlation matrix or null\n\t*/\n\tfunction accumulator1( v ) {\n\t\tvar denom;\n\t\tvar rdx;\n\t\tvar cij;\n\t\tvar rij;\n\t\tvar sdi;\n\t\tvar di;\n\t\tvar vi;\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 corr;\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 correlation 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\tif ( N === 1 ) {\n\t\t\tfor ( i = 0; i < order; i++ ) {\n\t\t\t\tvi = v.get( i );\n\t\t\t\tm = mu.get( i );\n\n\t\t\t\t// Compute the residual:\n\t\t\t\tdi = vi - m;\n\n\t\t\t\t// Update the sample mean:\n\t\t\t\tm += di / N;\n\t\t\t\tmu.set( i, m );\n\n\t\t\t\t// Update the sample standard deviation:\n\t\t\t\td[ i ] = di;\n\t\t\t\tM2[ i ] += di * ( vi-m );\n\t\t\t\tsd[ i ] = sqrt( M2[i]/denom );\n\n\t\t\t\t// Update the co-moments and correlation matrix, recognizing that the matrices are symmetric...\n\t\t\t\trdx = r * d[i]; // if `n=0`, `r=0.0`\n\t\t\t\tfor ( j = 0; j < i; j++ ) {\n\t\t\t\t\tcij = C.get( i, j ) + ( rdx*d[j] );\n\t\t\t\t\tC.set( i, j, cij );\n\t\t\t\t\tC.set( j, i, cij ); // via symmetry\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor ( i = 0; i < order; i++ ) {\n\t\t\t\tvi = v.get( i );\n\t\t\t\tm = mu.get( i );\n\n\t\t\t\t// Compute the residual:\n\t\t\t\tdi = vi - m;\n\n\t\t\t\t// Update the sample mean:\n\t\t\t\tm += di / N;\n\t\t\t\tmu.set( i, m );\n\n\t\t\t\t// Update the sample standard deviation:\n\t\t\t\td[ i ] = di;\n\t\t\t\tM2[ i ] += di * ( vi-m );\n\t\t\t\tsd[ i ] = sqrt( M2[i]/denom );\n\n\t\t\t\trdx = r * d[i];\n\t\t\t\tsdi = sd[ i ];\n\t\t\t\tfor ( j = 0; j < i; j++ ) {\n\t\t\t\t\tcij = C.get( i, j ) + ( rdx*d[j] );\n\t\t\t\t\tC.set( i, j, cij );\n\t\t\t\t\tC.set( j, i, cij ); // via symmetry\n\n\t\t\t\t\trij = ( cij/denom ) / ( sdi*sd[j] );\n\t\t\t\t\tcorr.set( i, j, rij );\n\t\t\t\t\tcorr.set( j, i, rij ); // via symmetry\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn corr;\n\t}\n\n\t/**\n\t* If provided a data vector, the accumulator function returns an updated sample correlation matrix. If not provided a data vector, the accumulator function returns the current sample correlation 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 correlation matrix dimensions\n\t* @returns {(ndarray|null)} sample correlation matrix or null\n\t*/\n\tfunction accumulator2( v ) {\n\t\tvar rij;\n\t\tvar cij;\n\t\tvar sdi;\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 corr;\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 correlation 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\tdi = v.get( i ) - mu.get( i );\n\t\t\td[ i ] = di;\n\n\t\t\t// Update the standard deviation:\n\t\t\tM2[ i ] += di * di;\n\t\t\tsd[ i ] = sqrt( M2[i]/N );\n\n\t\t\t// Update the co-moments and correlation matrix, recognizing that the matrices are symmetric...\n\t\t\tsdi = sd[ 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\trij = ( cij/N ) / ( sdi*sd[j] );\n\t\t\t\tcorr.set( i, j, rij );\n\t\t\t\tcorr.set( j, i, rij ); // via symmetry\n\t\t\t}\n\t\t}\n\t\treturn corr;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrpcorrmat;\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 a sample Pearson product-moment correlation matrix incrementally.\n*\n* @module @stdlib/stats-incr-pcorrmat\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var incrpcorrmat = require( '@stdlib/stats-incr-pcorrmat' );\n*\n* // Create an output correlation 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 corr = ndarray( 'float64', buffer, shape, strides, offset, order );\n*\n* // Create a correlation matrix accumulator:\n* var accumulator = incrpcorrmat( corr );\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 === corr );\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 correlation 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": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAoB,QAAS,oCAAqC,EAAE,YACpEC,EAAiB,QAAS,iCAAkC,EAC5DC,EAAe,QAAS,+BAAgC,EACxDC,EAAe,QAAS,uBAAwB,EAChDC,EAAS,QAAS,uBAAwB,EAC1CC,EAAO,QAAS,gCAAiC,EACjDC,EAAO,QAAS,sBAAuB,EACvCC,EAAQ,QAAS,2BAA4B,EAC7CC,EAAQ,QAAS,4BAA6B,EAalD,SAASC,EAAcC,EAAGC,EAAO,CAChC,IAAIC,EACAC,EACAC,EACAC,EAEJ,OAAKJ,EACJI,EAAIR,EAEJQ,EAAIT,EAELO,EAAS,IAAIV,EAAcO,EAAEA,CAAE,EAC/BI,EAAQ,CAAEJ,EAAGA,CAAE,EACfE,EAAU,CAAEF,EAAG,CAAE,EACVK,EAAG,UAAWF,EAAQC,EAAOF,EAAS,EAAG,WAAY,CAC7D,CAUA,SAASI,EAAUC,EAAQC,EAAI,CAC9B,IAAIC,EAAIF,EAAO,MAAO,CAAE,EACpBG,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAGC,IACnBH,EAAO,IAAKG,EAAGA,EAAGF,CAAE,EAErB,OAAOD,CACR,CASA,SAASI,EAAcC,EAAI,CAC1B,IAAIV,EACAC,EACAC,EAEJ,OAAAD,EAAS,IAAIV,EAAcmB,CAAE,EAC7BR,EAAQ,CAAEQ,CAAE,EACZV,EAAU,CAAE,CAAE,EAEPL,EAAO,UAAWM,EAAQC,EAAOF,EAAS,EAAG,WAAY,CACjE,CAoKA,SAASW,EAAcC,EAAKC,EAAQ,CACnC,IAAIC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAV,EAGJ,GADAA,EAAI,EACCtB,EAAmBwB,CAAI,EAC3BE,EAAQF,EACRG,EAAOlB,EAAciB,EAAO,EAAM,UACvBzB,EAAgBuB,CAAI,EAC/BE,EAAQF,EAAI,MAAO,CAAE,EACrBG,EAAOH,MAEP,OAAM,IAAI,UAAWpB,EAAQ,mLAAoLoB,CAAI,CAAE,EAiBxN,GAdAG,EAAOX,EAAUW,EAAM,CAAI,EAG3BK,EAAI,IAAI7B,EAAcuB,CAAM,EAG5BE,EAAK,IAAIzB,EAAcuB,CAAM,EAG7BG,EAAK,IAAI1B,EAAcuB,CAAM,EAG7BK,EAAItB,EAAciB,EAAO,EAAK,EAEzB,UAAU,OAAS,EAAI,CAC3B,GAAK,CAACxB,EAAcuB,CAAM,EACzB,MAAM,IAAI,UAAWrB,EAAQ,oFAAqFqB,CAAM,CAAE,EAE3H,GAAKjB,EAAOiB,EAAM,KAAM,IAAMC,EAC7B,MAAM,IAAI,MAAO,+HAA+HA,EAAM,aAAalB,EAAOiB,EAAM,KAAM,EAAE,GAAI,EAE7L,OAAAK,EAAKL,EACEQ,CACR,CAEA,OAAAH,EAAKT,EAAcK,CAAM,EAElBQ,EAWP,SAASA,EAAchB,EAAI,CAC1B,IAAIiB,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAhC,EACAiC,EACAvB,EACAwB,EACJ,GAAK,UAAU,SAAW,EACzB,OAAKtB,IAAM,EACH,KAEDK,EAER,GAAK,CAACzB,EAAcgB,CAAE,EACrB,MAAM,IAAI,UAAWd,EAAQ,yEAA0Ec,CAAE,CAAE,EAE5G,GAAKA,EAAE,MAAO,CAAE,IAAMQ,EACrB,MAAM,IAAI,MAAOtB,EAAQ,0GAA2GsB,EAAOR,EAAE,MAAO,CAAE,CAAE,CAAE,EAQ3J,GANAR,EAAIY,EACJA,GAAK,EACLqB,EAAIjC,EAAIY,EAERa,EAAQzB,GAAK,EAERY,IAAM,EACV,IAAMF,EAAI,EAAGA,EAAIM,EAAON,IAkBvB,IAjBAqB,EAAKvB,EAAE,IAAKE,CAAE,EACdsB,EAAIZ,EAAG,IAAKV,CAAE,EAGdoB,EAAKC,EAAKC,EAGVA,GAAKF,EAAKlB,EACVQ,EAAG,IAAKV,EAAGsB,CAAE,EAGbV,EAAGZ,CAAE,EAAIoB,EACTZ,EAAIR,CAAE,GAAKoB,GAAOC,EAAGC,GACrBb,EAAIT,CAAE,EAAIf,EAAMuB,EAAGR,CAAC,EAAEe,CAAM,EAG5BC,EAAMO,EAAIX,EAAEZ,CAAC,EACPwB,EAAI,EAAGA,EAAIxB,EAAGwB,IACnBP,EAAMN,EAAE,IAAKX,EAAGwB,CAAE,EAAMR,EAAIJ,EAAEY,CAAC,EAC/Bb,EAAE,IAAKX,EAAGwB,EAAGP,CAAI,EACjBN,EAAE,IAAKa,EAAGxB,EAAGiB,CAAI,MAInB,KAAMjB,EAAI,EAAGA,EAAIM,EAAON,IAkBvB,IAjBAqB,EAAKvB,EAAE,IAAKE,CAAE,EACdsB,EAAIZ,EAAG,IAAKV,CAAE,EAGdoB,EAAKC,EAAKC,EAGVA,GAAKF,EAAKlB,EACVQ,EAAG,IAAKV,EAAGsB,CAAE,EAGbV,EAAGZ,CAAE,EAAIoB,EACTZ,EAAIR,CAAE,GAAKoB,GAAOC,EAAGC,GACrBb,EAAIT,CAAE,EAAIf,EAAMuB,EAAGR,CAAC,EAAEe,CAAM,EAE5BC,EAAMO,EAAIX,EAAEZ,CAAC,EACbmB,EAAMV,EAAIT,CAAE,EACNwB,EAAI,EAAGA,EAAIxB,EAAGwB,IACnBP,EAAMN,EAAE,IAAKX,EAAGwB,CAAE,EAAMR,EAAIJ,EAAEY,CAAC,EAC/Bb,EAAE,IAAKX,EAAGwB,EAAGP,CAAI,EACjBN,EAAE,IAAKa,EAAGxB,EAAGiB,CAAI,EAEjBC,EAAQD,EAAIF,GAAYI,EAAIV,EAAGe,CAAC,GAChCjB,EAAK,IAAKP,EAAGwB,EAAGN,CAAI,EACpBX,EAAK,IAAKiB,EAAGxB,EAAGkB,CAAI,EAIvB,OAAOX,CACR,CAWA,SAASM,EAAcf,EAAI,CAC1B,IAAIoB,EACAD,EACAE,EACAC,EACA,EACAI,EACJ,GAAK,UAAU,SAAW,EACzB,OAAKtB,IAAM,EACH,KAEDK,EAER,GAAK,CAACzB,EAAcgB,CAAE,EACrB,MAAM,IAAI,UAAWd,EAAQ,yEAA0Ec,CAAE,CAAE,EAE5G,GAAKA,EAAE,MAAO,CAAE,IAAMQ,EACrB,MAAM,IAAI,MAAOtB,EAAQ,0GAA2GsB,EAAOR,EAAE,MAAO,CAAE,CAAE,CAAE,EAG3J,IADAI,GAAK,EACC,EAAI,EAAG,EAAII,EAAO,IAWvB,IATAc,EAAKtB,EAAE,IAAK,CAAE,EAAIY,EAAG,IAAK,CAAE,EAC5BE,EAAG,CAAE,EAAIQ,EAGTZ,EAAI,CAAE,GAAKY,EAAKA,EAChBX,EAAI,CAAE,EAAIxB,EAAMuB,EAAG,CAAC,EAAEN,CAAE,EAGxBiB,EAAMV,EAAI,CAAE,EACNe,EAAI,EAAGA,EAAI,EAAGA,IACnBP,EAAMN,EAAE,IAAK,EAAGa,CAAE,EAAMJ,EAAGR,EAAEY,CAAC,EAC9Bb,EAAE,IAAK,EAAGa,EAAGP,CAAI,EACjBN,EAAE,IAAKa,EAAG,EAAGP,CAAI,EAEjBC,EAAQD,EAAIf,GAAQiB,EAAIV,EAAGe,CAAC,GAC5BjB,EAAK,IAAK,EAAGiB,EAAGN,CAAI,EACpBX,EAAK,IAAKiB,EAAG,EAAGN,CAAI,EAGtB,OAAOX,CACR,CACD,CAKA5B,EAAO,QAAUwB,ICpYjB,IAAIsB,EAAO,IAKX,OAAO,QAAUA",
|
|
6
|
+
"names": ["require_main", "__commonJSMin", "exports", "module", "isPositiveInteger", "isSquareMatrix", "isVectorLike", "Float64Array", "format", "sqrt", "ctor", "bctor", "numel", "createMatrix", "n", "bool", "strides", "buffer", "shape", "f", "diagonal", "matrix", "v", "M", "i", "createVector", "N", "incrpcorrmat", "out", "means", "order", "corr", "M2", "sd", "mu", "C", "d", "accumulator2", "accumulator1", "denom", "rdx", "cij", "rij", "sdi", "di", "vi", "m", "r", "j", "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 correlation 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 incrpcorrmat( out: number | ndarray, means?: ndarray ): accumulator;
|
|
91
|
+
declare function incrpcorrmat( out: number | ndarray, means?: ndarray ): accumulator;
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
// EXPORTS //
|
package/lib/index.js
CHANGED
package/lib/main.js
CHANGED
|
@@ -24,6 +24,7 @@ var isPositiveInteger = require( '@stdlib/assert-is-positive-integer' ).isPrimit
|
|
|
24
24
|
var isSquareMatrix = require( '@stdlib/assert-is-square-matrix' );
|
|
25
25
|
var isVectorLike = require( '@stdlib/assert-is-vector-like' );
|
|
26
26
|
var Float64Array = require( '@stdlib/array-float64' );
|
|
27
|
+
var format = require( '@stdlib/string-format' );
|
|
27
28
|
var sqrt = require( '@stdlib/math-base-special-sqrt' );
|
|
28
29
|
var ctor = require( '@stdlib/ndarray-ctor' );
|
|
29
30
|
var bctor = require( '@stdlib/ndarray-base-ctor' );
|
|
@@ -273,7 +274,7 @@ function incrpcorrmat( out, means ) {
|
|
|
273
274
|
order = out.shape[ 0 ];
|
|
274
275
|
corr = out;
|
|
275
276
|
} else {
|
|
276
|
-
throw new TypeError( 'invalid argument. First argument must either specify the order of the correlation matrix or be a square
|
|
277
|
+
throw new TypeError( format( 'invalid argument. First argument must either specify the order of the correlation matrix or be a square two-dimensional ndarray for storing the correlation matrix. Value: `%s`.', out ) );
|
|
277
278
|
}
|
|
278
279
|
// Set the values along the correlation matrix diagonal to `1` (i.e., a random variable is always perfectly correlated with itself):
|
|
279
280
|
corr = diagonal( corr, 1.0 );
|
|
@@ -292,7 +293,7 @@ function incrpcorrmat( out, means ) {
|
|
|
292
293
|
|
|
293
294
|
if ( arguments.length > 1 ) {
|
|
294
295
|
if ( !isVectorLike( means ) ) {
|
|
295
|
-
throw new TypeError( 'invalid argument. Second argument must be a
|
|
296
|
+
throw new TypeError( format( 'invalid argument. Second argument must be a one-dimensional ndarray. Value: `%s`.', means ) );
|
|
296
297
|
}
|
|
297
298
|
if ( numel( means.shape ) !== order ) {
|
|
298
299
|
throw new Error( 'invalid argument. The number of elements (means) in the second argument must match correlation matrix dimensions. Expected: '+order+'. Actual: '+numel( means.shape )+'.' );
|
|
@@ -334,10 +335,10 @@ function incrpcorrmat( out, means ) {
|
|
|
334
335
|
return corr;
|
|
335
336
|
}
|
|
336
337
|
if ( !isVectorLike( v ) ) {
|
|
337
|
-
throw new TypeError( 'invalid argument. Must provide a
|
|
338
|
+
throw new TypeError( format( 'invalid argument. Must provide a one-dimensional ndarray. Value: `%s`.', v ) );
|
|
338
339
|
}
|
|
339
340
|
if ( v.shape[ 0 ] !== order ) {
|
|
340
|
-
throw new Error( 'invalid argument. Vector length must match correlation matrix dimensions. Expected:
|
|
341
|
+
throw new Error( format( 'invalid argument. Vector length must match correlation matrix dimensions. Expected: `%u`. Actual: `%u`.', order, v.shape[ 0 ] ) );
|
|
341
342
|
}
|
|
342
343
|
n = N;
|
|
343
344
|
N += 1;
|
|
@@ -426,10 +427,10 @@ function incrpcorrmat( out, means ) {
|
|
|
426
427
|
return corr;
|
|
427
428
|
}
|
|
428
429
|
if ( !isVectorLike( v ) ) {
|
|
429
|
-
throw new TypeError( 'invalid argument. Must provide a
|
|
430
|
+
throw new TypeError( format( 'invalid argument. Must provide a one-dimensional ndarray. Value: `%s`.', v ) );
|
|
430
431
|
}
|
|
431
432
|
if ( v.shape[ 0 ] !== order ) {
|
|
432
|
-
throw new Error( 'invalid argument. Vector length must match correlation matrix dimensions. Expected:
|
|
433
|
+
throw new Error( format( 'invalid argument. Vector length must match correlation matrix dimensions. Expected: `%u`. Actual: `%u`.', order, v.shape[ 0 ] ) );
|
|
433
434
|
}
|
|
434
435
|
N += 1;
|
|
435
436
|
for ( i = 0; i < order; i++ ) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-incr-pcorrmat",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Compute a sample Pearson product-moment correlation matrix incrementally.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,25 +37,28 @@
|
|
|
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/math-base-special-sqrt": "^0.0
|
|
45
|
-
"@stdlib/ndarray-base-ctor": "^0.0
|
|
46
|
-
"@stdlib/ndarray-base-numel": "^0.0
|
|
47
|
-
"@stdlib/ndarray-ctor": "^0.0
|
|
48
|
-
"@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/math-base-special-sqrt": "^0.2.0",
|
|
45
|
+
"@stdlib/ndarray-base-ctor": "^0.2.0",
|
|
46
|
+
"@stdlib/ndarray-base-numel": "^0.2.0",
|
|
47
|
+
"@stdlib/ndarray-ctor": "^0.2.0",
|
|
48
|
+
"@stdlib/string-format": "^0.2.0",
|
|
49
|
+
"@stdlib/types": "^0.3.1",
|
|
50
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.2.0"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@stdlib/assert-is-symmetric-matrix": "^0.0
|
|
52
|
-
"@stdlib/
|
|
53
|
-
"@stdlib/
|
|
54
|
-
"@stdlib/
|
|
55
|
-
"@stdlib/random-base-randu": "^0.0.x",
|
|
53
|
+
"@stdlib/assert-is-symmetric-matrix": "^0.2.0",
|
|
54
|
+
"@stdlib/constants-float64-eps": "^0.2.0",
|
|
55
|
+
"@stdlib/math-base-special-abs": "^0.2.0",
|
|
56
|
+
"@stdlib/random-base-randu": "^0.1.0",
|
|
56
57
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
57
58
|
"istanbul": "^0.4.1",
|
|
58
|
-
"tap-
|
|
59
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git",
|
|
60
|
+
"@stdlib/bench-harness": "^0.2.0",
|
|
61
|
+
"@stdlib/bench": "^0.3.1"
|
|
59
62
|
},
|
|
60
63
|
"engines": {
|
|
61
64
|
"node": ">=0.10.0",
|
|
@@ -98,7 +101,7 @@
|
|
|
98
101
|
"accumulator"
|
|
99
102
|
],
|
|
100
103
|
"funding": {
|
|
101
|
-
"type": "
|
|
102
|
-
"url": "https://
|
|
104
|
+
"type": "opencollective",
|
|
105
|
+
"url": "https://opencollective.com/stdlib"
|
|
103
106
|
}
|
|
104
107
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( out[, means] )
|
|
3
|
-
Returns an accumulator function which incrementally computes a sample
|
|
4
|
-
Pearson product-moment correlation matrix.
|
|
5
|
-
|
|
6
|
-
If provided a data vector, the accumulator function returns an updated
|
|
7
|
-
sample correlation matrix. If not provided a data vector, the accumulator
|
|
8
|
-
function returns the current sample correlation matrix.
|
|
9
|
-
|
|
10
|
-
Parameters
|
|
11
|
-
----------
|
|
12
|
-
out: integer|ndarray
|
|
13
|
-
Order of the correlation matrix or a square 2-dimensional ndarray for
|
|
14
|
-
storing the correlation 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 incrpcorrmat = 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
|
-
incrpcorrmat( cov ); // $ExpectType accumulator
|
|
36
|
-
incrpcorrmat( 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
|
-
incrpcorrmat( 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
|
-
incrpcorrmat( '5' ); // $ExpectError
|
|
51
|
-
incrpcorrmat( true ); // $ExpectError
|
|
52
|
-
incrpcorrmat( false ); // $ExpectError
|
|
53
|
-
incrpcorrmat( null ); // $ExpectError
|
|
54
|
-
incrpcorrmat( undefined ); // $ExpectError
|
|
55
|
-
incrpcorrmat( [] ); // $ExpectError
|
|
56
|
-
incrpcorrmat( {} ); // $ExpectError
|
|
57
|
-
incrpcorrmat( ( 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
|
-
incrpcorrmat( 2, '5' ); // $ExpectError
|
|
63
|
-
incrpcorrmat( 2, true ); // $ExpectError
|
|
64
|
-
incrpcorrmat( 2, false ); // $ExpectError
|
|
65
|
-
incrpcorrmat( 2, null ); // $ExpectError
|
|
66
|
-
incrpcorrmat( 2, [] ); // $ExpectError
|
|
67
|
-
incrpcorrmat( 2, {} ); // $ExpectError
|
|
68
|
-
incrpcorrmat( 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
|
-
incrpcorrmat(); // $ExpectError
|
|
89
|
-
incrpcorrmat( cov, means, {} ); // $ExpectError
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// The function returns an accumulator function which returns an accumulated result...
|
|
93
|
-
{
|
|
94
|
-
const acc = incrpcorrmat( 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 = incrpcorrmat( 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 = incrpcorrmat( 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 = incrpcorrmat( 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
|
-
}
|