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


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

tape( 'the function returns the standard deviation of a Kumaraswamy\'s double bounded distribution', function test( t ) {
var expected;
var delta;
var tol;
var a;
var b;
var i;
Expand All @@ -115,22 +112,16 @@ tape( 'the function returns the standard deviation of a Kumaraswamy\'s double bo
expected = data.expected;
a = data.a;
b = data.b;

/*
* High tolerance needed due to compounding errors in σ = √(m₂ - m₁²):
* - Two beta function evaluations with different parameters
* - Subtraction precision loss when m₂ ≈ m₁²
* - Square root operation amplifying small errors
*/
for ( i = 0; i < expected.length; i++ ) {
y = stdev( a[i], b[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );

/*
* High tolerance needed due to compounding errors in σ = √(m₂ - m₁²):
* - Two beta function evaluations with different parameters
* - Subtraction precision loss when m₂ ≈ m₁²
* - Square root operation amplifying small errors
*/
tol = 10000 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 10564 ), 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 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' );


// FIXTURES //
Expand Down Expand Up @@ -117,8 +116,6 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', opts, functio

tape( 'the function returns the standard deviation of a Kumaraswamy\'s double bounded distribution', opts, function test( t ) {
var expected;
var delta;
var tol;
var a;
var b;
var i;
Expand All @@ -127,22 +124,16 @@ tape( 'the function returns the standard deviation of a Kumaraswamy\'s double bo
expected = data.expected;
a = data.a;
b = data.b;

/*
* High tolerance needed due to compounding errors in σ = √(m₂ - m₁²):
* - Two beta function evaluations with different parameters
* - Subtraction precision loss when m₂ ≈ m₁²
* - Square root operation amplifying small errors
*/
for ( i = 0; i < expected.length; i++ ) {
y = stdev( a[i], b[i] );
if ( y === expected[i] ) {
t.strictEqual( y, expected[i], 'a: '+a[i]+', b: '+b[i]+', y: '+y+', expected: '+expected[i] );
} else {
delta = abs( y - expected[ i ] );

/*
* High tolerance needed due to compounding errors in σ = √(m₂ - m₁²):
* - Two beta function evaluations with different parameters
* - Subtraction precision loss when m₂ ≈ m₁²
* - Square root operation amplifying small errors
*/
tol = 18500 * EPS * abs( expected[ i ] );
t.ok( delta <= tol, 'within tolerance. a: '+a[i]+'. b: '+b[i]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol+'.' );
}
t.strictEqual( isAlmostSameValue( y, expected[ i ], 10564 ), true, 'returns expected value' );
}
t.end();
});
Loading