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,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/array/discrete-uniform' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var bernoulli = require( './../lib' );
Expand All @@ -34,7 +34,7 @@ bench( pkg, function benchmark( b ) {
var y;
var i;

x = randu( 100, 0, 500 );
x = discreteUniform( 100, 0, 500 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/array/discrete-uniform' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -43,7 +43,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var y;
var i;

x = randu( 100, 0, 500 );
x = discreteUniform( 100, 0, 500 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double elapsed;
double x[ 100 ];
double elapsed;
double y;
double t;
int i;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var EPS = require( '@stdlib/constants/float64/eps' );
var pkg = require( './../package.json' ).name;
Expand All @@ -37,12 +37,13 @@ bench( pkg, function benchmark( assert ) {
var b;
var i;

x = uniform( 100, 0.0, 1.0 );
a = uniform( 100, EPS, 1000.0 );
b = uniform( 100, EPS, 1000.0 );

assert.tic();
for ( i = 0; i < assert.iterations; i++ ) {
x = randu();
a = ( randu()*1000.0 ) + EPS;
b = ( randu()*1000.0 ) + EPS;
y = betainc( x, a, b );
y = betainc( x[ i % x.length ], a[ i % a.length ], b[ i % b.length ] );
if ( isnan( y ) ) {
assert.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,23 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double a[ 100 ];
double b[ 100 ];
double elapsed;
double x;
double a;
double b;
double y;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = rand_double();
a[ i ] = ( 1000.0*rand_double() ) + 0.1;
b[ i ] = ( 1000.0*rand_double() ) + 0.1;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = rand_double();
a = ( 1000.0*rand_double() ) + 0.1;
b = ( 1000.0*rand_double() ) + 0.1;
y = incbet( a, b, x );
y = incbet( a[ i%100 ], b[ i%100 ], x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
10 changes: 5 additions & 5 deletions lib/node_modules/@stdlib/math/base/special/betainc/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,23 @@ tape( 'main export is a function', function test( t ) {

tape( 'the function returns `NaN` if `x` is outside `[0,1]`', function test( t ) {
var val = betainc( -0.2, 1.0, 1.0 );
t.equal( isnan( val ), true, 'returns NaN' );
t.equal( isnan( val ), true, 'returns expected value' );

val = betainc( 1.1, 1.0, 1.0 );
t.equal( isnan( val ), true, 'returns NaN' );
t.equal( isnan( val ), true, 'returns expected value' );

t.end();
});

tape( 'the function returns `NaN` negative `a` or `b`', function test( t ) {
var val = betainc( 0.5, -1.0, 1.0 );
t.equal( isnan( val ), true, 'returns NaN' );
t.equal( isnan( val ), true, 'returns expected value' );

val = betainc( 0.5, 1.0, -1.0 );
t.equal( isnan( val ), true, 'returns NaN' );
t.equal( isnan( val ), true, 'returns expected value' );

val = betainc( 0.5, -1.0, -1.0 );
t.equal( isnan( val ), true, 'returns NaN' );
t.equal( isnan( val ), true, 'returns expected value' );
t.end();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var EPS = require( '@stdlib/constants/float64/eps' );
var pkg = require( './../package.json' ).name;
Expand All @@ -37,12 +37,13 @@ bench( pkg, function benchmark( assert ) {
var b;
var i;

x = uniform( 100, 0.0, 1.0 );
a = uniform( 100, EPS, 1000.0 );
b = uniform( 100, EPS, 1000.0 );

assert.tic();
for ( i = 0; i < assert.iterations; i++ ) {
x = randu();
a = ( randu()*1000.0 ) + EPS;
b = ( randu()*1000.0 ) + EPS;
y = betaincinv( x, a, b );
y = betaincinv( x[ i%x.length ], a[ i%a.length ], b[ i%b.length ] );
if ( isnan( y ) ) {
assert.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,20 +94,23 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double a[ 100 ];
double b[ 100 ];
double elapsed;
double x;
double a;
double b;
double y;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = rand_double();
a[ i ] = ( 1000.0*rand_double() ) + 0.1;
b[ i ] = ( 1000.0*rand_double() ) + 0.1;
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = rand_double();
a = ( 1000.0*rand_double() ) + 0.1;
b = ( 1000.0*rand_double() ) + 0.1;
y = incbi( a, b, x );
y = incbi( a[ i%100 ], b[ i%100 ], x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
38 changes: 19 additions & 19 deletions lib/node_modules/@stdlib/math/base/special/betaincinv/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,48 +49,48 @@ tape( 'main export is a function', function test( t ) {

tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) {
var y = betaincinv( NaN, 1.0, 1.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.2, NaN, 1.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.2, 1.0, NaN );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );
t.end();
});

tape( 'the function returns `NaN` if `p` is outside the interval `[0,1]`', function test( t ) {
var y = betaincinv( 1.5, 1.0, 1.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( -0.5, 1.0, 1.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );
t.end();
});

tape( 'if provided a nonpositive `a`, the function returns `NaN`', function test( t ) {
var y;

y = betaincinv( 0.5, 0.0, 2.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, -1.0, 2.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, -1.0, 2.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, NINF, 1.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, NINF, PINF );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, NINF, NINF );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, NINF, NaN );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

t.end();
});
Expand All @@ -99,25 +99,25 @@ tape( 'if provided a nonpositive `b`, the function returns `NaN`', function test
var y;

y = betaincinv( 0.5, 2.0, 0.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, 2.0, -1.0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, 2.0, -1/0 );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, 1.0, NINF );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, PINF, NINF );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, NINF, NINF );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = betaincinv( 0.5, NaN, NINF );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

t.end();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var betaln = require( './../lib' );
Expand All @@ -35,11 +35,12 @@ bench( pkg, function benchmark( b ) {
var z;
var i;

x = uniform( 100, 0.0, 1000.0 );
y = uniform( 100, 0.0, 1000.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*1000.0 ) - 0.0;
y = ( randu()*1000.0 ) - 0.0;
z = betaln( x, y );
z = betaln( x[ i % x.length ], y[ i % y.length ] );
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;
Expand All @@ -44,11 +44,12 @@ bench( pkg+'::native', opts, function benchmark( b ) {
var z;
var i;

x = uniform( 100, 0.0, 1000.0 );
y = uniform( 100, 0.0, 1000.0 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 1000.0 ) - 0.0;
y = ( randu() * 1000.0 ) - 0.0;
z = betaln( x, y );
z = betaln( x[ i % x.length ], y[ i % y.length ] );
if ( isnan( z ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,21 @@ static double rand_double( void ) {
* @return elapsed time in seconds
*/
static double benchmark( void ) {
double x[ 100 ];
double y[ 100 ];
double elapsed;
double x;
double y;
double z;
double t;
int i;

for ( i = 0; i < 100; i++ ) {
x[ i ] = 1000.0 * rand_double();
y[ i ] = 1000.0 * rand_double();
}

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
x = 1000.0 * rand_double() - 0.0;
y = 1000.0 * rand_double() - 0.0;
z = stdlib_base_betaln( x, y );
z = stdlib_base_betaln( x[ i%100 ], y[ i%100 ] );
if ( z != z ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ tape( 'main export is a function', function test( t ) {

tape( 'the function returns `NaN` if provided `x` outside `[-1.1,1.1]`', function test( t ) {
var y = dceval( 1.5, [1, 2, 3] );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = dceval( 1.11, [1, 2, 3] );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = dceval( -1.11, [1, 2, 3] );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

y = dceval( -1.5, [1, 2, 3] );
t.equal( isnan( y ), true, 'returns NaN' );
t.equal( isnan( y ), true, 'returns expected value' );

t.end();
});
Loading