diff --git a/lib/node_modules/@stdlib/stats/vartest/test/test.js b/lib/node_modules/@stdlib/stats/vartest/test/test.js index c2fb0c7d2cfc..222639e3dc06 100644 --- a/lib/node_modules/@stdlib/stats/vartest/test/test.js +++ b/lib/node_modules/@stdlib/stats/vartest/test/test.js @@ -21,10 +21,9 @@ // 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 PINF = require( '@stdlib/constants/float64/pinf' ); -var EPS = require( '@stdlib/constants/float64/eps' ); var vartest = require( './../lib' ); @@ -155,9 +154,7 @@ tape( 'the function throws an error if the `alpha` option is a numeric value out tape( 'the function by default performs a two-sample F-test', function test( t ) { var expected; - var delta; var out; - var tol; var a; var b; @@ -167,33 +164,23 @@ tape( 'the function by default performs a two-sample F-test', function test( t ) // Tested against R: expected = twosided.pValue; - delta = abs( out.pValue - expected ); - tol = 250.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. a: ['+a+']. b: ['+b+']. pValue: '+out.pValue+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.pValue, expected, 253 ), true, 'returns expected value' ); expected = twosided.statistic; - delta = abs( out.statistic - expected ); - tol = 1.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. a: ['+a+']. b: ['+b+']. statistic: '+out.statistic+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.statistic, expected, 1 ), true, 'returns expected value' ); expected = twosided.lower; - delta = abs( out.ci[0] - expected ); - tol = 5.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. a: ['+a+']. b: ['+b+']. lower CI: '+out.ci[0]+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[0], expected, 8 ), true, 'returns expected value' ); expected = twosided.upper; - delta = abs( out.ci[1] - expected ); - tol = 10.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. a: ['+a+']. b: ['+b+']. upper CI: '+out.ci[1]+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[1], expected, 9 ), true, 'returns expected value' ); t.end(); }); tape( 'the function performs a two-sample F-test assuming the true ratio of the population variances being equal to the value of the `ratio` option', function test( t ) { var expected; - var delta; var out; - var tol; var a; var b; @@ -207,28 +194,20 @@ tape( 'the function performs a two-sample F-test assuming the true ratio of the t.strictEqual( out.pValue, diff.pValue, 'returns correct p-value' ); expected = diff.statistic; - delta = abs( out.statistic - expected ); - tol = 1.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. a: ['+a+']. b: ['+b+']. statistic: '+out.statistic+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.statistic, expected, 1 ), true, 'returns expected value' ); expected = diff.lower; - delta = abs( out.ci[0] - expected ); - tol = 6.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. a: ['+a+']. b: ['+b+']. lower CI: '+out.ci[0]+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[0], expected, 8 ), true, 'returns expected value' ); expected = diff.upper; - delta = abs( out.ci[1] - expected ); - tol = 12.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. a: ['+a+']. b: ['+b+']. upper CI: '+out.ci[1]+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[1], expected, 9 ), true, 'returns expected value' ); t.end(); }); tape( 'the function performs a one-sided two-sample F-test', function test( t ) { var expected; - var delta; var out; - var tol; var a; var b; @@ -240,21 +219,15 @@ tape( 'the function performs a one-sided two-sample F-test', function test( t ) // Tested against R: expected = less.pValue; - delta = abs( out.pValue - expected ); - tol = 5.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. direction: less. a: ['+a+']. b: ['+b+']. pValue: '+out.pValue+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.pValue, expected, 4 ), true, 'returns expected value' ); expected = less.statistic; - delta = abs( out.statistic - expected ); - tol = 1.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. direction: less. a: ['+a+']. b: ['+b+']. statistic: '+out.statistic+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.statistic, expected, 1 ), true, 'returns expected value' ); t.strictEqual( out.ci[0], 0.0, 'returns 0 as lower bound of CI' ); expected = less.upper; - delta = abs( out.ci[1] - expected ); - tol = 5.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. direction: less. a: ['+a+']. b: ['+b+']. upper CI: '+out.ci[1]+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[1], expected, 8 ), true, 'returns expected value' ); out = vartest( a, b, { 'alternative': 'greater' @@ -262,19 +235,13 @@ tape( 'the function performs a one-sided two-sample F-test', function test( t ) // Tested against R: expected = greater.pValue; - delta = abs( out.pValue - expected ); - tol = 250.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. direction: greater. a: ['+a+']. b: ['+b+']. pValue: '+out.pValue+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.pValue, expected, 253 ), true, 'returns expected value' ); expected = greater.statistic; - delta = abs( out.statistic - expected ); - tol = 1.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. direction: greater. a: ['+a+']. b: ['+b+']. statistic: '+out.statistic+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.statistic, expected, 1 ), true, 'returns expected value' ); expected = greater.lower; - delta = abs( out.ci[0] - expected ); - tol = 1.0 * EPS * abs( expected ); - t.ok( delta <= tol, 'within tolerance. direction: greater. a: ['+a+']. b: ['+b+']. lower CI: '+out.ci[0]+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol ); + t.strictEqual( isAlmostSameValue( out.ci[0], expected, 1 ), true, 'returns expected value' ); t.strictEqual( out.ci[1], PINF, 'returns Infinity as upper bound of CI' );