From 3cfd70620a9040b6f667d3557377b61ffc9bacc5 Mon Sep 17 00:00:00 2001 From: hrshya Date: Sun, 18 May 2025 12:42:13 +0530 Subject: [PATCH 1/2] bench: update random value generation --- .../chisquare/cdf/benchmark/benchmark.js | 35 ++-- .../base/dists/chisquare/cdf/test/test.cdf.js | 26 +-- .../dists/chisquare/cdf/test/test.factory.js | 24 +-- .../chisquare/ctor/benchmark/benchmark.js | 186 +++++++++--------- .../chisquare/entropy/benchmark/benchmark.js | 16 +- .../entropy/benchmark/benchmark.native.js | 16 +- .../base/dists/chisquare/entropy/test/test.js | 8 +- .../chisquare/entropy/test/test.native.js | 8 +- .../chisquare/kurtosis/benchmark/benchmark.js | 16 +- .../kurtosis/benchmark/benchmark.native.js | 16 +- .../dists/chisquare/kurtosis/test/test.js | 8 +- .../chisquare/kurtosis/test/test.native.js | 8 +- .../chisquare/logpdf/benchmark/benchmark.js | 35 ++-- .../chisquare/logpdf/test/test.factory.js | 26 +-- .../chisquare/logpdf/test/test.logpdf.js | 28 +-- .../chisquare/mean/benchmark/benchmark.js | 16 +- .../mean/benchmark/benchmark.native.js | 16 +- .../base/dists/chisquare/mean/test/test.js | 6 +- .../dists/chisquare/mean/test/test.native.js | 6 +- .../chisquare/median/benchmark/benchmark.js | 16 +- .../base/dists/chisquare/median/test/test.js | 6 +- .../chisquare/mgf/benchmark/benchmark.js | 35 ++-- .../mgf/benchmark/benchmark.native.js | 21 +- .../dists/chisquare/mgf/test/test.factory.js | 12 +- .../base/dists/chisquare/mgf/test/test.mgf.js | 16 +- .../dists/chisquare/mgf/test/test.native.js | 16 +- 26 files changed, 297 insertions(+), 325 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/chisquare/cdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/cdf/benchmark/benchmark.js index 0ff24d3497af..f23eb2303b82 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/cdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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/chisquare/cdf/test/test.cdf.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/cdf/test/test.cdf.js index f0d4bd683a89..6064fb343c88 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/cdf/test/test.cdf.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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/chisquare/cdf/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/cdf/test/test.factory.js index c23443feeabe..71c24dede44c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/cdf/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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/chisquare/ctor/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/ctor/benchmark/benchmark.js index e45ca5676c96..00ec79545e5f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/ctor/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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 ChiSquare = 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 ChiSquare( k[ i % len ] ); + dist = new ChiSquare( k[ i % k.length ] ); if ( !( dist instanceof ChiSquare ) ) { 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 ChiSquare( 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 ChiSquare( 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 ChiSquare( 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 ChiSquare( 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 ChiSquare( 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 ChiSquare( 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 ChiSquare( 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 ChiSquare( 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 ChiSquare( 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+':mgf', 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, 0.5, opts ); + k = 5.54; dist = new ChiSquare( k ); - len = 100; - x = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - x[ i ] = uniform( 0.0, 0.5 ); - } 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' ); } @@ -400,23 +398,23 @@ bench( pkg+':mgf', 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 ChiSquare( 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 ChiSquare( 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/chisquare/entropy/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/benchmark/benchmark.js index b15ad2a85e60..bf466f3843f9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); -var Float64Array = require( '@stdlib/array/float64' ); +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/chisquare/entropy/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/benchmark/benchmark.native.js index df05c2e3adbe..12f671daadd1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/benchmark/benchmark.native.js @@ -22,9 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); var EPS = require( '@stdlib/constants/float64/eps' ); -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; @@ -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/chisquare/entropy/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/test/test.js index eb3fde92b0e3..45c97fabc537 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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/chisquare/entropy/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/test/test.native.js index 9afe3dc9f407..4a2b13a2959c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/entropy/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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/chisquare/kurtosis/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/benchmark/benchmark.js index cafaf285d900..0a366d60ab11 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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/chisquare/kurtosis/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/benchmark/benchmark.native.js index 98ec388f75ff..29f5beba9300 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/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 EPS = require( '@stdlib/constants/float64/eps' ); 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 = 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/chisquare/kurtosis/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.js index 54f5e7f9ddc2..23fe177039e5 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.js @@ -41,7 +41,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(); }); @@ -49,13 +49,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/chisquare/kurtosis/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.native.js index da1d8e766eb0..ebd741ff052b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/kurtosis/test/test.native.js @@ -50,7 +50,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 = kurtosis( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -58,13 +58,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/chisquare/logpdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/benchmark/benchmark.js index 8b4df406f3d0..d44b39fef02f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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/chisquare/logpdf/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/test/test.factory.js index 4787396d9908..f046f28a10a9 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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/chisquare/logpdf/test/test.logpdf.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/test/test.logpdf.js index c1be9d8ef282..0bf624f080ce 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/test/test.logpdf.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/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(); }); @@ -82,22 +82,22 @@ tape( 'if `k` equals `0`, the function evaluates a degenerate distribution cente var y; y = logpdf( 0.0, 0.0 ); - t.equal( y, PINF, 'returns +Infinity for x equal to 0' ); + t.equal( y, PINF, 'returns expected value' ); 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/chisquare/mean/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/benchmark/benchmark.js index 0aa2454b5330..3cbff601cd53 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/benchmark/benchmark.js @@ -21,8 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var uniform = require( '@stdlib/random/base/uniform' ); -var Float64Array = require( '@stdlib/array/float64' ); +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/chisquare/mean/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/benchmark/benchmark.native.js index 7857fb1ff27a..a087ff238671 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/benchmark/benchmark.native.js @@ -22,9 +22,8 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var Float64Array = require( '@stdlib/array/float64' ); var EPS = require( '@stdlib/constants/float64/eps' ); -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; @@ -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 = 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/chisquare/mean/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/test/test.js index 4df7eac38160..82135e1990c8 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/test/test.js @@ -41,7 +41,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(); }); @@ -49,10 +49,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/chisquare/mean/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/test/test.native.js index eb418c7feb40..1484696d4d8f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mean/test/test.native.js @@ -50,7 +50,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 = mean( NaN ); - t.equal( isnan( v ), true, 'returns NaN' ); + t.equal( isnan( v ), true, 'returns expected value' ); t.end(); }); @@ -58,10 +58,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/chisquare/median/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/median/benchmark/benchmark.js index 517a7f8092aa..53f3137fdf7f 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/median/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/median/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 median = 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( 1.0 + EPS, 20.0 ); - } + opts = { + 'dtype': 'float64' + }; + k = uniform( 100, 1.0 + EPS, 20.0, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = median( k[ i % len ]); + y = median( k[ i % k.length ]); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chisquare/median/test/test.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/median/test/test.js index a544fdebfe1d..990224a7f22a 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/median/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/median/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 k = median( NaN ); - t.equal( isnan( k ), true, 'returns NaN' ); + t.equal( isnan( k ), true, 'returns expected value' ); t.end(); }); @@ -51,10 +51,10 @@ tape( 'if provided a degrees of freedom `k` that is not a nonnegative number, th var k; k = median( -1.0 ); - t.equal( isnan( k ), true, 'returns NaN' ); + t.equal( isnan( k ), true, 'returns expected value' ); k = median( NINF ); - t.equal( isnan( k ), true, 'returns NaN' ); + t.equal( isnan( k ), true, 'returns expected value' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/benchmark/benchmark.js index 1420976c3f7c..74ebf36402c1 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/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 mgf = require( './../lib' ); @@ -32,23 +31,21 @@ var mgf = require( './../lib' ); // MAIN // bench( pkg, function benchmark( b ) { - var len; + var opts; var k; var t; var y; var i; - len = 100; - t = new Float64Array( len ); - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - t[ i ] = uniform( 0.0, 0.5 ); - k[ i ] = discreteUniform( 1, 100 ); - } + opts = { + 'dtype': 'float64' + }; + t = uniform( 100, 0.0, 0.5, opts ); + k = discreteUniform( 100, 1, 100, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mgf( t[ i % len ], k[ i % len ] ); + y = mgf( t[ i % t.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 mymgf; - var len; + var opts; var k; var t; var y; var i; + opts = { + 'dtype': 'float64' + }; + t = uniform( 100, 0.0, 0.5, opts ); + k = 10.0; mymgf = mgf.factory( k ); - len = 100; - t = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - t[ i ] = uniform( 0.0, 0.5 ); - } b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mymgf( t[ i % len ] ); + y = mymgf( t[ i % t.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/benchmark/benchmark.native.js index d0488a7efe54..cbc36194c9a2 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/benchmark/benchmark.native.js @@ -22,9 +22,8 @@ var resolve = require( 'path' ).resolve; 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 tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -41,23 +40,21 @@ var opts = { // MAIN // bench( pkg+'::native', opts, function benchmark( b ) { - var len; + var opts; var t; var k; var y; var i; - len = 100; - t = new Float64Array( len ); - k = new Float64Array( len ); - for ( i = 0; i < len; i++ ) { - t[ i ] = uniform( 0.0, 0.5 ); - k[ i ] = discreteUniform( 1, 100 ); - } + opts = { + 'dtype': 'float64' + }; + t = uniform( 100, 0.0, 0.5, opts ); + k = discreteUniform( 100, 1, 100, opts ); b.tic(); for ( i = 0; i < b.iterations; i++ ) { - y = mgf( t[ i % len ], k[ i % len ] ); + y = mgf( t[ i % t.length ], k[ i % k.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.factory.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.factory.js index 70a7b47bab4d..12d3fe2294b7 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.factory.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.factory.js @@ -52,11 +52,11 @@ tape( 'if provided `NaN` for any parameter, the created function returns `NaN`', mgf = factory( 1.0 ); y = mgf( NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); mgf = factory( NaN ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -68,10 +68,10 @@ tape( 'if provided a negative `k`, the created function always returns `NaN`', f mgf = factory( -1.0 ); y = mgf( 0.4 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -83,10 +83,10 @@ tape( 'if provided a `t >= 0.5`, the created function always returns `NaN`', fun mgf = factory( 1.0 ); y = mgf( 0.5 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 1.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/chisquare/mgf/test/test.mgf.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.mgf.js index a46f4ed12830..8254846c4699 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.mgf.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.mgf.js @@ -43,9 +43,9 @@ 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 = mgf( NaN, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -53,13 +53,13 @@ tape( 'if provided a negative `k`, the function always returns `NaN`', function var y; y = mgf( 0.4, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.4, NINF ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -68,13 +68,13 @@ tape( 'if provided `t >= 0.5`, the function always returns `NaN`', function test var y; y = mgf( 0.5, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 1.0, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 10.0, 1.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/chisquare/mgf/test/test.native.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.native.js index e03ca489bc4e..ca491b1b8173 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.native.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/test/test.native.js @@ -52,9 +52,9 @@ tape( 'main export is a function', opts, function test( t ) { tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, function test( t ) { var y = mgf( NaN, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, NaN ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -62,13 +62,13 @@ tape( 'if provided a negative `k`, the function always returns `NaN`', opts, fun var y; y = mgf( 0.4, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.0, -1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 0.4, NINF ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); @@ -77,13 +77,13 @@ tape( 'if provided `t >= 0.5`, the function always returns `NaN`', opts, functio var y; y = mgf( 0.5, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 1.0, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); y = mgf( 10.0, 1.0 ); - t.equal( isnan( y ), true, 'returns NaN' ); + t.equal( isnan( y ), true, 'returns expected value' ); t.end(); }); From 5a8bd8e15b842c62ca5301fdd6d12080a949335a Mon Sep 17 00:00:00 2001 From: Harsh <149176984+hrshya@users.noreply.github.com> Date: Sun, 18 May 2025 13:33:00 +0530 Subject: [PATCH 2/2] update benchmark.js Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com> --- .../stats/base/dists/chisquare/logpdf/benchmark/benchmark.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/benchmark/benchmark.js index d44b39fef02f..8fb1296f243b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/chisquare/logpdf/benchmark/benchmark.js @@ -38,7 +38,7 @@ bench( pkg, function benchmark( b ) { var i; opts = { - 'dtype': 'float64' + 'dtype': 'float64' }; x = uniform( 100, 0.0, 100.0, opts ); k = discreteUniform( 100, 1, 100, opts ); @@ -67,7 +67,7 @@ bench( pkg+':factory', function benchmark( b ) { var i; opts = { - 'dtype': 'float64' + 'dtype': 'float64' }; x = uniform( 100, 0.0, 100.0, opts );