diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/benchmark/benchmark.js index 2a4bd4033ba9..9d85d6e7ff71 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/benchmark/benchmark.js @@ -21,9 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/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 cdf = require( './../lib' ); @@ -32,26 +31,23 @@ var cdf = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var len; + var opts; var n; var p; var x; var y; var i; - len = 100; - x = new Float64Array( len ); - n = new Float64Array( len ); - p = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 100.0 ); - n[ i ] = discreteUniform( 1, 100 ); - p[ i ] = uniform( 0.0, 1.0 ); - } + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 100.0, opts ); + n = discreteUniform( 100, 1, 100, opts ); + p = uniform( 100, 0, 1, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = cdf( x[ i % len ], n[ i % len ], p[ i % len ] ); + y = cdf( x[ i % x.length ], n[ i % n.length ], p[ i % p.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -66,25 +62,25 @@ bench( pkg, function benchmark( b ) { bench( pkg+':factory', function benchmark( b ) { var mycdf; - var len; + var opts; var n; var p; var x; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 80.0, opts ); + n = 80; p = 0.4; mycdf = cdf.factory( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 80.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mycdf( x[ i % len ] ); + y = mycdf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/test/test.cdf.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/test/test.cdf.js index 45d6ad58cf09..d78e6917825f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/test/test.cdf.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/test/test.cdf.js @@ -47,36 +47,36 @@ 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 = cdf( NaN, 10, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0, NaN, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0, 10, NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); tape( 'if provided an `x` greater than or equal to `n`, the function returns `1` (provided `n` and `p` are valid)', function test( t ) { var y = cdf( PINF, 20, 0.5 ); - t.equal( y, 1.0, 'returns 1' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( 200, 20, 0.5 ); - t.equal( y, 1.0, 'returns 1' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( 21, 20, 0.5 ); - t.equal( y, 1.0, 'returns 1' ); + t.equal( y, 1.0, 'returns expected value' ); t.end(); }); tape( 'if provided a negative number for `x` and a valid `n` and `p`, the function returns `0`', function test( t ) { var y = cdf( NINF, 20, 0.5 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( -10.0, 20, 0.5 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( -1.0, 20, 0.5 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); t.end(); }); @@ -85,19 +85,19 @@ tape( 'if provided a `n` which is not a nonnegative integer, the function return var y; y = cdf( 2.0, 1.5, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 2.0, -2, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 2.0, -1, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0, 2.5, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0, PINF, 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -106,16 +106,16 @@ tape( 'if provided a success probability `p` outside of `[0,1]`, the function re var y; y = cdf( 2.0, 20, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0, 20, 1.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 2.0, 20, NINF ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 2.0, 20, PINF ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/test/test.factory.js index 9ed047c05e48..2c2245a00620 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/cdf/test/test.factory.js @@ -57,23 +57,23 @@ tape( 'if provided `NaN` for any parameter, the created function returns `NaN`', cdf = factory( 20, 0.5 ); y = cdf( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( NaN, 0.5 ); y = cdf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( 20, NaN ); y = cdf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( NaN, NaN ); y = cdf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( NaN, NaN ); y = cdf( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -84,13 +84,13 @@ tape( 'if provided a valid `n` and `p`, the function returns a function which re cdf = factory( 20, 0.5 ); y = cdf( PINF ); - t.equal( y, 1.0, 'returns 1' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( 200.0 ); - t.equal( y, 1.0, 'returns 1' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( 20.0 ); - t.equal( y, 1.0, 'returns 1' ); + t.equal( y, 1.0, 'returns expected value' ); t.end(); }); @@ -101,16 +101,16 @@ tape( 'if provided a valid `n` and `p`, the function returns a function which re cdf = factory( 20, 0.5 ); y = cdf( NINF ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( -10.0 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( -1.0 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( -0.5 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); t.end(); }); @@ -122,22 +122,22 @@ tape( 'if provided a `n` which is not a nonnegative integer, the created functio cdf = factory( 20.5, 0.5 ); y = cdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( -10, 0.5 ); y = cdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( PINF, 0.5 ); y = cdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( NINF, 0.5 ); y = cdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -149,22 +149,22 @@ tape( 'if provided a success probability `p` outside `[0,1]`, the created functi cdf = factory( 20, 1.5 ); y = cdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( 20, -0.5 ); y = cdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( 20, PINF ); y = cdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( 20, NINF ); y = cdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/ctor/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/ctor/benchmark/benchmark.js index f05dc876ac04..c9b361039af9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/ctor/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/ctor/benchmark/benchmark.js @@ -21,9 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var EPS = require( '@stdlib/constants/float64/eps' ); var pkg = require( './../package.json' ).name; @@ -34,22 +33,20 @@ var Binomial = require( './../lib' ); bench( pkg+'::instantiation', function benchmark( b ) { var dist; - var len; + var opts; var n; var p; var i; - len = 100; - n = new Float64Array( len ); - p = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - n[ i ] = discreteUniform( 1, 50 ); - p[ i ] = uniform( EPS, 1.0 ); - } + opts = { + 'dtype': 'float64' + }; + n = discreteUniform( 100, 1, 50, opts ); + p = uniform( 100, EPS, 1.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist = new Binomial( n[ i % len ], p[ i % len ] ); + dist = new Binomial( n[ i % n.length ], p[ i % p.length ] ); if ( !( dist instanceof Binomial ) ) { b.fail( 'should return a distribution instance' ); } @@ -90,25 +87,25 @@ bench( pkg+'::get:n', function benchmark( b ) { bench( pkg+'::set:n', function benchmark( b ) { var dist; - var len; + var opts; var n; var p; var y; var i; + opts = { + 'dtype': 'float64' + }; + y = discreteUniform( 100, 1, 50, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - y = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - y[ i ] = discreteUniform( 1, 50 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.n = y[ i % len ]; - if ( dist.n !== y[ i % len ] ) { + dist.n = y[ i % y.length ]; + if ( dist.n !== y[ i % y.length ] ) { b.fail( 'should return set value' ); } } @@ -148,25 +145,25 @@ bench( pkg+'::get:p', function benchmark( b ) { bench( pkg+'::set:p', function benchmark( b ) { var dist; - var len; + var opts; var n; var p; var y; var i; + opts = { + 'dtype': 'float64' + }; + y = uniform( 100, EPS, 1.0, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - y = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - y[ i ] = uniform( EPS, 1.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.p = y[ i % len ]; - if ( dist.p !== y[ i % len ] ) { + dist.p = y[ i % y.length ]; + if ( dist.p !== y[ i % y.length ] ) { b.fail( 'should return set value' ); } } @@ -180,25 +177,25 @@ bench( pkg+'::set:p', function benchmark( b ) { bench( pkg+':kurtosis', function benchmark( b ) { var dist; - var len; + var opts; var x; var n; var p; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = discreteUniform( 100, 1, 100, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = discreteUniform( 1, 100 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.n = x[ i % len ]; + dist.n = x[ i % x.length ]; y = dist.kurtosis; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -214,25 +211,25 @@ bench( pkg+':kurtosis', function benchmark( b ) { bench( pkg+':mean', function benchmark( b ) { var dist; - var len; + var opts; var x; var n; var p; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = discreteUniform( 100, 1, 100, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = discreteUniform( 1, 100 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.n = x[ i % len ]; + dist.n = x[ i % x.length ]; y = dist.mean; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -248,25 +245,25 @@ bench( pkg+':mean', function benchmark( b ) { bench( pkg+':mode', function benchmark( b ) { var dist; - var len; + var opts; var x; var n; var p; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = discreteUniform( 100, 1, 100, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = discreteUniform( 1, 100 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.n = x[ i % len ]; + dist.n = x[ i % x.length ]; y = dist.mode; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -282,25 +279,25 @@ bench( pkg+':mode', function benchmark( b ) { bench( pkg+':skewness', function benchmark( b ) { var dist; - var len; + var opts; var x; var n; var p; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = discreteUniform( 100, 1, 100, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = discreteUniform( 1, 100 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.n = x[ i % len ]; + dist.n = x[ i % x.length ]; y = dist.skewness; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -316,25 +313,25 @@ bench( pkg+':skewness', function benchmark( b ) { bench( pkg+':stdev', function benchmark( b ) { var dist; - var len; + var opts; var x; var n; var p; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = discreteUniform( 100, 1, 100, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = discreteUniform( 1, 100 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.n = x[ i % len ]; + dist.n = x[ i % x.length ]; y = dist.stdev; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -350,25 +347,25 @@ bench( pkg+':stdev', function benchmark( b ) { bench( pkg+':variance', function benchmark( b ) { var dist; - var len; + var opts; var x; var n; var p; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = discreteUniform( 100, 1, 100, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = discreteUniform( 1, 100 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.n = x[ i % len ]; + dist.n = x[ i % x.length ]; y = dist.variance; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -384,25 +381,25 @@ bench( pkg+':variance', function benchmark( b ) { bench( pkg+':cdf', function benchmark( b ) { var dist; - var len; + var opts; var n; var p; var x; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 1.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = dist.cdf( x[ i % len ] ); + y = dist.cdf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -417,7 +414,7 @@ bench( pkg+':cdf', function benchmark( b ) { bench( pkg+':logpmf', function benchmark( b ) { var dist; - var len; + var opts; var n; var p; var x; @@ -427,15 +424,14 @@ bench( pkg+':logpmf', function benchmark( b ) { n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = discreteUniform( 0, n ); - } + opts = { + 'dtype': 'float64' + }; + x = discreteUniform( 100, 0, n, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = dist.logpmf( x[ i % len ] ); + y = dist.logpmf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -450,25 +446,25 @@ bench( pkg+':logpmf', function benchmark( b ) { bench( pkg+':mgf', function benchmark( b ) { var dist; - var len; + var opts; var n; var p; var x; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 1.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = dist.mgf( x[ i % len ] ); + y = dist.mgf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -483,7 +479,7 @@ bench( pkg+':mgf', function benchmark( b ) { bench( pkg+':pmf', function benchmark( b ) { var dist; - var len; + var opts; var n; var p; var x; @@ -493,15 +489,14 @@ bench( pkg+':pmf', function benchmark( b ) { n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = discreteUniform( 0, n ); - } + opts = { + 'dtype': 'float64' + }; + x = discreteUniform( 100, 0, n, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = dist.pmf( x[ i % len ] ); + y = dist.pmf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -516,25 +511,25 @@ bench( pkg+':pmf', function benchmark( b ) { bench( pkg+':quantile', function benchmark( b ) { var dist; - var len; + var opts; var n; var p; var x; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + n = 40; p = 0.6; dist = new Binomial( n, p ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 1.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = dist.quantile( x[ i % len ] ); + y = dist.quantile( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/entropy/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/entropy/benchmark/benchmark.js index 63028323aabf..672b9f567313 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/entropy/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/entropy/benchmark/benchmark.js @@ -21,9 +21,8 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); -var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var uniform = require( '@stdlib/random/array/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 entropy = require( './../lib' ); @@ -32,23 +31,21 @@ var entropy = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var len; + var opts; var n; var p; var y; var i; - len = 1000; - n = new Float64Array( len ); - p = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - n[ i ] = discreteUniform( 1, 100 ); - p[ i ] = uniform( 0.0, 1.0 ); - } + opts = { + 'dtype': 'float64' + }; + n = discreteUniform( 1000, 1, 100, opts ); + p = uniform( 1000, 0.0, 1.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = entropy( n[ i % len ], p[ i % len ] ); + y = entropy( n[ i % n.length ], p[ i % p.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/entropy/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/binomial/entropy/test/test.js index ed6452d55317..fc90bf213232 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/entropy/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/entropy/test/test.js @@ -44,13 +44,13 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided `NaN` for any parameter, the function returns `NaN`', function test( t ) { var v = entropy( NaN, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( 10, NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( NaN, NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -59,19 +59,19 @@ tape( 'if provided an `n` which is not a nonnegative integer, the function retur var v; v = entropy( 1.5, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( -2, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( -1, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( 2.5, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( PINF, 0.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -80,16 +80,16 @@ tape( 'if provided a success probability `p` outside of `[0,1]`, the function re var v; v = entropy( 20, -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( 20, 1.5 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( 20, NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( 20, PINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -97,10 +97,10 @@ tape( 'if provided a success probability `p` outside of `[0,1]`, the function re tape( 'the function returns `0` for `p` equal to `1` or `0`', function test( t ) { var y; y = entropy( 3, 1.0 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); y = entropy( 3, 0.0 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); t.end(); }); @@ -108,7 +108,7 @@ tape( 'the function returns `0` for `p` equal to `1` or `0`', function test( t ) tape( 'the function returns `0` for `n` equal to `0`', function test( t ) { var y; y = entropy( 0, 0.5 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); t.end(); });