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

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 tryRequire = require( '@stdlib/utils/try-require' );
var PINF = require( '@stdlib/constants/float64/pinf' );
var NINF = require( '@stdlib/constants/float64/ninf' );
var EPS = require( '@stdlib/constants/float64/eps' );
var abs = require( '@stdlib/math/base/special/abs' );
var uniform = require( '@stdlib/random/base/uniform' );
var ln = require( '@stdlib/math/base/special/ln' );
var cdf = require( '@stdlib/stats/base/dists/gamma/cdf' );
Expand Down Expand Up @@ -153,10 +153,8 @@ tape( 'if provided an `alpha` equal to `0` and `beta` is positive, the function

tape( 'the function evaluates the logarithm of the CDF', opts, function test( t ) {
var expected;
var delta;
var alpha;
var beta;
var tol;
var i;
var x;
var y;
Expand All @@ -167,14 +165,9 @@ tape( 'the function evaluates the logarithm of the CDF', opts, function test( t
beta = uniform( EPS, 10.0 );
y = logcdf( x, alpha, beta );
expected = ln( cdf( x, alpha, beta ) );
if ( y === expected ) {
t.strictEqual( y, expected, 'x: '+x+', alpha: '+alpha+', beta: '+beta+', y: '+y+', expected: '+expected );
} else {
// NOTE: increased test tolerance due to differences in accumulated error between JavaScript and C, especially as we are wrapping `cdf` which relies on `gammainc`, where compiler optimizations can result in different error propagation
delta = abs( y - expected );
tol = 100.0 * EPS * abs( expected );
t.ok( delta <= tol, 'within tolerance. x: '+x+'. alpha: '+alpha+'. beta: '+beta+'. y: '+y+'. E: '+expected+'. Δ: '+delta+'. tol: '+tol+'.' );
}

// NOTE: increased ULP tolerance due to differences in accumulated error between JavaScript and C, especially as we are wrapping `cdf` which relies on `gammainc`, where compiler optimizations can result in different error propagation
t.strictEqual( isAlmostSameValue( y, expected, 100 ), true, 'returns expected value' );
}
t.end();
});
Loading