From 4171dc4da526ee337469be78921fb14c8edc2a47 Mon Sep 17 00:00:00 2001 From: hrshya Date: Thu, 15 May 2025 16:12:54 +0530 Subject: [PATCH] bench: update random value generation --- .../base/dists/chi/cdf/benchmark/benchmark.js | 35 ++-- .../stats/base/dists/chi/cdf/test/test.cdf.js | 26 +-- .../base/dists/chi/cdf/test/test.factory.js | 24 +-- .../dists/chi/ctor/benchmark/benchmark.js | 186 +++++++++--------- .../dists/chi/entropy/benchmark/benchmark.js | 16 +- .../chi/entropy/benchmark/benchmark.native.js | 16 +- .../stats/base/dists/chi/entropy/test/test.js | 8 +- .../dists/chi/entropy/test/test.native.js | 8 +- .../dists/chi/kurtosis/benchmark/benchmark.js | 16 +- .../base/dists/chi/kurtosis/test/test.js | 8 +- .../dists/chi/logpdf/benchmark/benchmark.js | 35 ++-- .../dists/chi/logpdf/test/test.factory.js | 26 +-- .../base/dists/chi/logpdf/test/test.logpdf.js | 26 +-- .../dists/chi/mean/benchmark/benchmark.js | 16 +- .../chi/mean/benchmark/benchmark.native.js | 16 +- .../stats/base/dists/chi/mean/test/test.js | 6 +- .../base/dists/chi/mean/test/test.native.js | 6 +- 17 files changed, 228 insertions(+), 246 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/benchmark/benchmark.js index 0ff24d3497af..f23eb2303b82 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/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,23 +31,21 @@ var cdf = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var len; + var opts; var k; var x; var y; var i; - len = 100; - x = new Float64Array( len ); - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 100.0 ); - k[ i ] = discreteUniform( 1, 100 ); - } + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 100.0, opts ); + k = discreteUniform( 100, 1, 100, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = cdf( x[ i % len ], k[ i % len ] ); + y = cdf( x[ i % x.length ], k[ i % k.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -63,23 +60,23 @@ bench( pkg, function benchmark( b ) { bench( pkg+':factory', function benchmark( b ) { var mycdf; - var len; + var opts; var k; var x; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 100.0, opts ); + k = 10.0; mycdf = cdf.factory( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 100.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/chi/cdf/test/test.cdf.js b/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/test/test.cdf.js index e0d2a17e38d2..11c565ad625c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/test/test.cdf.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/test/test.cdf.js @@ -44,21 +44,21 @@ 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, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0, NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); tape( 'if provided `+infinity` for `x` and a finite `k`, the function returns `1`', function test( t ) { var y = cdf( PINF, 1.0 ); - t.equal( y, 1.0, 'returns 1' ); + t.equal( y, 1.0, 'returns expected value' ); t.end(); }); tape( 'if provided `-infinity` for `x` and a finite `k`, the function returns `0`', function test( t ) { var y = cdf( NINF, 1.0 ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); t.end(); }); @@ -66,13 +66,13 @@ tape( 'if provided a negative `k`, the function always returns `NaN`', function var y; y = cdf( 2.0, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 0.0, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = cdf( 2.0, NINF ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -81,22 +81,22 @@ tape( 'if provided a `k` equal to `0`, the function evaluates a degenerate distr var y; y = cdf( PINF, 0.0 ); - t.equal( y, 1.0, 'returns 1 for x greater than 0' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( 2.5, 0.0 ); - t.equal( y, 1.0, 'returns 1 for x greater than 0' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( 0.0, 0.0 ); - t.equal( y, 1.0, 'returns 1 for x equal to 0' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( -2.0, 0.0 ); - t.equal( y, 0.0, 'returns 0 for x smaller than 0' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( NINF, 0.0 ); - t.equal( y, 0.0, 'returns 0 for x smaller than 0' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( NaN, 0.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/chi/cdf/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/test/test.factory.js index 61baaa445c18..a58994bd9927 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/cdf/test/test.factory.js @@ -54,11 +54,11 @@ tape( 'if provided `NaN` for any parameter, the created function returns `NaN`', cdf = factory( 1.0 ); y = cdf( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); cdf = factory( NaN ); y = cdf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -69,7 +69,7 @@ tape( 'if provided a finite `k`, the function returns a function which returns ` cdf = factory( 1.0 ); y = cdf( PINF ); - t.equal( y, 1.0, 'returns 1' ); + t.equal( y, 1.0, 'returns expected value' ); t.end(); }); @@ -80,7 +80,7 @@ tape( 'if provided a finite `k`, the function returns a function which returns ` cdf = factory( 0.0, 1.0 ); y = cdf( NINF ); - t.equal( y, 0.0, 'returns 0' ); + t.equal( y, 0.0, 'returns expected value' ); t.end(); }); @@ -92,10 +92,10 @@ tape( 'if provided a negative `k`, the created function always returns `NaN`', f cdf = factory( -1.0 ); 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' ); t.end(); }); @@ -107,22 +107,22 @@ tape( 'if `k` equals `0`, the created function evaluates a degenerate distributi cdf = factory( 0.0 ); y = cdf( PINF ); - t.equal( y, 1.0, 'returns 1 for x greater than one' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( 3.0 ); - t.equal( y, 1.0, 'returns 1 for x greater than 0' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( 0.0 ); - t.equal( y, 1.0, 'returns 1 for x equal to 0' ); + t.equal( y, 1.0, 'returns expected value' ); y = cdf( -0.5 ); - t.equal( y, 0.0, 'returns 0 for x smaller than one' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( NINF ); - t.equal( y, 0.0, 'returns 0 for x smaller than one' ); + t.equal( y, 0.0, 'returns expected value' ); y = cdf( NaN ); - 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/chi/ctor/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chi/ctor/benchmark/benchmark.js index 7c4fce9734e0..554c11f34a63 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/ctor/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/ctor/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +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; @@ -33,19 +32,18 @@ var Chi = require( './../lib' ); bench( pkg+'::instantiation', function benchmark( b ) { var dist; - var len; + var opts; var i; var k; - len = 100; - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - k[ i ] = uniform( EPS, 10.0 ); - } + opts = { + 'dtype': 'float64' + }; + k = uniform( 100, EPS, 10.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist = new Chi( k[ i % len ] ); + dist = new Chi( k[ i % k.length ] ); if ( !( dist instanceof Chi ) ) { b.fail( 'should return a distribution instance' ); } @@ -84,23 +82,23 @@ bench( pkg+'::get:k', function benchmark( b ) { bench( pkg+'::set:k', function benchmark( b ) { var dist; - var len; + var opts; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + y = uniform( 100, EPS, 10.0, opts ); + k = 5.54; dist = new Chi( k ); - len = 100; - y = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - y[ i ] = uniform( EPS, 10.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.k = y[ i % len ]; - if ( dist.k !== y[ i % len ] ) { + dist.k = y[ i % y.length ]; + if ( dist.k !== y[ i % y.length ] ) { b.fail( 'should return set value' ); } } @@ -114,23 +112,23 @@ bench( pkg+'::set:k', function benchmark( b ) { bench( pkg+':entropy', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, EPS, 10.0, opts ); + k = 5.54; dist = new Chi( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( EPS, 10.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.k = x[ i % len ]; + dist.k = x[ i % x.length ]; y = dist.entropy; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -146,23 +144,23 @@ bench( pkg+':entropy', function benchmark( b ) { bench( pkg+':kurtosis', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 1.0 + EPS, 10.0, opts ); + k = 5.54; dist = new Chi( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 1.0 + EPS, 10.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.k = x[ i % len ]; + dist.k = x[ i % x.length ]; y = dist.kurtosis; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -178,23 +176,23 @@ bench( pkg+':kurtosis', function benchmark( b ) { bench( pkg+':mean', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, EPS, 10.0, opts ); + k = 5.54; dist = new Chi( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( EPS, 10.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.k = x[ i % len ]; + dist.k = x[ i % x.length ]; y = dist.mean; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -210,23 +208,23 @@ bench( pkg+':mean', function benchmark( b ) { bench( pkg+':mode', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 1.0 + EPS, 10.0, opts ); + k = 5.54; dist = new Chi( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 1.0 + EPS, 10.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.k = x[ i % len ]; + dist.k = x[ i % x.length ]; y = dist.mode; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -242,23 +240,23 @@ bench( pkg+':mode', function benchmark( b ) { bench( pkg+':skewness', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 1.0 + EPS, 10.0, opts ); + k = 5.54; dist = new Chi( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 1.0 + EPS, 10.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.k = x[ i % len ]; + dist.k = x[ i % x.length ]; y = dist.skewness; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -274,23 +272,23 @@ bench( pkg+':skewness', function benchmark( b ) { bench( pkg+':stdev', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 1.0 + EPS, 10.0, opts ); + k = 5.54; dist = new Chi( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 1.0 + EPS, 10.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.k = x[ i % len ]; + dist.k = x[ i % x.length ]; y = dist.stdev; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -306,23 +304,23 @@ bench( pkg+':stdev', function benchmark( b ) { bench( pkg+':variance', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 1.0 + EPS, 10.0, opts ); + k = 5.54; dist = new Chi( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 1.0 + EPS, 10.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - dist.k = x[ i % len ]; + dist.k = x[ i % x.length ]; y = dist.variance; if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -338,23 +336,23 @@ bench( pkg+':variance', function benchmark( b ) { bench( pkg+':cdf', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + k = 5.54; dist = new Chi( k ); - 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' ); } @@ -369,23 +367,23 @@ bench( pkg+':cdf', function benchmark( b ) { bench( pkg+':logpdf', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + k = 5.54; dist = new Chi( k ); - 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.logpdf( x[ i % len ] ); + y = dist.logpdf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -400,23 +398,23 @@ bench( pkg+':logpdf', function benchmark( b ) { bench( pkg+':pdf', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + k = 5.54; dist = new Chi( k ); - 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.pdf( x[ i % len ] ); + y = dist.pdf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -431,23 +429,23 @@ bench( pkg+':pdf', function benchmark( b ) { bench( pkg+':quantile', function benchmark( b ) { var dist; - var len; + var opts; var x; var y; var i; var k; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + k = 5.54; dist = new Chi( k ); - 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/chi/entropy/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark/benchmark.js index 3313b7f39017..bf466f3843f9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +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; @@ -32,20 +31,19 @@ var entropy = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var len; + var opts; var k; var y; var i; - len = 100; - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - k[ i ] = uniform( EPS, 20.0 ); - } + opts = { + 'dtype': 'float64' + }; + k = uniform( 100, EPS, 20.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = entropy( k[ i % len ] ); + y = entropy( k[ i % k.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark/benchmark.native.js index ddb681e3c4df..27b7c09ef76b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +var uniform = require( '@stdlib/random/array/uniform' ); var EPS = require( '@stdlib/constants/float64/eps' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -41,20 +40,19 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { - var len; + var opts; var k; var y; var i; - len = 100; - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - k[ i ] = uniform( EPS, 20.0 ); - } + opts = { + 'dtype': 'float64' + }; + k = uniform( 100, EPS, 20.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = entropy( k[ i % len ] ); + y = entropy( k[ i % k.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.js index 15f115b13a7a..3d86a688db79 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.js @@ -43,7 +43,7 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided `NaN` for `k`, the function returns `NaN`', function test( t ) { var v = entropy( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -51,13 +51,13 @@ tape( 'if provided a degrees of freedom parameter `k` that is not a positive num var v; v = entropy( 0.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.native.js index 760baa76c24b..7e4f00c9cb68 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/entropy/test/test.native.js @@ -52,7 +52,7 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'if provided `NaN` for `k`, the function returns `NaN`', opts, function test( t ) { var v = entropy( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -60,13 +60,13 @@ tape( 'if provided a degrees of freedom parameter `k` that is not a positive num var v; v = entropy( 0.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = entropy( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/kurtosis/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chi/kurtosis/benchmark/benchmark.js index cafaf285d900..0a366d60ab11 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/kurtosis/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/kurtosis/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +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; @@ -32,20 +31,19 @@ var kurtosis = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var len; + var opts; var k; var y; var i; - len = 100; - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - k[ i ] = uniform( EPS, 20.0 ); - } + opts = { + 'dtype': 'float64' + }; + k = uniform( 100, EPS, 20.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = kurtosis( k[ i % len ] ); + y = kurtosis( k[ i % k.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/kurtosis/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/chi/kurtosis/test/test.js index 188fe2cde34e..c39101feb50a 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/kurtosis/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/kurtosis/test/test.js @@ -42,7 +42,7 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided `NaN` for `k`, the function returns `NaN`', function test( t ) { var v = kurtosis( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -50,13 +50,13 @@ tape( 'if provided a degrees of freedom parameter `k` that is not a positive num var v; v = kurtosis( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = kurtosis( 0.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = kurtosis( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/benchmark/benchmark.js index 8b4df406f3d0..8fb1296f243b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/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 logpdf = require( './../lib' ); @@ -32,23 +31,21 @@ var logpdf = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var len; + var opts; var k; var x; var y; var i; - len = 100; - x = new Float64Array( len ); - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 100.0 ); - k[ i ] = discreteUniform( 1, 100 ); - } + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 100.0, opts ); + k = discreteUniform( 100, 1, 100, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = logpdf( x[ i % len ], k[ i % len ] ); + y = logpdf( x[ i % x.length ], k[ i % k.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -63,23 +60,23 @@ bench( pkg, function benchmark( b ) { bench( pkg+':factory', function benchmark( b ) { var mylogpdf; - var len; + var opts; var k; var x; var y; var i; + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 100.0, opts ); + k = 10.0; mylogpdf = logpdf.factory( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 100.0 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mylogpdf( x[ i % len ] ); + y = mylogpdf( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/test/test.factory.js index addde0078e9a..49dc23fdf14d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/test/test.factory.js @@ -55,11 +55,11 @@ tape( 'if provided `NaN` for any parameter, the created function returns `NaN`', logpdf = factory( 1.0 ); y = logpdf( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); logpdf = factory( NaN ); y = logpdf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -70,7 +70,7 @@ tape( 'if provided a finite `k`, the function returns a function which returns ` logpdf = factory( 1.0 ); y = logpdf( PINF ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); t.end(); }); @@ -81,7 +81,7 @@ tape( 'if provided a finite `k`, the function returns a function which returns ` logpdf = factory( 1.0 ); y = logpdf( NINF ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); t.end(); }); @@ -93,10 +93,10 @@ tape( 'if provided a negative `k`, the created function always returns `NaN`', f logpdf = factory( -1.0 ); y = logpdf( 2.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = logpdf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -108,22 +108,22 @@ tape( 'if `k` equals `0`, the created function evaluates a degenerate distributi logpdf = factory( 0.0 ); y = logpdf( -2.0 ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); y = logpdf( 0.0 ); - t.equal( y, PINF, 'returns Infinity for x equal to 0' ); + t.equal( y, PINF, 'returns expected value' ); y = logpdf( 1.0 ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); y = logpdf( PINF ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); y = logpdf( NINF ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); y = logpdf( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -138,7 +138,7 @@ tape( 'the returned function returns `-Infinity` for all `x < 0`', function test for ( i = 0; i < 100; i++ ) { x = -( randu()*100.0 ) - EPS; y = logpdf( x ); - t.equal( y, NINF, 'returns -Infinity for x='+x ); + t.equal( y, NINF, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/test/test.logpdf.js b/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/test/test.logpdf.js index bde03f05d359..b1bb48ba460e 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/test/test.logpdf.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/logpdf/test/test.logpdf.js @@ -45,21 +45,21 @@ 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 = logpdf( NaN, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = logpdf( 0.0, NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); tape( 'if provided `+infinity` for `x` and a finite `k`, the function returns `-Infinity`', function test( t ) { var y = logpdf( PINF, 1.0 ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); t.end(); }); tape( 'if provided `-infinity` for `x` and a finite `k`, the function returns `-Infinity`', function test( t ) { var y = logpdf( NINF, 1.0 ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); t.end(); }); @@ -67,13 +67,13 @@ tape( 'if provided a negative `k`, the function always returns `NaN`', function var y; y = logpdf( 2.0, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = logpdf( 0.0, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = logpdf( 2.0, NINF ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -85,19 +85,19 @@ tape( 'if `k` equals `0`, the function evaluates a degenerate distribution cente t.equal( y, PINF, 'returns Infinity for x equal to 0' ); y = logpdf( 1.0, 0.0 ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); y = logpdf( -1.5, 0.0 ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); y = logpdf( PINF, 0.0 ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); y = logpdf( NINF, 0.0 ); - t.equal( y, NINF, 'returns -Infinity' ); + t.equal( y, NINF, 'returns expected value' ); y = logpdf( NaN, 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -110,7 +110,7 @@ tape( 'the function returns `-Infinity` for all `x < 0`', function test( t ) { for ( i = 0; i < 100; i++ ) { x = -( randu()*100.0 ) - EPS; y = logpdf( x, 1.0 ); - t.equal( y, NINF, 'returns -Infinity for x='+x ); + t.equal( y, NINF, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chi/mean/benchmark/benchmark.js index d6959d8e722c..3cbff601cd53 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/mean/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/mean/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +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; @@ -32,20 +31,19 @@ var mean = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var len; + var opts; var k; var y; var i; - len = 100; - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - k[ i ] = uniform( EPS, 20.0 ); - } + opts = { + 'dtype': 'float64' + }; + k = uniform( 100, EPS, 20.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mean( k[ i % len ] ); + y = mean( k[ i % k.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/mean/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/chi/mean/benchmark/benchmark.native.js index dd4f2c38adc2..d3347c105357 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/mean/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/mean/benchmark/benchmark.native.js @@ -22,8 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); -var uniform = require( '@stdlib/random/base/uniform' ); +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; @@ -40,20 +39,19 @@ var opts = { // MAIN // bench( pkg + '::native', opts, function benchmark( b ) { - var len; + var opts; var k; var y; var i; - len = 100; - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - k[ i ] = uniform( 1.0, 10.0 ); - } + opts = { + 'dtype': 'float64' + }; + k = uniform( 100, 1.0, 10.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mean( k[ i % len ] ); + y = mean( k[ i % k.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/mean/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/chi/mean/test/test.js index bb02f47ea3b7..9a8ee1414673 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/mean/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/mean/test/test.js @@ -43,7 +43,7 @@ tape( 'main export is a function', function test( t ) { tape( 'if provided `NaN` for `k`, the function returns `NaN`', function test( t ) { var v = mean( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -51,10 +51,10 @@ tape( 'if provided a degrees of freedom parameter `k` that is not a nonnegative var v; v = mean( -1.0 ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); v = mean( NINF ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/chi/mean/test/test.native.js index 00c9a6e86a27..7af2c2fc3d73 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/mean/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/mean/test/test.native.js @@ -51,7 +51,7 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'if provided `NaN` for the parameter, the function returns `NaN`', opts, function test( t ) { var y = mean( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -59,10 +59,10 @@ tape( 'if provided a non-positive `k`, the function returns `NaN`', opts, functi var y; y = mean( -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mean( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); });