Skip to content
Merged
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
47 changes: 7 additions & 40 deletions lib/node_modules/@stdlib/stats/incr/mcovariance/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@
// 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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var EPS = require( '@stdlib/constants/float64/eps' );
var zeros = require( '@stdlib/array/base/zeros' );
var incrmcovariance = require( './../lib' );

Expand Down Expand Up @@ -263,12 +262,10 @@ tape( 'the function returns an accumulator function (known means)', function tes
tape( 'the accumulator function computes a moving unbiased sample covariance 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 @@ -278,7 +275,7 @@ tape( 'the accumulator function computes a moving unbiased sample covariance inc

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

// Define the window size:
W = 10;
Expand All @@ -297,13 +294,7 @@ tape( 'the accumulator function computes a moving unbiased sample covariance inc
}
means = mean( [ 0.0, 0.0 ], arr );
expected = covariance( 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, 8192 ), true, 'returns expected value' );
}
}
t.end();
Expand All @@ -313,11 +304,9 @@ tape( 'the accumulator function computes a moving unbiased sample covariance inc
var expected;
var actual;
var means;
var delta;
var data;
var acc;
var arr;
var tol;
var d;
var N;
var M;
Expand All @@ -327,7 +316,7 @@ tape( 'the accumulator function computes a moving unbiased sample covariance inc

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

// Define the window size:
W = 10;
Expand All @@ -345,13 +334,7 @@ tape( 'the accumulator function computes a moving unbiased sample covariance inc
arr = d.slice( j-W+1, j+1 );
}
expected = covariance( 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, 1674 ), true, 'returns expected value' );
}
}
t.end();
Expand All @@ -361,9 +344,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 @@ -392,13 +373,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr
}
means = mean( [ 0.0, 0.0 ], d );
expected = covariance( 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.5 * EPS * abs( expected );
t.strictEqual( delta < tol, true, 'window: '+i+'. expected: '+expected+'. actual: '+actual+'. tol: '+tol+'. delta: '+delta+'.' );
}
t.strictEqual( isAlmostSameValue( actual, expected, 2 ), true, 'returns expected value' );
}
t.end();
});
Expand All @@ -407,9 +382,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 @@ -438,13 +411,7 @@ tape( 'if not provided an input value, the accumulator function returns the curr
d = data.slice( i-W+1, i+1 );
}
expected = covariance( d, means[ 0 ], means[ 1 ], true );
if ( actual === expected ) {
t.strictEqual( actual, expected, 'returns expected value. window: '+i+'.' );
} else {
delta = abs( actual - expected );
tol = 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
Loading