Skip to content
Open
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,8 +21,9 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var ceil = require( '@stdlib/math/base/special/ceil' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
Comment on lines +24 to +26
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you refactor this to use @stdlib/random/array/uniform and @stdlib/random/array/discrete-uniform instead? In that way, you won't need Float64Array. Just as done here in this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment applies to the other file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the same changes to their respective benchmark.native.js files as well please? Thanks!

var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var cdf = require( './../lib' );
Expand All @@ -31,16 +32,23 @@
// MAIN //

bench( pkg, function benchmark( b ) {
var len;
var n;
var x;
var y;
var i;

len = 100;
x = new Float64Array( len );
n = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( 0.0, 20.0 );
n[ i ] = discreteUniform( 1, 20 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = randu() * 20.0;
n = ceil( randu()*20.0 );
y = cdf( x, n );
y = cdf( x[ i % len ], n[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -53,20 +61,25 @@
b.end();
});

bench( pkg+':factory', function benchmark( b ) {

Check warning on line 64 in lib/node_modules/@stdlib/stats/base/dists/signrank/cdf/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Use `@stdlib/string/format` instead of string concatenation for benchmark descriptions
var mycdf;
var len;
var n;
var x;
var y;
var i;

n = 20;
len = 100;
mycdf = cdf.factory( n );
x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( 0.0, 20.0 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = randu() * 20.0;
y = mycdf( x );
y = mycdf( 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,8 +21,9 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var randint = require( '@stdlib/random/base/discrete-uniform' );
var Float64Array = require( '@stdlib/array/float64' );
var uniform = require( '@stdlib/random/base/uniform' );
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var quantile = require( './../lib' );
Expand All @@ -31,16 +32,23 @@
// MAIN //

bench( pkg, function benchmark( b ) {
var len;
var n;
var p;
var y;
var i;

len = 100;
p = new Float64Array( len );
n = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
p[ i ] = uniform( 0.0, 1.0 );
n[ i ] = discreteUniform( 1, 200 );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
p = randu();
n = randint( 1, 200 );
y = quantile( p, n );
y = quantile( p[ i % len ], n[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand All @@ -53,20 +61,25 @@
b.end();
});

bench( pkg+':factory', function benchmark( b ) {

Check warning on line 64 in lib/node_modules/@stdlib/stats/base/dists/signrank/quantile/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Use `@stdlib/string/format` instead of string concatenation for benchmark descriptions
var myquantile;
var len;
var n;
var p;
var y;
var i;

n = 8;
len = 100;
p = new Float64Array( len );
myquantile = quantile.factory( n );
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