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 @@ -21,11 +21,10 @@
// 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 NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var factory = require( './../lib/factory.js' );


Expand Down Expand Up @@ -156,8 +155,6 @@ tape( 'if provided a nonpositive `c`, the created function always returns `NaN`'
tape( 'the created function evaluates the logcdf for `x` given positive `mu`', function test( t ) {
var expected;
var logcdf;
var delta;
var tol;
var mu;
var c;
var i;
Expand All @@ -171,22 +168,14 @@ tape( 'the created function evaluates the logcdf for `x` given positive `mu`', f
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( mu[i], c[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the created function evaluates the logcdf for `x` given negative `mu`', function test( t ) {
var expected;
var logcdf;
var delta;
var tol;
var mu;
var c;
var i;
Expand All @@ -200,22 +189,14 @@ tape( 'the created function evaluates the logcdf for `x` given negative `mu`', f
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( mu[i], c[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the created function evaluates the logcdf for `x` given large variance ( = large `b`)', function test( t ) {
var expected;
var logcdf;
var delta;
var tol;
var mu;
var c;
var i;
Expand All @@ -229,13 +210,7 @@ tape( 'the created function evaluates the logcdf for `x` given large variance (
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( mu[i], c[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});
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 isnan = require( '@stdlib/math/base/assert/is-nan' );
var abs = require( '@stdlib/math/base/special/abs' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var logcdf = require( './../lib' );


Expand Down Expand Up @@ -105,8 +104,6 @@ tape( 'if provided a nonpositive `c`, the function returns `NaN`', function test

tape( 'the function evaluates the logcdf for `x` given positive `mu`', function test( t ) {
var expected;
var delta;
var tol;
var mu;
var c;
var i;
Expand All @@ -119,50 +116,32 @@ tape( 'the function evaluates the logcdf for `x` given positive `mu`', function
c = positiveMean.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], mu[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given negative `mu`', function test( t ) {
var expected;
var delta;
var tol;
var mu;
var c;
var i;
var x;
var y;

tol = EPS;

expected = negativeMean.expected;
x = negativeMean.x;
mu = negativeMean.mu;
c = negativeMean.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], mu[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given large variance ( = large `b` )', function test( t ) {
var expected;
var delta;
var tol;
var mu;
var c;
var i;
Expand All @@ -175,13 +154,7 @@ tape( 'the function evaluates the logcdf for `x` given large variance ( = large
c = largeVariance.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], mu[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 1.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. mu: '+mu[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@
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 PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );


// VARIABLES //
Expand Down Expand Up @@ -114,8 +113,6 @@ tape( 'if provided a nonpositive `c`, the function returns `NaN`', opts, functio

tape( 'the function evaluates the logcdf for `x` given positive `mu`', opts, function test( t ) {
var expected;
var delta;
var tol;
var mu;
var c;
var i;
Expand All @@ -128,50 +125,32 @@ tape( 'the function evaluates the logcdf for `x` given positive `mu`', opts, fun
c = positiveMean.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], mu[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[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]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given negative `mu`', opts, function test( t ) {
var expected;
var delta;
var tol;
var mu;
var c;
var i;
var x;
var y;

tol = EPS;

expected = negativeMean.expected;
x = negativeMean.x;
mu = negativeMean.mu;
c = negativeMean.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], mu[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[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]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given large variance ( = large `b` )', opts, function test( t ) {
var expected;
var delta;
var tol;
var mu;
var c;
var i;
Expand All @@ -184,13 +163,7 @@ tape( 'the function evaluates the logcdf for `x` given large variance ( = large
c = largeVariance.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], mu[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', mu:'+mu[i]+', c: '+c[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]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 0 ), true, 'returns expected value' );
}
t.end();
});