diff --git a/lib/node_modules/@stdlib/stats/pcorrtest/test/test.js b/lib/node_modules/@stdlib/stats/pcorrtest/test/test.js index 6946282330b2..953ea2fa45b3 100644 --- a/lib/node_modules/@stdlib/stats/pcorrtest/test/test.js +++ b/lib/node_modules/@stdlib/stats/pcorrtest/test/test.js @@ -21,9 +21,8 @@ // MODULES // var tape = require( 'tape' ); +var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' ); var contains = require( '@stdlib/assert/contains' ); -var abs = require( '@stdlib/math/base/special/abs' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var pcorrtest = require( './../lib' ); @@ -177,9 +176,7 @@ tape( 'the function throws an error if provided arrays with less than four obser tape( 'the function by default performs a two-sided t-test for the Pearson correlation between paired samples', function test( t ) { var expected; - var delta; var out; - var tol; var i; var x; var y; @@ -190,29 +187,21 @@ tape( 'the function by default performs a two-sided t-test for the Pearson corre // Tested against R: expected = twosided.pValue; - delta = abs( out.pValue - expected ); - tol = 1e-6 * abs( expected ); - t.ok( delta <= tol, 'within tolerance. p-value: '+out.pValue+'. E: '+expected+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.pValue, expected, 167809046 ), true, 'returns expected value' ); expected = twosided.statistic; - delta = abs( out.statistic - expected ); - tol = 10.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. statistic: '+out.statistic+'. E: '+expected+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.statistic, expected, 0 ), true, 'returns expected value' ); expected = twosided.ci; for ( i = 0; i < 2; i++ ) { - delta = abs( out.ci[ i ] - expected[ i ]); - tol = 20.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. CI['+i+']: '+out.ci[ i ]+'. E: '+expected[ i ]+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[ i ], expected[ i ], 1 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function performs a one-sided t-test for the Pearson correlation between paired samples (when alternative is `less`)', function test( t ) { var expected; - var delta; var out; - var tol; var i; var x; var y; @@ -225,29 +214,21 @@ tape( 'the function performs a one-sided t-test for the Pearson correlation betw // Tested against R: expected = less.pValue; - delta = abs( out.pValue - expected ); - tol = 100 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. p-value: '+out.pValue+'. E: '+expected+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.pValue, expected, 0 ), true, 'returns expected value' ); expected = less.statistic; - delta = abs( out.statistic - expected ); - tol = 10.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. statistic: '+out.statistic+'. E: '+expected+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.statistic, expected, 0 ), true, 'returns expected value' ); expected = less.ci; for ( i = 0; i < 2; i++ ) { - delta = abs( out.ci[ i ] - expected[ i ]); - tol = 10.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. CI['+i+']: '+out.ci[ i ]+'. E: '+expected[ i ]+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[ i ], expected[ i ], 3 ), true, 'returns expected value' ); } t.end(); }); tape( 'the function performs a one-sided t-test for the Pearson correlation between paired samples (when alternative is `greater`)', function test( t ) { var expected; - var delta; var out; - var tol; var i; var x; var y; @@ -260,20 +241,14 @@ tape( 'the function performs a one-sided t-test for the Pearson correlation betw // Tested against R: expected = greater.pValue; - delta = abs( out.pValue - expected ); - tol = 100 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. p-value: '+out.pValue+'. E: '+expected+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.pValue, expected, 0 ), true, 'returns expected value' ); expected = greater.statistic; - delta = abs( out.statistic - expected ); - tol = 10.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. statistic: '+out.statistic+'. E: '+expected+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.statistic, expected, 2 ), true, 'returns expected value' ); expected = greater.ci; for ( i = 0; i < 2; i++ ) { - delta = abs( out.ci[ i ] - expected[ i ]); - tol = 10.0 * EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. CI['+i+']: '+out.ci[ i ]+'. E: '+expected[ i ]+' Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[ i ], expected[ i ], 3 ), true, 'returns expected value' ); } t.end(); });