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 @@ -157,8 +156,6 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the created function
tape( 'the created function evaluates the logcdf for `x` given a small range `b - a`', function test( t ) {
var expected;
var logcdf;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -174,22 +171,14 @@ tape( 'the created function evaluates the logcdf for `x` given a small range `b
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( a[i], b[i], c[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 6 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the created function evaluates the logcdf for `x` given a medium range `b - a`', function test( t ) {
var expected;
var logcdf;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -205,22 +194,14 @@ tape( 'the created function evaluates the logcdf for `x` given a medium range `b
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( a[i], b[i], c[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[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 a large range `b - a`', function test( t ) {
var expected;
var logcdf;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -236,13 +217,7 @@ tape( 'the created function evaluates the logcdf for `x` given a large range `b
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( a[i], b[i], c[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 11 ), 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 @@ -92,8 +91,6 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns

tape( 'the function evaluates the logcdf for `x` given a small range `b - a`', function test( t ) {
var expected;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -108,21 +105,13 @@ tape( 'the function evaluates the logcdf for `x` given a small range `b - a`', f
c = smallRange.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], a[i], b[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 6 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given a medium range `b - a`', function test( t ) {
var expected;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -137,21 +126,13 @@ tape( 'the function evaluates the logcdf for `x` given a medium range `b - a`',
c = mediumRange.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], a[i], b[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[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 a large range `b - a`', function test( t ) {
var expected;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -166,13 +147,7 @@ tape( 'the function evaluates the logcdf for `x` given a large range `b - a`', f
c = largeRange.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], a[i], b[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 11 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@

var resolve = require( 'path' ).resolve;
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 tryRequire = require( '@stdlib/utils/try-require' );


Expand Down Expand Up @@ -101,8 +100,6 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns

tape( 'the function evaluates the logcdf for `x` given a small range `b - a`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -117,21 +114,13 @@ tape( 'the function evaluates the logcdf for `x` given a small range `b - a`', o
c = smallRange.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], a[i], b[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 6 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given a medium range `b - a`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -146,21 +135,13 @@ tape( 'the function evaluates the logcdf for `x` given a medium range `b - a`',
c = mediumRange.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], a[i], b[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[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 a large range `b - a`', opts, function test( t ) {
var expected;
var delta;
var tol;
var x;
var a;
var b;
Expand All @@ -175,13 +156,7 @@ tape( 'the function evaluates the logcdf for `x` given a large range `b - a`', o
c = largeRange.c;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], a[i], b[i], c[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', a: '+a[i]+', b: '+b[i]+', c: '+c[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 10.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. a: '+a[i]+'. b: '+b[i]+'. c: '+c[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 11 ), true, 'returns expected value' );
}
t.end();
});