diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/README.md b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/README.md
new file mode 100644
index 000000000000..5f1f28901f2a
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/README.md
@@ -0,0 +1,215 @@
+
+
+# incrnanmpcorr2
+
+> Compute a moving squared sample [Pearson product-moment correlation coefficient][pearson-correlation] incrementally, ignoring `NaN` values.
+
+
+
+The [Pearson product-moment correlation coefficient][pearson-correlation] between random variables `X` and `Y` is defined as
+
+
+
+```math
+\rho_{X,Y} = \frac{\mathop{\mathrm{cov}}(X,Y)}{\sigma_X \sigma_Y}
+```
+
+
+
+
+
+where the numerator is the [covariance][covariance] and the denominator is the product of the respective standard deviations.
+
+For a sample of size `W`, the sample [Pearson product-moment correlation coefficient][pearson-correlation] is defined as
+
+
+
+```math
+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} \displaystyle\sqrt{\displaystyle\sum_{i=0}^{n-1} (y_i - \bar{y})^2}}
+```
+
+
+
+
+
+The squared sample [Pearson product-moment correlation coefficient][pearson-correlation] is thus defined as the square of the sample [Pearson product-moment correlation coefficient][pearson-correlation].
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var incrnanmpcorr2 = require( '@stdlib/stats/incr/nanmpcorr2' );
+```
+
+#### incrnanmpcorr2( window\[, mx, my] )
+
+Returns an accumulator `function` which incrementally computes a moving squared sample [Pearson product-moment correlation coefficient][pearson-correlation], ignoring `NaN` values. The `window` parameter defines the number of values over which to compute the moving squared sample [Pearson product-moment correlation coefficient][pearson-correlation].
+
+```javascript
+var accumulator = incrnanmpcorr2( 3 );
+```
+
+If means are already known, provide `mx` and `my` arguments.
+
+```javascript
+var accumulator = incrnanmpcorr2( 3, 5.0, -3.14 );
+```
+
+#### accumulator( \[x, y] )
+
+If provided input values `x` and `y`, the accumulator function returns an updated accumulated value. If not provided input values `x` and `y`, the accumulator function returns the current accumulated value.
+
+```javascript
+var accumulator = incrnanmpcorr2( 3 );
+
+var r2 = accumulator();
+// returns null
+
+// Fill the window with valid pairs:
+r2 = accumulator( 2.0, 1.0 ); // [(2.0, 1.0)]
+// returns 0.0
+
+r2 = accumulator( -5.0, 3.14 ); // [(2.0, 1.0), (-5.0, 3.14)]
+// returns ~1.0
+
+// NaN input is ignored (window unchanged):
+r2 = accumulator( NaN, 3.14 ); // [(2.0, 1.0), (-5.0, 3.14)]
+// returns ~1.0
+
+// NaN input is ignored (window unchanged):
+r2 = accumulator( -5.0, NaN ); // [(2.0, 1.0), (-5.0, 3.14)]
+// returns ~1.0
+
+// NaN input is ignored (window unchanged):
+r2 = accumulator( NaN, NaN ); // [(2.0, 1.0), (-5.0, 3.14)]
+// returns ~1.0
+
+// Window reaches size W:
+r2 = accumulator( 3.0, -1.0 ); // [(2.0, 1.0), (-5.0, 3.14), (3.0, -1.0)]
+// returns ~0.86
+
+// Window begins sliding (valid pairs only):
+r2 = accumulator( 5.0, -9.5 ); // [(-5.0, 3.14), (3.0, -1.0), (5.0, -9.5)]
+// returns ~0.74
+
+r2 = accumulator( -5.0, 1.5 ); // [(3.0, -1.0), (5.0, -9.5), (-5.0, 1.5)]
+// returns ~0.64
+
+r2 = accumulator();
+// returns ~0.64
+
+```
+
+
+
+
+
+
+
+## Notes
+
+- Input values are **not** type checked. If provided `NaN` for either input value, the update is ignored and the accumulated value remains unchanged. If non-numeric inputs are possible, you are advised to type check and handle accordingly **before** passing the value to the accumulator function.
+- As `W` valid (x,y) pairs are needed to fill the window buffer, the first `W-1` returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values.
+- In comparison to the sample [Pearson product-moment correlation coefficient][pearson-correlation], the squared sample [Pearson product-moment correlation coefficient][pearson-correlation] is useful for emphasizing strong correlations.
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var randu = require( '@stdlib/random/base/randu' );
+var incrnanmpcorr2 = require( '@stdlib/stats/incr/nanmpcorr2' );
+
+var accumulator;
+var x;
+var y;
+var i;
+
+// Initialize an accumulator:
+accumulator = incrnanmpcorr2( 5 );
+
+// For each simulated datum, update the moving squared sample correlation coefficient...
+for ( i = 0; i < 100; i++ ) {
+ x = randu() * 100.0;
+ y = randu() * 100.0;
+ accumulator( x, y );
+}
+console.log( accumulator() );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[pearson-correlation]: https://en.wikipedia.org/wiki/Pearson_correlation_coefficient
+
+[covariance]: https://en.wikipedia.org/wiki/Covariance
+
+
+
+[@stdlib/stats/incr/mapcorr]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mapcorr
+
+[@stdlib/stats/incr/mpcorr]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/mpcorr
+
+[@stdlib/stats/incr/pcorr2]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/stats/incr/pcorr2
+
+
+
+
+
+
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/benchmark/benchmark.js
new file mode 100644
index 000000000000..87078328bf74
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/benchmark/benchmark.js
@@ -0,0 +1,91 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var bench = require( '@stdlib/bench' );
+var randu = require( '@stdlib/random/base/randu' );
+var pkg = require( './../package.json' ).name;
+var incrnanmpcorr2 = require( './../lib' );
+
+
+// MAIN //
+
+bench( pkg, function benchmark( b ) {
+ var f;
+ var i;
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ f = incrnanmpcorr2( (i%5)+1 );
+ if ( typeof f !== 'function' ) {
+ b.fail( 'should return a function' );
+ }
+ }
+ b.toc();
+ if ( typeof f !== 'function' ) {
+ b.fail( 'should return a function' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::accumulator', function benchmark( b ) {
+ var acc;
+ var v;
+ var i;
+
+ acc = incrnanmpcorr2( 5 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = acc( randu(), randu() );
+ if ( v !== v ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( v !== v ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
+
+bench( pkg+'::accumulator,known_means', function benchmark( b ) {
+ var acc;
+ var v;
+ var i;
+
+ acc = incrnanmpcorr2( 5, 3.0, -1.0 );
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ v = acc( randu(), randu() );
+ if ( v !== v ) {
+ b.fail( 'should not return NaN' );
+ }
+ }
+ b.toc();
+ if ( v !== v ) {
+ b.fail( 'should not return NaN' );
+ }
+ b.pass( 'benchmark finished' );
+ b.end();
+});
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/img/equation_pearson_correlation_coefficient.svg b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/img/equation_pearson_correlation_coefficient.svg
new file mode 100644
index 000000000000..61e3ef3e3500
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/img/equation_pearson_correlation_coefficient.svg
@@ -0,0 +1,48 @@
+
\ No newline at end of file
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/img/equation_sample_pearson_correlation_coefficient.svg b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/img/equation_sample_pearson_correlation_coefficient.svg
new file mode 100644
index 000000000000..31facfed161b
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/img/equation_sample_pearson_correlation_coefficient.svg
@@ -0,0 +1,126 @@
+
\ No newline at end of file
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/repl.txt b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/repl.txt
new file mode 100644
index 000000000000..b5f2610c7fef
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/repl.txt
@@ -0,0 +1,59 @@
+
+{{alias}}( W[, mx, my] )
+ Returns an accumulator function which incrementally computes a moving
+ squared sample Pearson product-moment correlation coefficient, ignoring
+ `NaN` values.
+
+ The `W` parameter defines the number of values over which to compute the
+ moving squared sample correlation coefficient.
+
+ If provided values, the accumulator function returns an updated moving
+ squared sample correlation coefficient. If not provided values, the
+ accumulator function returns the current moving squared sample correlation
+ coefficient.
+
+ As `W` (x,y) pairs are needed to fill the window buffer, the first `W-1`
+ returned values are calculated from smaller sample sizes. Until the window
+ is full, each returned value is calculated from all provided values.
+
+ Parameters
+ ----------
+ W: integer
+ Window size.
+
+ mx: number (optional)
+ Known mean.
+
+ my: number (optional)
+ Known mean.
+
+ Returns
+ -------
+ acc: Function
+ Accumulator function.
+
+ Examples
+ --------
+ > var accumulator = {{alias}}( 3 );
+ > var r2 = accumulator()
+ null
+ > r2 = accumulator( 2.0, 1.0 )
+ 0.0
+ > r2 = accumulator( -5.0, 3.14 )
+ ~1.0
+ > r2 = accumulator( NaN, 3.14 )
+ ~1.0
+ > r2 = accumulator( -5.0, NaN )
+ ~1.0
+ > r2 = accumulator( NaN, NaN )
+ ~1.0
+ > r2 = accumulator( 3.0, -1.0 )
+ ~0.86
+ > r2 = accumulator( 5.0, -9.5 )
+ ~0.74
+ > r2 = accumulator()
+ ~0.74
+
+ See Also
+ --------
+
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/types/index.d.ts
new file mode 100644
index 000000000000..9e562be01561
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/types/index.d.ts
@@ -0,0 +1,98 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+// TypeScript Version: 4.1
+
+///
+
+/**
+* If provided arguments, returns an updated moving squared sample correlation coefficient.
+*
+* @param x - value
+* @param y - value
+* @returns updated moving squared sample correlation coefficient
+*/
+type accumulator = ( x?: number, y?: number ) => number | null;
+
+/**
+* Returns an accumulator function which incrementally computes a moving squared sample Pearson product-moment correlation coefficient, ignoring `NaN` values.
+*
+* ## Notes
+*
+* - The `W` parameter defines the number of values over which to compute the moving squared sample correlation coefficient.
+* - As `W` (x,y) pairs are needed to fill the window buffer, the first `W-1` returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values.
+*
+* @param W - window size
+* @param meanx - mean value
+* @param meany - mean value
+* @throws first argument must be a positive integer
+* @returns accumulator function
+*
+* @example
+* var accumulator = incrnanmpcorr2( 3, -2.0, 10.0 );
+*/
+declare function incrnanmpcorr2( W: number, meanx: number, meany: number ): accumulator;
+
+/**
+* Returns an accumulator function which incrementally computes a moving squared sample Pearson product-moment correlation coefficient, ignoring `NaN` values.
+*
+* ## Notes
+*
+* - The `W` parameter defines the number of values over which to compute the moving squared sample correlation coefficient.
+* - As `W` (x,y) pairs are needed to fill the window buffer, the first `W-1` returned values are calculated from smaller sample sizes. Until the window is full, each returned value is calculated from all provided values.
+*
+* @param W - window size
+* @throws first argument must be a positive integer
+* @returns accumulator function
+*
+* @example
+* var accumulator = incrnanmpcorr2( 3 );
+*
+* var r2 = accumulator();
+* // returns null
+*
+* r2 = accumulator( 2.0, 1.0 );
+* // returns 0.0
+*
+* r2 = accumulator( -5.0, 3.14 );
+* // returns ~1.0
+*
+* r2 = accumulator( NaN, 3.14 );
+* // returns ~1.0
+*
+* r2 = accumulator( -5.0, NaN );
+* // returns ~1.0
+*
+* r2 = accumulator( NaN, NaN );
+* // returns ~1.0
+*
+* r2 = accumulator( 3.0, -1.0 );
+* // returns ~0.86
+*
+* r2 = accumulator( 5.0, -9.5 );
+* // returns ~0.74
+*
+* r2 = accumulator();
+* // returns ~0.74
+*/
+declare function incrnanmpcorr2( W: number ): accumulator;
+
+
+// EXPORTS //
+
+export = incrnanmpcorr2;
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/types/test.ts b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/types/test.ts
new file mode 100644
index 000000000000..02078cdbee9c
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/docs/types/test.ts
@@ -0,0 +1,123 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+import incrnanmpcorr2 = require( './index' );
+
+
+// TESTS //
+
+// The function returns an accumulator function...
+{
+ incrnanmpcorr2( 3 ); // $ExpectType accumulator
+ incrnanmpcorr2( 3, 2.5, 4.5 ); // $ExpectType accumulator
+}
+
+// The compiler throws an error if the function is provided non-numeric arguments...
+{
+ incrnanmpcorr2( 2, '5' ); // $ExpectError
+ incrnanmpcorr2( 2, true ); // $ExpectError
+ incrnanmpcorr2( 2, false ); // $ExpectError
+ incrnanmpcorr2( 2, null ); // $ExpectError
+ incrnanmpcorr2( 2, undefined ); // $ExpectError
+ incrnanmpcorr2( 2, [] ); // $ExpectError
+ incrnanmpcorr2( 2, {} ); // $ExpectError
+ incrnanmpcorr2( 2, ( x: number ): number => x ); // $ExpectError
+
+ incrnanmpcorr2( '5', 4 ); // $ExpectError
+ incrnanmpcorr2( true, 4 ); // $ExpectError
+ incrnanmpcorr2( false, 4 ); // $ExpectError
+ incrnanmpcorr2( null, 4 ); // $ExpectError
+ incrnanmpcorr2( undefined, 4 ); // $ExpectError
+ incrnanmpcorr2( [], 4 ); // $ExpectError
+ incrnanmpcorr2( {}, 4 ); // $ExpectError
+ incrnanmpcorr2( ( x: number ): number => x, 4 ); // $ExpectError
+
+ incrnanmpcorr2( '5', 2.5, 3.5 ); // $ExpectError
+ incrnanmpcorr2( true, 2.5, 3.5 ); // $ExpectError
+ incrnanmpcorr2( false, 2.5, 3.5 ); // $ExpectError
+ incrnanmpcorr2( null, 2.5, 3.5 ); // $ExpectError
+ incrnanmpcorr2( undefined, 2.5, 3.5 ); // $ExpectError
+ incrnanmpcorr2( [], 2.5, 3.5 ); // $ExpectError
+ incrnanmpcorr2( {}, 2.5, 3.5 ); // $ExpectError
+ incrnanmpcorr2( ( x: number ): number => x, 2.5, 3.5 ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an invalid number of arguments...
+{
+ incrnanmpcorr2(); // $ExpectError
+ incrnanmpcorr2( 2, 3 ); // $ExpectError
+ incrnanmpcorr2( 2, 2, 3, 4 ); // $ExpectError
+}
+
+// The function returns an accumulator function which returns an accumulated result...
+{
+ const acc = incrnanmpcorr2( 3 );
+
+ acc(); // $ExpectType number | null
+ acc( 3.14, 2.0 ); // $ExpectType number | null
+}
+
+// The function returns an accumulator function which returns an accumulated result (known means)...
+{
+ const acc = incrnanmpcorr2( 3, 2, -3 );
+
+ acc(); // $ExpectType number | null
+ acc( 3.14, 2.0 ); // $ExpectType number | null
+}
+
+// The compiler throws an error if the returned accumulator function is provided invalid arguments...
+{
+ const acc = incrnanmpcorr2( 3 );
+
+ acc( '5', 1.0 ); // $ExpectError
+ acc( true, 1.0 ); // $ExpectError
+ acc( false, 1.0 ); // $ExpectError
+ acc( null, 1.0 ); // $ExpectError
+ acc( [], 1.0 ); // $ExpectError
+ acc( {}, 1.0 ); // $ExpectError
+ acc( ( x: number ): number => x, 1.0 ); // $ExpectError
+
+ acc( 3.14, '5' ); // $ExpectError
+ acc( 3.14, true ); // $ExpectError
+ acc( 3.14, false ); // $ExpectError
+ acc( 3.14, null ); // $ExpectError
+ acc( 3.14, [] ); // $ExpectError
+ acc( 3.14, {} ); // $ExpectError
+ acc( 3.14, ( x: number ): number => x ); // $ExpectError
+}
+
+// The compiler throws an error if the returned accumulator function is provided invalid arguments (known means)...
+{
+ const acc = incrnanmpcorr2( 3, 2, -3 );
+
+ acc( '5', 1.0 ); // $ExpectError
+ acc( true, 1.0 ); // $ExpectError
+ acc( false, 1.0 ); // $ExpectError
+ acc( null, 1.0 ); // $ExpectError
+ acc( [], 1.0 ); // $ExpectError
+ acc( {}, 1.0 ); // $ExpectError
+ acc( ( x: number ): number => x, 1.0 ); // $ExpectError
+
+ acc( 3.14, '5' ); // $ExpectError
+ acc( 3.14, true ); // $ExpectError
+ acc( 3.14, false ); // $ExpectError
+ acc( 3.14, null ); // $ExpectError
+ acc( 3.14, [] ); // $ExpectError
+ acc( 3.14, {} ); // $ExpectError
+ acc( 3.14, ( x: number ): number => x ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/examples/index.js b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/examples/index.js
new file mode 100644
index 000000000000..4ea47d1042ee
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/examples/index.js
@@ -0,0 +1,45 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+var randu = require( '@stdlib/random/base/randu' );
+var incrnanmpcorr2 = require( './../lib' );
+
+var accumulator;
+var r2;
+var x;
+var y;
+var i;
+
+// Initialize an accumulator:
+accumulator = incrnanmpcorr2( 5 );
+
+// For each simulated datum, update the moving squared sample correlation coefficient...
+console.log( '\nx\ty\tr^2\n' );
+for ( i = 0; i < 100; i++ ) {
+ if ( randu() < 0.2 ) {
+ x = NaN;
+ y = randu() * 100.0;
+ } else {
+ x = randu() * 100.0;
+ y = randu() * 100.0;
+ }
+ r2 = accumulator( x, y );
+ console.log( '%d\t%d\t%d', x.toFixed( 4 ), y.toFixed( 4 ), (r2 === null) ? NaN : r2.toFixed( 4 ) );
+}
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/lib/index.js b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/lib/index.js
new file mode 100644
index 000000000000..9ae93b9db222
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/lib/index.js
@@ -0,0 +1,66 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+/**
+* Compute a moving squared sample Pearson product-moment correlation coefficient incrementally, ignoring `NaN` values.
+*
+* @module @stdlib/stats/incr/nanmpcorr2
+*
+* @example
+* var incrnanmpcorr2 = require( '@stdlib/stats/incr/nanmpcorr2' );
+*
+* var accumulator = incrnanmpcorr2( 3 );
+*
+* var r2 = accumulator();
+* // returns null
+*
+* r2 = accumulator( 2.0, 1.0 );
+* // returns 0.0
+*
+* r2 = accumulator( -5.0, 3.14 );
+* // returns ~1.0
+*
+* r2 = accumulator( NaN, 3.14 );
+* // returns ~1.0
+*
+* r2 = accumulator( -5.0, NaN );
+* // returns ~1.0
+*
+* r2 = accumulator( NaN, NaN );
+* // returns ~1.0
+*
+* r2 = accumulator( 3.0, -1.0 );
+* // returns ~0.86
+*
+* r2 = accumulator( 5.0, -9.5 );
+* // returns ~0.74
+*
+* r2 = accumulator();
+* // returns ~0.74
+*/
+
+// MODULES //
+
+var incrnanmpcorr2 = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = incrnanmpcorr2;
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/lib/main.js b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/lib/main.js
new file mode 100644
index 000000000000..86398e0c49da
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/lib/main.js
@@ -0,0 +1,113 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
+var isNumber = require( '@stdlib/assert/is-number' ).isPrimitive;
+var isnan = require( '@stdlib/math/base/assert/is-nan' );
+var incrmpcorr2 = require( '@stdlib/stats/incr/mpcorr2' );
+var format = require( '@stdlib/string/format' );
+
+
+// MAIN //
+
+/**
+* Returns an accumulator function which incrementally computes a moving squared sample Pearson product-moment correlation coefficient, ignoring `NaN` values.
+*
+* @param {PositiveInteger} W - window size
+* @param {number} [meanx] - mean value
+* @param {number} [meany] - mean value
+* @throws {TypeError} first argument must be a positive integer
+* @throws {TypeError} second argument must be a number
+* @throws {TypeError} third argument must be a number
+* @returns {Function} accumulator function
+*
+* @example
+* var accumulator = incrnanmpcorr2( 3 );
+*
+* var r2 = accumulator();
+* // returns null
+*
+* r2 = accumulator( 2.0, 1.0 );
+* // returns 0.0
+*
+* r2 = accumulator( -5.0, 3.14 );
+* // returns ~1.0
+*
+* r2 = accumulator( NaN, 3.14 );
+* // returns ~1.0
+*
+* r2 = accumulator( -5.0, NaN );
+* // returns ~1.0
+*
+* r2 = accumulator( NaN, NaN );
+* // returns ~1.0
+*
+* r2 = accumulator( 3.0, -1.0 );
+* // returns ~0.86
+*
+* r2 = accumulator( 5.0, -9.5 );
+* // returns ~0.74
+*
+* r2 = accumulator();
+* // returns ~0.74
+*
+* @example
+* var accumulator = incrnanmpcorr2( 3, -2.0, 10.0 );
+*/
+function incrnanmpcorr2( W, meanx, meany ) {
+ var acc;
+ if ( !isPositiveInteger( W ) ) {
+ throw new TypeError( format( 'invalid argument. First argument must be a positive integer. Value: `%s`.', W ) );
+ }
+ if ( arguments.length > 1 ) {
+ if ( !isNumber( meanx ) ) {
+ throw new TypeError( format( 'invalid argument. Second argument must be a number. Value: `%s`.', meanx ) );
+ }
+ if ( !isNumber( meany ) ) {
+ throw new TypeError( format( 'invalid argument. Third argument must be a number. Value: `%s`.', meany ) );
+ }
+ acc = incrmpcorr2( W, meanx, meany );
+ } else {
+ acc = incrmpcorr2( W );
+ }
+ return accumulator;
+
+ /**
+ * If provided a value, the accumulator function returns an updated accumulated value. If not provided a value, the accumulator function returns the current accumulated value.
+ *
+ * @private
+ * @param {number} [x] - input value
+ * @param {number} [y] - input value
+ * @returns {(number|null)} squared sample correlation coefficient or null
+ */
+ function accumulator( x, y ) {
+ if ( arguments.length === 0 || isnan( x ) || isnan( y ) ) {
+ return acc();
+ }
+ return acc( x, y );
+ }
+}
+
+
+// EXPORTS //
+
+module.exports = incrnanmpcorr2;
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/package.json b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/package.json
new file mode 100644
index 000000000000..c6c7edea5091
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/package.json
@@ -0,0 +1,81 @@
+{
+ "name": "@stdlib/stats/incr/nanmpcorr2",
+ "version": "0.0.0",
+ "description": "Compute a moving squared sample Pearson product-moment correlation coefficient incrementally, ignoring `NaN` values.",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdmath",
+ "statistics",
+ "stats",
+ "mathematics",
+ "math",
+ "covariance",
+ "sample covariance",
+ "variance",
+ "unbiased",
+ "var",
+ "correlation",
+ "corr",
+ "pcorr",
+ "pearson",
+ "product-moment",
+ "r-squared",
+ "r2",
+ "bivariate",
+ "incremental",
+ "accumulator",
+ "moving covariance",
+ "moving correlation",
+ "sliding window",
+ "sliding",
+ "window",
+ "moving",
+ "rolling"
+ ]
+}
diff --git a/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/test/test.js b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/test/test.js
new file mode 100644
index 000000000000..4b2e25abdbfe
--- /dev/null
+++ b/lib/node_modules/@stdlib/stats/incr/nanmpcorr2/test/test.js
@@ -0,0 +1,667 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 The Stdlib Authors.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+
+'use strict';
+
+// MODULES //
+
+var tape = require( 'tape' );
+var randu = require( '@stdlib/random/base/randu' );
+var abs = require( '@stdlib/math/base/special/abs' );
+var pow = require( '@stdlib/math/base/special/pow' );
+var sqrt = require( '@stdlib/math/base/special/sqrt' );
+var EPS = require( '@stdlib/constants/float64/eps' );
+var zeros = require( '@stdlib/array/base/zeros' );
+var incrnanmpcorr2 = require( './../lib' );
+
+
+// FUNCTIONS //
+
+/**
+* Computes sample means using Welford's algorithm.
+*
+* @private
+* @param {Array} out - output array
+* @param {ArrayArray} arr - input array
+* @returns {Array} output array
+*/
+function mean( out, arr ) {
+ var delta;
+ var mx;
+ var my;
+ var N;
+ var i;
+
+ mx = 0.0;
+ my = 0.0;
+
+ N = 0;
+ for ( i = 0; i < arr.length; i++ ) {
+ N += 1;
+ delta = arr[i][0] - mx;
+ mx += delta / N;
+ delta = arr[i][1] - my;
+ my += delta / N;
+ }
+ out[ 0 ] = mx;
+ out[ 1 ] = my;
+ return out;
+}
+
+/**
+* Computes standard deviations.
+*
+* @private
+* @param {Array} out - output array
+* @param {ArrayArray} arr - input array
+* @param {number} mx - `x` mean
+* @param {number} my - `y` mean
+* @param {boolean} bool - boolean indicating whether to compute a biased standard deviation
+* @returns {Array} output array
+*/
+function stdev( out, arr, mx, my, bool ) {
+ var delta;
+ var M2x;
+ var M2y;
+ var N;
+ var i;
+
+ M2x = 0.0;
+ M2y = 0.0;
+
+ N = 0;
+ for ( i = 0; i < arr.length; i++ ) {
+ N += 1;
+ delta = arr[i][0] - mx;
+ M2x += delta * delta;
+ delta = arr[i][1] - my;
+ M2y += delta * delta;
+ }
+ if ( bool ) {
+ out[ 0 ] = sqrt( M2x / N );
+ out[ 1 ] = sqrt( M2y / N );
+ return out;
+ }
+ if ( N < 2 ) {
+ out[ 0 ] = 0.0;
+ out[ 1 ] = 0.0;
+ return out;
+ }
+ out[ 0 ] = sqrt( M2x / (N-1) );
+ out[ 1 ] = sqrt( M2y / (N-1) );
+ return out;
+}
+
+/**
+* Computes the covariance using textbook formula.
+*
+* @private
+* @param {ArrayArray} arr - input array
+* @param {number} mx - `x` mean
+* @param {number} my - `y` mean
+* @param {boolean} bool - boolean indicating whether to compute the population covariance
+* @returns {number} covariance
+*/
+function covariance( arr, mx, my, bool ) {
+ var N;
+ var C;
+ var i;
+
+ N = arr.length;
+ C = 0.0;
+ for ( i = 0; i < N; i++ ) {
+ C += ( arr[i][0]-mx ) * ( arr[i][1]-my );
+ }
+ if ( bool ) {
+ return C / N;
+ }
+ if ( N === 1 ) {
+ return 0.0;
+ }
+ return C / (N-1);
+}
+
+/**
+* Computes the squared sample Pearson product-moment correlation coefficient using textbook formula.
+*
+* @private
+* @param {ArrayArray} arr - input array
+* @param {number} mx - `x` mean
+* @param {number} my - `y` mean
+* @param {boolean} bool - boolean indicating whether to compute the population correlation coefficient
+* @returns {number} squared correlation coefficient
+*/
+function pcorr2( arr, mx, my, bool ) {
+ var cov;
+ var sd;
+ var r;
+ if ( bool === false && arr.length < 2 ) {
+ return 0.0;
+ }
+ sd = stdev( [ 0.0, 0.0 ], arr, mx, my, bool );
+ cov = covariance( arr, mx, my, bool );
+ r = cov / ( sd[0]*sd[1] );
+ return r * r;
+}
+
+/**
+* Generates a set of sample datasets.
+*
+* @private
+* @param {PositiveInteger} N - number of datasets
+* @param {PositiveInteger} M - dataset length
+* @param {PositiveInteger} [seed] - PRNG seed
+* @returns {ArrayArray} sample datasets
+*/
+function datasets( N, M, seed ) {
+ var data;
+ var rand;
+ var tmp;
+ var i;
+ var j;
+
+ rand = randu.factory({
+ 'seed': seed || ( randu()*pow( 2.0, 31 ) )|0
+ });
+
+ // Generate datasets consisting of (x,y) pairs of varying value ranges...
+ data = zeros( N );
+ for ( i = 0; i < N; i++ ) {
+ tmp = zeros( M );
+ for ( j = 0; j < M; j++ ) {
+ tmp[ j ] = [
+ rand() * pow( 10.0, i ),
+ rand() * pow( 10.0, i )
+ ];
+ }
+ data[ i ] = tmp;
+ }
+ return data;
+}
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof incrnanmpcorr2, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function throws an error if not provided a positive integer for the window size', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ -5.0,
+ 0.0,
+ 3.14,
+ true,
+ null,
+ void 0,
+ NaN,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ incrnanmpcorr2( value );
+ };
+ }
+});
+
+tape( 'the function throws an error if not provided a positive integer for the window size (known means)', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ -5.0,
+ 0.0,
+ 3.14,
+ true,
+ null,
+ void 0,
+ NaN,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ incrnanmpcorr2( value, 3.0, 3.14 );
+ };
+ }
+});
+
+tape( 'the function throws an error if not provided a number as the mean value', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ incrnanmpcorr2( 3, value, 3.14 );
+ };
+ }
+});
+
+tape( 'the function throws an error if not provided a number as the mean value', function test( t ) {
+ var values;
+ var i;
+
+ values = [
+ '5',
+ true,
+ false,
+ null,
+ void 0,
+ [],
+ {},
+ function noop() {}
+ ];
+
+ for ( i = 0; i < values.length; i++ ) {
+ t.throws( badValue( values[i] ), TypeError, 'throws an error when provided '+values[i] );
+ }
+ t.end();
+
+ function badValue( value ) {
+ return function badValue() {
+ incrnanmpcorr2( 3, 3.14, value );
+ };
+ }
+});
+
+tape( 'the function returns an accumulator function', function test( t ) {
+ t.strictEqual( typeof incrnanmpcorr2( 3 ), 'function', 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function returns an accumulator function (known means)', function test( t ) {
+ t.strictEqual( typeof incrnanmpcorr2( 3, 3.0, 3.14 ), 'function', 'returns expected value' );
+ t.end();
+});
+
+tape( 'the accumulator function computes a moving squared sample Pearson product-moment correlation coefficient incrementally', function test( t ) {
+ var expected;
+ var actual;
+ var delta;
+ var means;
+ var valid;
+ var data;
+ var acc;
+ var arr;
+ var tol;
+ var d;
+ var N;
+ var M;
+ var W;
+ var i;
+ var j;
+ var x;
+ var y;
+
+ N = 10;
+ M = 100;
+ data = datasets( N, M, 123456 );
+
+ // Define the window size:
+ W = 10;
+
+ // For each dataset, compute the actual and expected squared correlation coefficients...
+ for ( i = 0; i < N; i++ ) {
+ d = data[ i ];
+ valid = [];
+
+ acc = incrnanmpcorr2( W );
+ for ( j = 0; j < M; j++ ) {
+ x = d[ j ][ 0 ];
+ y = d[ j ][ 1 ];
+
+ // Inject NaN:
+ if ( j % 7 === 0 ) {
+ x = NaN;
+ }
+ if ( j % 11 === 0 ) {
+ y = NaN;
+ }
+
+ actual = acc( x, y );
+
+ // Track valid (x,y) pairs:
+ if ( x === x && y === y ) {
+ valid.push( [ x, y ] );
+ }
+
+ // Determine expected window:
+ if ( valid.length > W ) {
+ arr = valid.slice( valid.length - W );
+ } else {
+ arr = valid;
+ }
+
+ // If insufficient data, expect null:
+ if ( arr.length === 0 ) {
+ t.strictEqual( actual, null, 'returns null when insufficient valid data. dataset: '+i+'. step: '+j+'.' );
+ continue;
+ }
+
+ means = mean( [ 0.0, 0.0 ], arr );
+ expected = pcorr2( arr, means[ 0 ], means[ 1 ], false );
+
+ if ( actual === expected ) {
+ t.strictEqual( actual, expected, 'returns expected value. dataset: '+i+'. window: '+j+'.' );
+ } else {
+ delta = abs( actual - expected );
+ tol = 5.0e5 * EPS * abs( expected );
+ t.strictEqual( delta < tol, true, 'dataset: '+i+'. window: '+j+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
+ }
+ }
+ }
+ t.end();
+});
+
+tape( 'the accumulator function computes a moving squared sample Pearson product-moment correlation coefficient incrementally (known means)', function test( t ) {
+ var expected;
+ var actual;
+ var means;
+ var delta;
+ var valid;
+ var data;
+ var acc;
+ var arr;
+ var tol;
+ var d;
+ var N;
+ var M;
+ var W;
+ var i;
+ var j;
+ var x;
+ var y;
+
+ N = 10;
+ M = 100;
+ data = datasets( N, M, 123456 );
+
+ // Define the window size:
+ W = 10;
+
+ // For each dataset, compute the actual and expected squared correlation coefficients...
+ for ( i = 0; i < N; i++ ) {
+ d = data[ i ];
+ valid = [];
+ means = mean( [ 0.0, 0.0 ], d );
+ acc = incrnanmpcorr2( W, means[ 0 ], means[ 1 ] );
+ for ( j = 0; j < M; j++ ) {
+ x = d[ j ][ 0 ];
+ y = d[ j ][ 1 ];
+
+ // Inject NaNs:
+ if ( j % 7 === 0 ) {
+ x = NaN;
+ }
+ if ( j % 11 === 0 ) {
+ y = NaN;
+ }
+
+ actual = acc( x, y );
+
+ // Track valid (x,y) pairs:
+ if ( x === x && y === y ) {
+ valid.push( [ x, y ] );
+ }
+
+ // Determine expected window:
+ if ( valid.length > W ) {
+ arr = valid.slice( valid.length - W );
+ }
+ else {
+ arr = valid;
+ }
+
+ // Insufficient valid data:
+ if ( arr.length === 0 ) {
+ t.strictEqual( actual, null, 'returns null when insufficient valid data. dataset: '+i+'. step: '+j+'.' );
+ continue;
+ }
+
+ expected = pcorr2( arr, means[ 0 ], means[ 1 ], true );
+
+ if ( actual === expected ) {
+ t.strictEqual( actual, expected, 'returns expected value. dataset: '+i+'. step: '+j+'.' );
+ }
+ else {
+ delta = abs( actual - expected );
+ tol = 5.0e5 * EPS * abs( expected );
+ t.strictEqual( delta < tol, true, 'dataset: '+i+'. step: '+j+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
+ }
+ }
+ }
+ t.end();
+});
+
+tape( 'if not provided an input value, the accumulator function returns the current squared sample correlation coefficient (unknown means)', function test( t ) {
+ var expected;
+ var actual;
+ var means;
+ var delta;
+ var data;
+ var tol;
+ var acc;
+ var W;
+ var N;
+ var d;
+ var i;
+
+ data = [
+ [ 2.0, 1.0 ],
+ [ -5.0, 3.14 ],
+ [ 3.0, -1.0 ],
+ [ 5.0, -9.5 ]
+ ];
+ N = data.length;
+
+ // Window size:
+ W = 3;
+
+ acc = incrnanmpcorr2( W );
+ for ( i = 0; i < N; i++ ) {
+ acc( data[ i ][ 0 ], data[ i ][ 1 ] );
+ actual = acc();
+ if ( i < W-1 ) {
+ d = data.slice( 0, i+1 );
+ } else {
+ d = data.slice( i-W+1, i+1 );
+ }
+ means = mean( [ 0.0, 0.0 ], d );
+ expected = pcorr2( d, means[ 0 ], means[ 1 ], false );
+ if ( actual === expected ) {
+ t.strictEqual( actual, expected, 'returns expected value. window: '+i+'.' );
+ } else {
+ delta = abs( actual - expected );
+ tol = 2.0 * EPS * abs( expected );
+ t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
+ }
+ }
+ t.end();
+});
+
+tape( 'if not provided an input value, the accumulator function returns the current squared sample correlation coefficient (unknown means, ignoring NaNs)', function test( t ) {
+ var expected;
+ var actual;
+ var means;
+ var delta;
+ var valid;
+ var tol;
+ var acc;
+ var arr;
+ var d;
+ var W;
+ var N;
+ var i;
+ var x;
+ var y;
+
+ d = [
+ [ 2.0, 1.0 ],
+ [ -5.0, 3.14 ],
+ [ 3.0, -1.0 ],
+ [ 5.0, -9.5 ]
+ ];
+ N = d.length;
+
+ // Window size:
+ W = 3;
+
+ acc = incrnanmpcorr2( W );
+ valid = [];
+
+ for ( i = 0; i < N; i++ ) {
+ x = d[ i ][ 0 ];
+ y = d[ i ][ 1 ];
+
+ // Inject NaN:
+ if ( i === 1 ) {
+ x = NaN;
+ }
+
+ acc( x, y );
+ actual = acc();
+
+ // Track valid pairs:
+ if ( x === x && y === y ) {
+ valid.push( [ x, y ] );
+ }
+
+ // Determine expected window:
+ if ( valid.length > W ) {
+ arr = valid.slice( valid.length - W );
+ }
+ else {
+ arr = valid;
+ }
+
+ // No valid data:
+ if ( arr.length === 0 ) {
+ t.strictEqual( actual, null, 'returns null when insufficient valid data. step: '+i+'.' );
+ continue;
+ }
+
+ // One valid pair (unknown means → 0):
+ if ( arr.length === 1 ) {
+ t.strictEqual( actual, 0.0, 'returns 0 when only one valid observation is available. step: '+i+'.' );
+ continue;
+ }
+
+ means = mean( [ 0.0, 0.0 ], arr );
+ expected = pcorr2( arr, means[ 0 ], means[ 1 ], false );
+
+ if ( actual === expected ) {
+ t.strictEqual( actual, expected, 'returns expected value. step: '+i+'.' );
+ }
+ else {
+ delta = abs( actual - expected );
+ tol = 5.0e5 * EPS * abs( expected );
+ t.strictEqual( delta < tol, true, 'step: '+i+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
+ }
+ }
+ t.end();
+});
+
+tape( 'if data has yet to be provided, the accumulator function returns `null`', function test( t ) {
+ var acc = incrnanmpcorr2( 3 );
+ t.strictEqual( acc(), null, 'returns expected value' );
+ t.end();
+});
+
+tape( 'if data has yet to be provided, the accumulator function returns `null` (known means)', function test( t ) {
+ var acc = incrnanmpcorr2( 3, 3.0, 3.14 );
+ t.strictEqual( acc(), null, 'returns expected value' );
+ t.end();
+});
+
+tape( 'if only one datum has been provided and the means are unknown, the accumulator function returns `0`', function test( t ) {
+ var acc = incrnanmpcorr2( 3 );
+ acc( 2.0, 3.14 );
+ t.strictEqual( acc(), 0.0, 'returns expected value' );
+ t.end();
+});
+
+tape( 'if only one datum has been provided and the means are known, the accumulator function may not return `0`', function test( t ) {
+ var acc = incrnanmpcorr2( 3, 30.0, -100.0 );
+ acc( 2.0, 1.0 );
+ t.notEqual( acc(), 0.0, 'does not return 0' );
+ t.end();
+});
+
+tape( 'if the window size is `1` and the means are unknown, the accumulator function always returns `0`', function test( t ) {
+ var acc;
+ var r;
+ var i;
+
+ acc = incrnanmpcorr2( 1 );
+ for ( i = 0; i < 100; i++ ) {
+ r = acc( randu()*100.0, randu()*100.0 );
+ t.strictEqual( r, 0.0, 'returns expected value' );
+ }
+ t.end();
+});
+
+tape( 'if the window size is `1` and the means are known, the accumulator function may not always return `0`', function test( t ) {
+ var acc;
+ var r;
+ var i;
+
+ acc = incrnanmpcorr2( 1, 500.0, -500.0 ); // means are outside the range of simulated values so the correlation should never be zero
+ for ( i = 0; i < 100; i++ ) {
+ r = acc( randu()*100.0, randu()*100.0 );
+ t.notEqual( r, 0.0, 'does not return 0' );
+ }
+ t.end();
+});