@stdlib/stats-incr-pcorrdistmat 0.0.7 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CITATION.cff +30 -0
- package/LICENSE +0 -304
- package/NOTICE +1 -1
- package/README.md +24 -12
- 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 +1 -1
- package/lib/index.js +2 -2
- package/lib/main.js +8 -7
- package/package.json +20 -18
- package/docs/repl.txt +0 -53
- package/docs/types/test.ts +0 -161
package/CITATION.cff
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
title: stdlib
|
|
3
|
+
message: >-
|
|
4
|
+
If you use this software, please cite it using the
|
|
5
|
+
metadata from this file.
|
|
6
|
+
|
|
7
|
+
type: software
|
|
8
|
+
|
|
9
|
+
authors:
|
|
10
|
+
- name: The Stdlib Authors
|
|
11
|
+
url: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
12
|
+
|
|
13
|
+
repository-code: https://github.com/stdlib-js/stdlib
|
|
14
|
+
url: https://stdlib.io
|
|
15
|
+
|
|
16
|
+
abstract: |
|
|
17
|
+
Standard library for JavaScript and Node.js.
|
|
18
|
+
|
|
19
|
+
keywords:
|
|
20
|
+
- JavaScript
|
|
21
|
+
- Node.js
|
|
22
|
+
- TypeScript
|
|
23
|
+
- standard library
|
|
24
|
+
- scientific computing
|
|
25
|
+
- numerical computing
|
|
26
|
+
- statistical computing
|
|
27
|
+
|
|
28
|
+
license: Apache-2.0 AND BSL-1.0
|
|
29
|
+
|
|
30
|
+
date-released: 2016
|
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-2023 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
|
# incrpcorrdistmat
|
|
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] -->
|
|
@@ -219,8 +230,8 @@ for ( i = 0; i < 100; i++ ) {
|
|
|
219
230
|
|
|
220
231
|
## See Also
|
|
221
232
|
|
|
222
|
-
- <span class="package-name">[`@stdlib/stats
|
|
223
|
-
- <span class="package-name">[`@stdlib/stats
|
|
233
|
+
- <span class="package-name">[`@stdlib/stats-incr/pcorrdist`][@stdlib/stats/incr/pcorrdist]</span><span class="delimiter">: </span><span class="description">compute a sample Pearson product-moment correlation distance.</span>
|
|
234
|
+
- <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>
|
|
224
235
|
|
|
225
236
|
</section>
|
|
226
237
|
|
|
@@ -252,7 +263,7 @@ See [LICENSE][stdlib-license].
|
|
|
252
263
|
|
|
253
264
|
## Copyright
|
|
254
265
|
|
|
255
|
-
Copyright © 2016-
|
|
266
|
+
Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors].
|
|
256
267
|
|
|
257
268
|
</section>
|
|
258
269
|
|
|
@@ -265,8 +276,8 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
265
276
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/stats-incr-pcorrdistmat.svg
|
|
266
277
|
[npm-url]: https://npmjs.org/package/@stdlib/stats-incr-pcorrdistmat
|
|
267
278
|
|
|
268
|
-
[test-image]: https://github.com/stdlib-js/stats-incr-pcorrdistmat/actions/workflows/test.yml/badge.svg
|
|
269
|
-
[test-url]: https://github.com/stdlib-js/stats-incr-pcorrdistmat/actions/workflows/test.yml
|
|
279
|
+
[test-image]: https://github.com/stdlib-js/stats-incr-pcorrdistmat/actions/workflows/test.yml/badge.svg?branch=v0.1.0
|
|
280
|
+
[test-url]: https://github.com/stdlib-js/stats-incr-pcorrdistmat/actions/workflows/test.yml?query=branch:v0.1.0
|
|
270
281
|
|
|
271
282
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/stats-incr-pcorrdistmat/main.svg
|
|
272
283
|
[coverage-url]: https://codecov.io/github/stdlib-js/stats-incr-pcorrdistmat?branch=main
|
|
@@ -278,19 +289,20 @@ Copyright © 2016-2022. The Stdlib [Authors][stdlib-authors].
|
|
|
278
289
|
|
|
279
290
|
-->
|
|
280
291
|
|
|
292
|
+
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
293
|
+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
|
|
294
|
+
|
|
295
|
+
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
296
|
+
|
|
297
|
+
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
298
|
+
|
|
281
299
|
[umd]: https://github.com/umdjs/umd
|
|
282
300
|
[es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
|
|
283
301
|
|
|
284
302
|
[deno-url]: https://github.com/stdlib-js/stats-incr-pcorrdistmat/tree/deno
|
|
285
303
|
[umd-url]: https://github.com/stdlib-js/stats-incr-pcorrdistmat/tree/umd
|
|
286
304
|
[esm-url]: https://github.com/stdlib-js/stats-incr-pcorrdistmat/tree/esm
|
|
287
|
-
|
|
288
|
-
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
|
|
289
|
-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
|
|
290
|
-
|
|
291
|
-
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
292
|
-
|
|
293
|
-
[stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
|
|
305
|
+
[branches-url]: https://github.com/stdlib-js/stats-incr-pcorrdistmat/blob/main/branches.md
|
|
294
306
|
|
|
295
307
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/stats-incr-pcorrdistmat/main/LICENSE
|
|
296
308
|
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";var I=function(i,o){return function(){return o||i((o={exports:{}}).exports,o),o.exports}};var S=I(function(K,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'),x=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(i,o){var e,s,c,u;return o?u=F:u=B,s=new E(i*i),c=[i,i],e=[i,1],u("float64",s,c,e,0,"row-major")}function D(i){var o,e,s;return e=new E(i),s=[i],o=[1],F("float64",e,s,o,0,"row-major")}function G(i,o){var e,s,c,u,q,l,h,v;if(v=0,L(i))e=i,s=A(e,!1);else if(z(i))e=i.shape[0],s=i;else throw new TypeError(x('1JdDe',i));if(h=new E(e),c=new E(e),u=new E(e),l=A(e,!0),arguments.length>1){if(!b(o))throw new TypeError(x('1JdDc',o));if(T(o.shape)!==e)throw new Error(x('1Jd9f',e,T(o.shape)));return q=o,C}return q=D(e),k;function k(d){var w,g,m,p,a,t,y,f,j,V,r,n;if(arguments.length===0)return v===0?null:s;if(!b(d))throw new TypeError(x('1JdDd',d));if(d.shape[0]!==e)throw new Error(x('1Jd9g',e,d.shape[0]));if(j=v,v+=1,V=j/v,w=j||1,v===1)for(r=0;r<e;r++)for(y=d.get(r),f=q.get(r),t=y-f,f+=t/v,q.set(r,f),h[r]=t,c[r]+=t*(y-f),u[r]=M(c[r]/w),g=V*h[r],n=0;n<=r;n++)m=l.get(r,n)+g*h[n],l.set(r,n,m),l.set(n,r,m);else for(r=0;r<e;r++)for(y=d.get(r),f=q.get(r),t=y-f,f+=t/v,q.set(r,f),h[r]=t,c[r]+=t*(y-f),u[r]=M(c[r]/w),g=V*h[r],a=u[r],n=0;n<r;n++)m=l.get(r,n)+g*h[n],l.set(r,n,m),l.set(n,r,m),p=1-m/w/(a*u[n]),s.set(r,n,p),s.set(n,r,p);return s}function C(d){var w,g,m,p,a,t;if(arguments.length===0)return v===0?null:s;if(!b(d))throw new TypeError(x('1JdDd',d));if(d.shape[0]!==e)throw new Error(x('1Jd9h',e,d.shape[0]));for(v+=1,a=0;a<e;a++)for(p=d.get(a)-q.get(a),h[a]=p,c[a]+=p*p,u[a]=M(c[a]/v),m=u[a],t=0;t<a;t++)g=l.get(a,t)+p*h[t],l.set(a,t,g),l.set(t,a,g),w=1-g/v/(m*u[t]),s.set(a,t,w),s.set(t,a,w);return s}}P.exports=G
|
|
3
|
+
});var H=S();module.exports=H;
|
|
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* 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 distance matrix.\n*\n* ## Method\n*\n* - For each sample Pearson product-moment correlation distance, 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* - The sample Pearson product-moment correlation distance is defined as\n*\n* ```tex\n* d = 1 - r = 1 - \\frac{\\operatorname{cov}_n(x,y)}{\\sigma_x \\sigma_y}\n* ```\n*\n* - The implementation thus computes each sample Pearson product-moment correlation coefficient \\\\(r\\\\) and subtracts each coefficient from 1.\n*\n* @param {(PositiveInteger|ndarray)} out - order of the correlation distance matrix or a square 2-dimensional output ndarray for storing the correlation distance 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 distance 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 distance 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 dist = ndarray( 'float64', buffer, shape, strides, offset, order );\n*\n* // Create a correlation distance matrix accumulator:\n* var accumulator = incrpcorrdistmat( dist );\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 === dist );\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 distance matrix:\n* out = accumulator();\n* // returns <ndarray>\n*/\nfunction incrpcorrdistmat( out, means ) {\n\tvar order;\n\tvar dist;\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\tdist = createMatrix( order, false );\n\t} else if ( isSquareMatrix( out ) ) {\n\t\torder = out.shape[ 0 ];\n\t\tdist = out;\n\t} else {\n\t\tthrow new TypeError( format( 'invalid argument. First argument must either specify the order of the correlation distance matrix or be a square two-dimensional ndarray for storing the correlation distance 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 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( format( 'invalid argument. The number of elements (means) in the second argument must match correlation distance 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 sample correlation distance matrix. If not provided a data vector, the accumulator function returns the current sample correlation distance 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 distance matrix dimensions\n\t* @returns {(ndarray|null)} sample correlation distance matrix or null\n\t*/\n\tfunction accumulator1( v ) {\n\t\tvar denom;\n\t\tvar rdx;\n\t\tvar cij;\n\t\tvar dij;\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 dist;\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 distance 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\t// Update the co-moments and correlation distance matrix, recognizing that the matrices are symmetric...\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\tdij = 1.0 - ( (cij/denom)/(sdi*sd[j]) );\n\t\t\t\t\tdist.set( i, j, dij );\n\t\t\t\t\tdist.set( j, i, dij ); // via symmetry\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn dist;\n\t}\n\n\t/**\n\t* If provided a data vector, the accumulator function returns an updated sample correlation distance matrix. If not provided a data vector, the accumulator function returns the current sample correlation distance 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 distance matrix dimensions\n\t* @returns {(ndarray|null)} sample correlation distance matrix or null\n\t*/\n\tfunction accumulator2( v ) {\n\t\tvar dij;\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 dist;\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 distance 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\n\t\t\t// Update standard deviation:\n\t\t\td[ i ] = di;\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 distance 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\tdij = 1.0 - ( (cij/N)/(sdi*sd[j]) );\n\t\t\t\tdist.set( i, j, dij );\n\t\t\t\tdist.set( j, i, dij ); // via symmetry\n\t\t\t}\n\t\t}\n\t\treturn dist;\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = incrpcorrdistmat;\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 distance matrix incrementally.\n*\n* @module @stdlib/stats-incr-pcorrdistmat\n*\n* @example\n* var Float64Array = require( '@stdlib/array-float64' );\n* var ndarray = require( '@stdlib/ndarray-ctor' );\n* var incrpcorrdistmat = require( '@stdlib/stats-incr-pcorrdistmat' );\n*\n* // Create an output correlation distance 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 dist = ndarray( 'float64', buffer, shape, strides, offset, order );\n*\n* // Create a correlation distance matrix accumulator:\n* var accumulator = incrpcorrdistmat( dist );\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 === dist );\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 distance 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", "format", "sqrt", "ctor", "bctor", "numel", "createMatrix", "n", "bool", "strides", "buffer", "shape", "f", "createVector", "N", "incrpcorrdistmat", "out", "means", "order", "dist", "M2", "sd", "mu", "C", "d", "accumulator2", "accumulator1", "v", "denom", "rdx", "cij", "dij", "sdi", "di", "vi", "m", "r", "i", "j", "main"]
|
|
7
|
+
}
|
package/docs/types/index.d.ts
CHANGED
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' );
|
|
@@ -264,7 +265,7 @@ function incrpcorrdistmat( out, means ) {
|
|
|
264
265
|
order = out.shape[ 0 ];
|
|
265
266
|
dist = out;
|
|
266
267
|
} else {
|
|
267
|
-
throw new TypeError( 'invalid argument. First argument must either specify the order of the correlation distance matrix or be a square
|
|
268
|
+
throw new TypeError( format( 'invalid argument. First argument must either specify the order of the correlation distance matrix or be a square two-dimensional ndarray for storing the correlation distance matrix. Value: `%s`.', out ) );
|
|
268
269
|
}
|
|
269
270
|
// Create a scratch array for storing residuals (i.e., `x_i - xbar_{i-1}`):
|
|
270
271
|
d = new Float64Array( order );
|
|
@@ -280,10 +281,10 @@ function incrpcorrdistmat( out, means ) {
|
|
|
280
281
|
|
|
281
282
|
if ( arguments.length > 1 ) {
|
|
282
283
|
if ( !isVectorLike( means ) ) {
|
|
283
|
-
throw new TypeError( 'invalid argument. Second argument must be a
|
|
284
|
+
throw new TypeError( format( 'invalid argument. Second argument must be a one-dimensional ndarray. Value: `%s`.', means ) );
|
|
284
285
|
}
|
|
285
286
|
if ( numel( means.shape ) !== order ) {
|
|
286
|
-
throw new Error( 'invalid argument. The number of elements (means) in the second argument must match correlation distance matrix dimensions. Expected:
|
|
287
|
+
throw new Error( format( 'invalid argument. The number of elements (means) in the second argument must match correlation distance matrix dimensions. Expected: `%u`. Actual: `%u`.', order, numel( means.shape ) ) );
|
|
287
288
|
}
|
|
288
289
|
mu = means; // TODO: should we copy this? Otherwise, internal state could be "corrupted" due to mutation outside the accumulator
|
|
289
290
|
return accumulator2;
|
|
@@ -322,10 +323,10 @@ function incrpcorrdistmat( out, means ) {
|
|
|
322
323
|
return dist;
|
|
323
324
|
}
|
|
324
325
|
if ( !isVectorLike( v ) ) {
|
|
325
|
-
throw new TypeError( 'invalid argument. Must provide a
|
|
326
|
+
throw new TypeError( format( 'invalid argument. Must provide a one-dimensional ndarray. Value: `%s`.', v ) );
|
|
326
327
|
}
|
|
327
328
|
if ( v.shape[ 0 ] !== order ) {
|
|
328
|
-
throw new Error( 'invalid argument. Vector length must match correlation matrix dimensions. Expected:
|
|
329
|
+
throw new Error( format( 'invalid argument. Vector length must match correlation matrix dimensions. Expected: `%u`. Actual: `%u`.', order, v.shape[ 0 ] ) );
|
|
329
330
|
}
|
|
330
331
|
n = N;
|
|
331
332
|
N += 1;
|
|
@@ -415,10 +416,10 @@ function incrpcorrdistmat( out, means ) {
|
|
|
415
416
|
return dist;
|
|
416
417
|
}
|
|
417
418
|
if ( !isVectorLike( v ) ) {
|
|
418
|
-
throw new TypeError( 'invalid argument. Must provide a
|
|
419
|
+
throw new TypeError( format( 'invalid argument. Must provide a one-dimensional ndarray. Value: `%s`.', v ) );
|
|
419
420
|
}
|
|
420
421
|
if ( v.shape[ 0 ] !== order ) {
|
|
421
|
-
throw new Error( 'invalid argument. Vector length must match correlation distance matrix dimensions. Expected:
|
|
422
|
+
throw new Error( format( 'invalid argument. Vector length must match correlation distance matrix dimensions. Expected: `%u`. Actual: `%u`.', order, v.shape[ 0 ] ) );
|
|
422
423
|
}
|
|
423
424
|
N += 1;
|
|
424
425
|
for ( i = 0; i < order; i++ ) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stdlib/stats-incr-pcorrdistmat",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Compute a sample Pearson product-moment correlation distance matrix incrementally.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -37,25 +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/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.1.0",
|
|
41
|
+
"@stdlib/assert-is-positive-integer": "^0.1.0",
|
|
42
|
+
"@stdlib/assert-is-square-matrix": "^0.1.0",
|
|
43
|
+
"@stdlib/assert-is-vector-like": "^0.1.0",
|
|
44
|
+
"@stdlib/math-base-special-sqrt": "^0.1.0",
|
|
45
|
+
"@stdlib/ndarray-base-ctor": "^0.1.0",
|
|
46
|
+
"@stdlib/ndarray-base-numel": "^0.1.0",
|
|
47
|
+
"@stdlib/ndarray-ctor": "^0.1.0",
|
|
48
|
+
"@stdlib/string-format": "^0.1.0",
|
|
49
|
+
"@stdlib/types": "^0.1.0",
|
|
50
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.1.0"
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
|
-
"@stdlib/assert-is-symmetric-matrix": "^0.0
|
|
52
|
-
"@stdlib/bench": "^0.0
|
|
53
|
-
"@stdlib/constants-float64-eps": "^0.0
|
|
54
|
-
"@stdlib/math-base-special-abs": "^0.0
|
|
55
|
-
"@stdlib/random-base-randu": "^0.0.
|
|
53
|
+
"@stdlib/assert-is-symmetric-matrix": "^0.1.0",
|
|
54
|
+
"@stdlib/bench": "^0.1.0",
|
|
55
|
+
"@stdlib/constants-float64-eps": "^0.1.0",
|
|
56
|
+
"@stdlib/math-base-special-abs": "^0.1.0",
|
|
57
|
+
"@stdlib/random-base-randu": "^0.0.8",
|
|
56
58
|
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
|
|
57
59
|
"istanbul": "^0.4.1",
|
|
58
|
-
"tap-
|
|
60
|
+
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
|
|
59
61
|
},
|
|
60
62
|
"engines": {
|
|
61
63
|
"node": ">=0.10.0",
|
|
@@ -94,7 +96,7 @@
|
|
|
94
96
|
"accumulator"
|
|
95
97
|
],
|
|
96
98
|
"funding": {
|
|
97
|
-
"type": "
|
|
98
|
-
"url": "https://
|
|
99
|
+
"type": "opencollective",
|
|
100
|
+
"url": "https://opencollective.com/stdlib"
|
|
99
101
|
}
|
|
100
102
|
}
|
package/docs/repl.txt
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
{{alias}}( out[, means] )
|
|
3
|
-
Returns an accumulator function which incrementally computes a sample
|
|
4
|
-
Pearson product-moment correlation distance matrix.
|
|
5
|
-
|
|
6
|
-
If provided a data vector, the accumulator function returns an updated
|
|
7
|
-
sample correlation distance matrix. If not provided a data vector, the
|
|
8
|
-
accumulator function returns the current sample correlation distance matrix.
|
|
9
|
-
|
|
10
|
-
Due to limitations inherent in representing numeric values using floating-
|
|
11
|
-
point format (i.e., the inability to represent numeric values with infinite
|
|
12
|
-
precision), the correlation distance between perfectly correlated random
|
|
13
|
-
variables may *not* be `0` or `2`. In fact, the correlation distance is
|
|
14
|
-
*not* guaranteed to be strictly on the interval [0,2]. Any computed distance
|
|
15
|
-
should, however, be within floating-point roundoff error.
|
|
16
|
-
|
|
17
|
-
Parameters
|
|
18
|
-
----------
|
|
19
|
-
out: integer|ndarray
|
|
20
|
-
Order of the correlation distance matrix or a square 2-dimensional
|
|
21
|
-
ndarray for storing the correlation distance matrix.
|
|
22
|
-
|
|
23
|
-
means: ndarray (optional)
|
|
24
|
-
Known means.
|
|
25
|
-
|
|
26
|
-
Returns
|
|
27
|
-
-------
|
|
28
|
-
acc: Function
|
|
29
|
-
Accumulator function.
|
|
30
|
-
|
|
31
|
-
Examples
|
|
32
|
-
--------
|
|
33
|
-
> var accumulator = {{alias}}( 2 );
|
|
34
|
-
> var out = accumulator()
|
|
35
|
-
<ndarray>
|
|
36
|
-
> var buf = new {{alias:@stdlib/array/float64}}( 2 );
|
|
37
|
-
> var shape = [ 2 ];
|
|
38
|
-
> var strides = [ 1 ];
|
|
39
|
-
> var v = {{alias:@stdlib/ndarray/ctor}}( 'float64', buf, shape, strides, 0, 'row-major' );
|
|
40
|
-
> v.set( 0, 2.0 );
|
|
41
|
-
> v.set( 1, 1.0 );
|
|
42
|
-
> out = accumulator( v )
|
|
43
|
-
<ndarray>
|
|
44
|
-
> v.set( 0, -5.0 );
|
|
45
|
-
> v.set( 1, 3.14 );
|
|
46
|
-
> out = accumulator( v )
|
|
47
|
-
<ndarray>
|
|
48
|
-
> out = accumulator()
|
|
49
|
-
<ndarray>
|
|
50
|
-
|
|
51
|
-
See Also
|
|
52
|
-
--------
|
|
53
|
-
|
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 incrpcorrdistmat = 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
|
-
incrpcorrdistmat( cov ); // $ExpectType accumulator
|
|
36
|
-
incrpcorrdistmat( 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
|
-
incrpcorrdistmat( 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
|
-
incrpcorrdistmat( '5' ); // $ExpectError
|
|
51
|
-
incrpcorrdistmat( true ); // $ExpectError
|
|
52
|
-
incrpcorrdistmat( false ); // $ExpectError
|
|
53
|
-
incrpcorrdistmat( null ); // $ExpectError
|
|
54
|
-
incrpcorrdistmat( undefined ); // $ExpectError
|
|
55
|
-
incrpcorrdistmat( [] ); // $ExpectError
|
|
56
|
-
incrpcorrdistmat( {} ); // $ExpectError
|
|
57
|
-
incrpcorrdistmat( ( 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
|
-
incrpcorrdistmat( 2, '5' ); // $ExpectError
|
|
63
|
-
incrpcorrdistmat( 2, true ); // $ExpectError
|
|
64
|
-
incrpcorrdistmat( 2, false ); // $ExpectError
|
|
65
|
-
incrpcorrdistmat( 2, null ); // $ExpectError
|
|
66
|
-
incrpcorrdistmat( 2, [] ); // $ExpectError
|
|
67
|
-
incrpcorrdistmat( 2, {} ); // $ExpectError
|
|
68
|
-
incrpcorrdistmat( 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
|
-
incrpcorrdistmat(); // $ExpectError
|
|
89
|
-
incrpcorrdistmat( cov, means, {} ); // $ExpectError
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// The function returns an accumulator function which returns an accumulated result...
|
|
93
|
-
{
|
|
94
|
-
const acc = incrpcorrdistmat( 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 = incrpcorrdistmat( 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 = incrpcorrdistmat( 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 = incrpcorrdistmat( 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
|
-
}
|