Skip to content
Draft
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,10 +22,9 @@

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' );
var factory = require( './../lib/factory.js' );


Expand Down Expand Up @@ -139,9 +138,7 @@ tape( 'if provided a nonpositive `gamma`, the created function always returns `N
tape( 'the created function evaluates the logcdf for `x` given `x0` and `gamma` (large gamma)', function test( t ) {
var expected;
var logcdf;
var delta;
var gamma;
var tol;
var x0;
var i;
var x;
Expand All @@ -154,23 +151,15 @@ tape( 'the created function evaluates the logcdf for `x` given `x0` and `gamma`
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( x0[i], gamma[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 7.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 9 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the created function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 < 0`)', function test( t ) {
var expected;
var logcdf;
var delta;
var gamma;
var tol;
var x0;
var i;
var x;
Expand All @@ -183,23 +172,15 @@ tape( 'the created function evaluates the logcdf for `x` given `x0` and `gamma`
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( x0[i], gamma[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 7.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 12 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the created function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 > 0`)', function test( t ) {
var expected;
var logcdf;
var delta;
var gamma;
var tol;
var x0;
var i;
var x;
Expand All @@ -212,13 +193,7 @@ tape( 'the created function evaluates the logcdf for `x` given `x0` and `gamma`
for ( i = 0; i < x.length; i++ ) {
logcdf = factory( x0[i], gamma[i] );
y = logcdf( x[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 7.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 6 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,9 @@

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' );
var logcdf = require( './../lib' );


Expand Down Expand Up @@ -95,9 +94,7 @@ tape( 'if provided a nonpositive `gamma`, the function always returns `NaN`', fu

tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (large `gamma`)', function test( t ) {
var expected;
var delta;
var gamma;
var tol;
var x0;
var x;
var y;
Expand All @@ -109,22 +106,14 @@ tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (large `
gamma = largeGamma.gamma;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], x0[i], gamma[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 7.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 9 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 < 0`)', function test( t ) {
var expected;
var delta;
var gamma;
var tol;
var x0;
var x;
var y;
Expand All @@ -136,22 +125,14 @@ tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 < 0
gamma = negativeMedian.gamma;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], x0[i], gamma[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 7.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 12 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 > 0`)', function test( t ) {
var expected;
var delta;
var gamma;
var tol;
var x0;
var x;
var y;
Expand All @@ -163,13 +144,7 @@ tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 > 0
gamma = positiveMedian.gamma;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], x0[i], gamma[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 7.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 6 ), true, 'returns expected value' );
}
t.end();
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ 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' );


// FIXTURES //
Expand Down Expand Up @@ -104,9 +103,7 @@ tape( 'if provided a nonpositive `gamma`, the function always returns `NaN`', op

tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (large `gamma`)', opts, function test( t ) {
var expected;
var delta;
var gamma;
var tol;
var x0;
var x;
var y;
Expand All @@ -118,22 +115,14 @@ tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (large `
gamma = largeGamma.gamma;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], x0[i], gamma[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 7.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 9 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 < 0`)', opts, function test( t ) {
var expected;
var delta;
var gamma;
var tol;
var x0;
var x;
var y;
Expand All @@ -145,22 +134,14 @@ tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 < 0
gamma = negativeMedian.gamma;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], x0[i], gamma[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 300.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 12 ), true, 'returns expected value' );
}
t.end();
});

tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 > 0`)', opts, function test( t ) {
var expected;
var delta;
var gamma;
var tol;
var x0;
var x;
var y;
Expand All @@ -172,13 +153,7 @@ tape( 'the function evaluates the logcdf for `x` given `x0` and `gamma` (`x0 > 0
gamma = positiveMedian.gamma;
for ( i = 0; i < x.length; i++ ) {
y = logcdf( x[i], x0[i], gamma[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'x: '+x[i]+', x0:'+x0[i]+', gamma: '+gamma[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );
tol = 220.0 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. x0: '+x0[i]+'. gamma: '+gamma[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[i], 6 ), true, 'returns expected value' );
}
t.end();
});