Skip to content
Merged
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 @@ -22,7 +22,7 @@

var tape = require( 'tape' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
Expand Down Expand Up @@ -156,9 +156,7 @@ tape( 'if `s` equals `0`, the created function evaluates a degenerate distributi

tape( 'the created function evaluates the pdf for `x` given positive `mu`', function test( t ) {
var expected;
var delta;
var pdf;
var tol;
var mu;
var s;
var x;
Expand All @@ -172,24 +170,16 @@ tape( 'the created function evaluates the pdf for `x` given positive `mu`', func
for ( i = 0; i < x.length; i++ ) {
pdf = factory( mu[i], s[i] );
y = pdf( x[i] );
if ( expected[i] !== null && !(expected[i] === 0.0 && y < EPS ) ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
if ( expected[i] !== null && !( expected[i] === 0.0 && y < EPS ) ) {
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the created function evaluates the pdf for `x` given negative `mu`', function test( t ) {
var expected;
var delta;
var pdf;
var tol;
var mu;
var s;
var x;
Expand All @@ -203,24 +193,16 @@ tape( 'the created function evaluates the pdf for `x` given negative `mu`', func
for ( i = 0; i < x.length; i++ ) {
pdf = factory( mu[i], s[i] );
y = pdf( x[i] );
if ( expected[i] !== null && !(expected[i] === 0.0 && y < EPS ) ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
if ( expected[i] !== null && !( expected[i] === 0.0 && y < EPS ) ) {
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the created function evaluates the pdf for `x` given large variance ( = large `s`)', function test( t ) {
var expected;
var delta;
var pdf;
var tol;
var mu;
var s;
var x;
Expand All @@ -235,13 +217,7 @@ tape( 'the created function evaluates the pdf for `x` given large variance ( = l
pdf = factory( mu[i], s[i] );
y = pdf( x[i] );
if ( expected[i] !== null ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var resolve = require( 'path' ).resolve;
var tape = require( 'tape' );
var tryRequire = require( '@stdlib/utils/try-require' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
Expand Down Expand Up @@ -122,8 +122,6 @@ tape( 'if provided `s` equal to `0`, the function evaluates a degenerate distrib

tape( 'the function evaluates the pdf for `x` given positive `mu`', opts, function test( t ) {
var expected;
var delta;
var tol;
var mu;
var x;
var s;
Expand All @@ -136,23 +134,15 @@ tape( 'the function evaluates the pdf for `x` given positive `mu`', opts, functi
s = positiveMean.s;
for ( i = 0; i < x.length; i++ ) {
y = pdf( x[i], mu[i], s[i] );
if ( expected[i] !== null && !(expected[i] === 0.0 && y < EPS ) ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
if ( expected[i] !== null && !( expected[i] === 0.0 && y < EPS ) ) {
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function evaluates the pdf for `x` given negative `mu`', opts, function test( t ) {
var expected;
var delta;
var tol;
var mu;
var x;
var s;
Expand All @@ -165,23 +155,15 @@ tape( 'the function evaluates the pdf for `x` given negative `mu`', opts, functi
s = negativeMean.s;
for ( i = 0; i < x.length; i++ ) {
y = pdf( x[i], mu[i], s[i] );
if ( expected[i] !== null && !(expected[i] === 0.0 && y < EPS ) ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
if ( expected[i] !== null && !( expected[i] === 0.0 && y < EPS ) ) {
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function evaluates the pdf for `x` given large variance ( = large `s` )', opts, function test( t ) {
var expected;
var delta;
var tol;
var mu;
var x;
var s;
Expand All @@ -195,13 +177,7 @@ tape( 'the function evaluates the pdf for `x` given large variance ( = large `s`
for ( i = 0; i < x.length; i++ ) {
y = pdf( x[i], mu[i], s[i] );
if ( expected[i] !== null ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var tape = require( 'tape' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var isAlmostSameValue = require( '@stdlib/assert/is-almost-same-value' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
Expand Down Expand Up @@ -113,8 +113,6 @@ tape( 'if provided `s` equal to `0`, the function evaluates a degenerate distrib

tape( 'the function evaluates the pdf for `x` given positive `mu`', function test( t ) {
var expected;
var delta;
var tol;
var mu;
var x;
var s;
Expand All @@ -127,23 +125,15 @@ tape( 'the function evaluates the pdf for `x` given positive `mu`', function tes
s = positiveMean.s;
for ( i = 0; i < x.length; i++ ) {
y = pdf( x[i], mu[i], s[i] );
if ( expected[i] !== null && !(expected[i] === 0.0 && y < EPS ) ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
if ( expected[i] !== null && !( expected[i] === 0.0 && y < EPS ) ) {
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function evaluates the pdf for `x` given negative `mu`', function test( t ) {
var expected;
var delta;
var tol;
var mu;
var x;
var s;
Expand All @@ -156,23 +146,15 @@ tape( 'the function evaluates the pdf for `x` given negative `mu`', function tes
s = negativeMean.s;
for ( i = 0; i < x.length; i++ ) {
y = pdf( x[i], mu[i], s[i] );
if ( expected[i] !== null && !(expected[i] === 0.0 && y < EPS ) ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
if ( expected[i] !== null && !( expected[i] === 0.0 && y < EPS ) ) {
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
});

tape( 'the function evaluates the pdf for `x` given large variance ( = large `s` )', function test( t ) {
var expected;
var delta;
var tol;
var mu;
var x;
var s;
Expand All @@ -186,13 +168,7 @@ tape( 'the function evaluates the pdf for `x` given large variance ( = large `s`
for ( i = 0; i < x.length; i++ ) {
y = pdf( x[i], mu[i], s[i] );
if ( expected[i] !== null ) {
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu: '+mu[i]+', s: '+s[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 3.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. s: '+s[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 4 ), true, 'returns expected value' );
}
}
t.end();
Expand Down