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


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

tape( 'the function evaluates the cdf 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 @@ -104,21 +101,13 @@ tape( 'the function evaluates the cdf for `x` given a small range `b - a`', func
c = smallRange.c;
for ( i = 0; i < x.length; i++ ) {
y = cdf( 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 = 1.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 cdf 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 @@ -133,21 +122,13 @@ tape( 'the function evaluates the cdf for `x` given a medium range `b - a`', fun
c = mediumRange.c;
for ( i = 0; i < x.length; i++ ) {
y = cdf( 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 = 1.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 cdf 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 @@ -162,13 +143,7 @@ tape( 'the function evaluates the cdf for `x` given a large range `b - a`', func
c = largeRange.c;
for ( i = 0; i < x.length; i++ ) {
y = cdf( 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 = 1.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();
});
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,9 +155,7 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the created function

tape( 'the created function evaluates the cdf for `x` given a small range `b - a`', function test( t ) {
var expected;
var delta;
var cdf;
var tol;
var x;
var a;
var b;
Expand All @@ -174,22 +171,14 @@ tape( 'the created function evaluates the cdf for `x` given a small range `b - a
for ( i = 0; i < x.length; i++ ) {
cdf = factory( a[i], b[i], c[i] );
y = cdf( 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 = 1.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 cdf for `x` given a medium range `b - a`', function test( t ) {
var expected;
var delta;
var cdf;
var tol;
var x;
var a;
var b;
Expand All @@ -205,22 +194,14 @@ tape( 'the created function evaluates the cdf for `x` given a medium range `b -
for ( i = 0; i < x.length; i++ ) {
cdf = factory( a[i], b[i], c[i] );
y = cdf( 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 = 1.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 cdf for `x` given a large range `b - a`', function test( t ) {
var expected;
var delta;
var cdf;
var tol;
var x;
var a;
var b;
Expand All @@ -236,13 +217,7 @@ tape( 'the created function evaluates the cdf for `x` given a large range `b - a
for ( i = 0; i < x.length; i++ ) {
cdf = factory( a[i], b[i], c[i] );
y = cdf( 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 = 1.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();
});
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 @@ -97,8 +96,6 @@ tape( 'if provided parameters not satisfying `a <= c <= b`, the function returns

tape( 'the function evaluates the cdf 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 @@ -113,21 +110,13 @@ tape( 'the function evaluates the cdf for `x` given a small range `b - a`', opts
c = smallRange.c;
for ( i = 0; i < x.length; i++ ) {
y = cdf( 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 = 1.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 cdf 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 @@ -142,21 +131,13 @@ tape( 'the function evaluates the cdf for `x` given a medium range `b - a`', opt
c = mediumRange.c;
for ( i = 0; i < x.length; i++ ) {
y = cdf( 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 = 1.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 cdf 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 @@ -171,13 +152,7 @@ tape( 'the function evaluates the cdf for `x` given a large range `b - a`', opts
c = largeRange.c;
for ( i = 0; i < x.length; i++ ) {
y = cdf( 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 = 1.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();
});