Skip to content
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
// MODULES //

var tape = require( 'tape' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var variance = require( './../lib' );


Expand Down Expand Up @@ -119,8 +118,6 @@ tape( 'if provided an `n` which is not a nonnegative integer, the function retur

tape( 'the function returns the variance of a hypergeometric distribution', function test( t ) {
var expected;
var delta;
var tol;
var N;
var K;
var n;
Expand All @@ -133,13 +130,7 @@ tape( 'the function returns the variance of a hypergeometric distribution', func
n = data.n;
for ( i = 0; i < n.length; i++ ) {
y = variance( N[i], K[i], n[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'N: '+N[i]+', K: '+K[i]+', n: '+n[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 18.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. N: '+N[i]+'. K: '+K[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 29 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var tryRequire = require( '@stdlib/utils/try-require' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var EPS = require( '@stdlib/constants/float64/eps' );


// VARIABLES //
Expand Down Expand Up @@ -87,8 +86,6 @@ tape( 'if provided an `n` which is not a nonnegative integer, the function retur

tape( 'the function returns the variance of a hypergeometric distribution', opts, function test( t ) {
var expected;
var delta;
var tol;
var N;
var K;
var n;
Expand All @@ -101,13 +98,7 @@ tape( 'the function returns the variance of a hypergeometric distribution', opts
n = data.n;
for ( i = 0; i < n.length; i++ ) {
y = variance( N[i], K[i], n[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'N: '+N[i]+', K: '+K[i]+', n: '+n[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 18.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. N: '+N[i]+'. K: '+K[i]+'. n: '+n[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 1 ), true, 'returns expected value' );
}
t.end();
});