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

Large diffs are not rendered by default.

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

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
Expand All @@ -32,16 +33,24 @@ var logcdf = require( './../lib' );
bench( pkg, function benchmark( b ) {
var min;
var max;
var len;
var x;
var y;
var i;

len = 100;
x = new Float64Array( len );
min = new Float64Array( len );
max = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -10.0, 10.0 );
min[ i ] = uniform( -20.0, 0.0 );
max[ i ] = uniform( min[ i ], min[ i ] + 40.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = uniform( -10.0, 10.0 );
min = uniform( -20.0, 0.0 );
max = uniform( min, min + 40.0 );
y = logcdf( x, min, max );
y = logcdf( x[ i % len ], min[ i % len ], max[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -58,18 +67,23 @@ bench( pkg+':factory', function benchmark( b ) {
var mylogcdf;
var min;
var max;
var len;
var x;
var y;
var i;

min = -1.5;
max = 1.5;
mylogcdf = logcdf.factory( min, max );
len = 100;
x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -2.0, 0.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = uniform( -2.0, 0.0 );
y = mylogcdf( x );
y = mylogcdf( x[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
Expand All @@ -32,16 +33,24 @@ var logpdf = require( './../lib' );
bench( pkg, function benchmark( b ) {
var min;
var max;
var len;
var x;
var y;
var i;

len = 100;
x = new Float64Array( len );
min = new Float64Array( len );
max = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -10.0, 10.0 );
min[ i ] = uniform( -20.0, 0.0 );
max[ i ] = uniform( min[ i ], min[ i ] + 40.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = uniform( -10.0, 10.0 );
min = uniform( -20.0, 0.0 );
max = uniform( min, min + 40.0 );
y = logpdf( x, min, max );
y = logpdf( x[ i % len ], min[ i % len ], max[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -58,18 +67,23 @@ bench( pkg+':factory', function benchmark( b ) {
var mylogpdf;
var min;
var max;
var len;
var x;
var y;
var i;

min = -1.5;
max = 1.5;
mylogpdf = logpdf.factory( min, max );
len = 100;
x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -2.0, 0.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = uniform( -2.0, 0.0 );
y = mylogpdf( x );
y = mylogpdf( x[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
Expand All @@ -32,14 +33,21 @@ var mean = require( './../lib' );
bench( pkg, function benchmark( b ) {
var min;
var max;
var len;
var y;
var i;

len = 100;
min = new Float64Array( len );
max = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
min[ i ] = uniform( 0.0, 10.0 );
max[ i ] = uniform( min[ i ], min[ i ] + 10.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
min = uniform( 0.0, 10.0 );
max = uniform( min, min + 10.0 );
y = mean( min, max );
y = mean( min[ i % len ], max[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
Expand All @@ -32,14 +33,21 @@ var median = require( './../lib' );
bench( pkg, function benchmark( b ) {
var min;
var max;
var len;
var y;
var i;

len = 100;
min = new Float64Array( len );
max = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
min[ i ] = uniform( 0.0, 10.0 );
max[ i ] = uniform( min[ i ], min[ i ] + 10.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
min = uniform( 0.0, 10.0 );
max = uniform( min, min + 10.0 );
y = median( min, max );
y = median( min[ i % len ], max[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
Expand All @@ -32,14 +33,21 @@ var mode = require( './../lib' );
bench( pkg, function benchmark( b ) {
var min;
var max;
var len;
var y;
var i;

len = 100;
min = new Float64Array( len );
max = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
min[ i ] = uniform( 0.0, 10.0 );
max[ i ] = uniform( min[ i ], min[ i ] + 10.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
min = uniform( 0.0, 10.0 );
max = uniform( min, min + 10.0 );
y = mode( min, max );
y = mode( min[ i % len ], max[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );
Expand Down Expand Up @@ -51,7 +50,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
min = new Float64Array( len );
max = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
min[ i ] = ( randu()*10.0 );
min[ i ] = uniform( 0.0, 10.0 );
max[ i ] = uniform( min[ i ], min[ i ] + 10.0 );
}

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

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
Expand All @@ -32,16 +33,24 @@ var pdf = require( './../lib' );
bench( pkg, function benchmark( b ) {
var min;
var max;
var len;
var x;
var y;
var i;

len = 100;
x = new Float64Array( len );
min = new Float64Array( len );
max = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -10.0, 10.0 );
min[ i ] = uniform( -20.0, 0.0 );
max[ i ] = uniform( min[ i ], min[ i ] + 40.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = uniform( -10.0, 10.0 );
min = uniform( -20.0, 0.0 );
max = uniform( min, min + 40.0 );
y = pdf( x, min, max );
y = pdf( x[ i % len ], min[ i % len ], max[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -58,18 +67,23 @@ bench( pkg+':factory', function benchmark( b ) {
var mypdf;
var min;
var max;
var len;
var x;
var y;
var i;

min = -1.5;
max = 1.5;
mypdf = pdf.factory( min, max );
len = 100;
x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -2.0, 0.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = uniform( -2.0, 0.0 );
y = mypdf( x );
y = mypdf( x[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
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 Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
Expand All @@ -33,16 +33,24 @@ var quantile = require( './../lib' );
bench( pkg, function benchmark( b ) {
var min;
var max;
var len;
var p;
var y;
var i;

len = 100;
p = new Float64Array( len );
min = new Float64Array( len );
max = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
p[ i ] = uniform( 0.0, 1.0 );
min[ i ] = uniform( -20.0, 0.0 );
max[ i ] = uniform( min[ i ], min[ i ] + 40.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
p = randu();
min = uniform( -20.0, 0.0 );
max = uniform( min, min + 40.0 );
y = quantile( p, min, max );
y = quantile( p[ i % len ], min[ i % len ], max[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -59,18 +67,23 @@ bench( pkg+':factory', function benchmark( b ) {
var myquantile;
var min;
var max;
var len;
var p;
var y;
var i;

min = -1.5;
max = 1.5;
myquantile = quantile.factory( min, max );
len = 100;
p = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
p[ i ] = uniform( 0.0, 1.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
p = randu();
y = myquantile( p );
y = myquantile( p[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Loading
Loading