Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 9 additions & 52 deletions lib/node_modules/@stdlib/stats/incr/mpcorr/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
// MODULES //

var tape = require( 'tape' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var EPS = require( '@stdlib/constants/float64/eps' );
var zeros = require( '@stdlib/array/base/zeros' );
var incrmpcorr = require( './../lib' );

Expand Down Expand Up @@ -329,12 +328,10 @@ tape( 'the function returns an accumulator function (known means)', function tes
tape( 'the accumulator function computes a moving sample Pearson product-moment correlation coefficient incrementally', function test( t ) {
var expected;
var actual;
var delta;
var means;
var data;
var acc;
var arr;
var tol;
var d;
var N;
var M;
Expand All @@ -344,7 +341,7 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment

N = 10;
M = 100;
data = datasets( N, M, randu.seed );
data = datasets( N, M, 123456 );

// Define the window size:
W = 10;
Expand All @@ -363,13 +360,7 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
}
means = mean( [ 0.0, 0.0 ], arr );
expected = pcorr( 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.strictEqual( isAlmostSameValue( actual, expected, 6716 ), true, 'returns expected value' );
}
}
t.end();
Expand All @@ -379,11 +370,9 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
var expected;
var actual;
var means;
var delta;
var data;
var acc;
var arr;
var tol;
var d;
var N;
var M;
Expand All @@ -393,7 +382,7 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment

N = 10;
M = 100;
data = datasets( N, M, randu.seed );
data = datasets( N, M, 123456 );

// Define the window size:
W = 10;
Expand All @@ -411,13 +400,7 @@ tape( 'the accumulator function computes a moving sample Pearson product-moment
arr = d.slice( j-W+1, j+1 );
}
expected = pcorr( arr, means[ 0 ], means[ 1 ], true );
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.strictEqual( isAlmostSameValue( actual, expected, 1623 ), true, 'returns expected value' );
}
}
t.end();
Expand All @@ -427,9 +410,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr
var expected;
var actual;
var means;
var delta;
var data;
var tol;
var acc;
var W;
var N;
Expand Down Expand Up @@ -458,13 +439,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr
}
means = mean( [ 0.0, 0.0 ], d );
expected = pcorr( d, means[ 0 ], means[ 1 ], false );
if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value. window: '+i+'.' );
} else {
delta = abs( actual - expected );
tol = 1.0 * EPS * abs( expected );
t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( actual, expected, 1 ), true, 'returns expected value' );
}
t.end();
});
Expand All @@ -473,9 +448,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr
var expected;
var actual;
var means;
var delta;
var data;
var tol;
var acc;
var W;
var N;
Expand Down Expand Up @@ -504,13 +477,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr
d = data.slice( i-W+1, i+1 );
}
expected = pcorr( d, means[ 0 ], means[ 1 ], true );
if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value. window: '+i+'.' );
} else {
delta = abs( actual - expected );
tol = 1.0 * EPS * abs( expected );
t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( actual, expected, 0 ), true, 'returns expected value' );
}
t.end();
});
Expand Down Expand Up @@ -569,10 +536,8 @@ tape( 'if the window size is `1` and the means are known, the accumulator functi

tape( 'if provided `NaN`, the accumulated value is `NaN` for at least `W` invocations (unknown means)', function test( t ) {
var expected;
var delta;
var data;
var acc;
var tol;
var v;
var i;

Expand Down Expand Up @@ -631,12 +596,8 @@ tape( 'if provided `NaN`, the accumulated value is `NaN` for at least `W` invoca
if ( isnan( expected[ i ] ) ) {
t.strictEqual( isnan( v ), true, 'returns expected value for window '+i );
t.strictEqual( isnan( acc() ), true, 'returns expected value for window '+i );
} else if ( v === expected[ i ] ) {
t.strictEqual( v, expected[ i ], 'returns expected value for window: '+i );
} else {
delta = abs( v - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected[ i ]+'. actual: '+v+'. tol: '+tol+'. delta: '+delta+'.' );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
t.strictEqual( acc(), v, 'returns expected value for window '+i );
}
}
Expand Down Expand Up @@ -672,12 +633,8 @@ tape( 'if provided `NaN`, the accumulated value is `NaN` for at least `W` invoca
if ( isnan( expected[ i ] ) ) {
t.strictEqual( isnan( v ), true, 'returns expected value for window '+i );
t.strictEqual( isnan( acc() ), true, 'returns expected value for window '+i );
} else if ( v === expected[ i ] ) {
t.strictEqual( v, expected[ i ], 'returns expected value for window: '+i );
} else {
delta = abs( v - expected[ i ] );
tol = EPS * abs( expected[ i ] );
t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected[ i ]+'. actual: '+v+'. tol: '+tol+'. delta: '+delta+'.' );
t.strictEqual( isAlmostSameValue( v, expected[ i ], 1 ), true, 'returns expected value' );
t.strictEqual( acc(), v, 'returns expected value for window '+i );
}
}
Expand Down
Loading