diff --git a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/ctor/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/ctor/benchmark/benchmark.js index 785fe8d3130d..136a88317d6d 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/ctor/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/ctor/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +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,15 +32,20 @@ var Kumaraswamy = require( './../lib' ); bench( pkg+'::instantiation', function benchmark( bm ) { var dist; + var opts; var a; var b; var i; + opts = { + 'dtype': 'float64' + }; + a = uniform( 100, EPS, 10.0, opts ); + b = uniform( 100, EPS, 10.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - a = ( randu() * 10.0 ) + EPS; - b = ( randu() * 10.0 ) + EPS; - dist = new Kumaraswamy( a, b ); + dist = new Kumaraswamy( a[ i % a.length ], b[ i % b.length ] ); if ( !( dist instanceof Kumaraswamy ) ) { bm.fail( 'should return a distribution instance' ); } @@ -81,6 +86,7 @@ bench( pkg+'::get:a', function benchmark( bm ) { bench( pkg+'::set:a', function benchmark( bm ) { var dist; + var opts; var a; var b; var y; @@ -90,10 +96,14 @@ bench( pkg+'::set:a', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + y = uniform( 100, EPS, 100.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - y = ( 100.0*randu() ) + EPS; - dist.a = y; + dist.a = y[ i % y.length ]; if ( dist.a !== y ) { bm.fail( 'should return set value' ); } @@ -134,6 +144,7 @@ bench( pkg+'::get:b', function benchmark( bm ) { bench( pkg+'::set:b', function benchmark( bm ) { var dist; + var opts; var a; var b; var y; @@ -143,10 +154,14 @@ bench( pkg+'::set:b', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + y = uniform( 100, EPS, 100.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - y = ( 100.0*randu() ) + EPS; - dist.b = y; + dist.b = y[ i % y.length ]; if ( dist.b !== y ) { bm.fail( 'should return set value' ); } @@ -161,8 +176,10 @@ bench( pkg+'::set:b', function benchmark( bm ) { bench( pkg+':kurtosis', function benchmark( bm ) { var dist; + var opts; var a; var b; + var x; var y; var i; @@ -170,9 +187,14 @@ bench( pkg+':kurtosis', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, EPS, 100.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - dist.a = ( 100.0*randu() ) + EPS; + dist.a = x[ i % x.length ]; y = dist.kurtosis; if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); @@ -188,8 +210,10 @@ bench( pkg+':kurtosis', function benchmark( bm ) { bench( pkg+':mean', function benchmark( bm ) { var dist; + var opts; var a; var b; + var x; var y; var i; @@ -197,9 +221,14 @@ bench( pkg+':mean', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, EPS, 100.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - dist.a = ( 100.0*randu() ) + EPS; + dist.a = x[ i % x.length ]; y = dist.mean; if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); @@ -215,8 +244,10 @@ bench( pkg+':mean', function benchmark( bm ) { bench( pkg+':mode', function benchmark( bm ) { var dist; + var opts; var a; var b; + var x; var y; var i; @@ -224,9 +255,14 @@ bench( pkg+':mode', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, EPS + 1.0, 100.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - dist.a = ( 100.0*randu() ) + 1.0 + EPS; + dist.a = x[ i % x.length ]; y = dist.mode; if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); @@ -242,8 +278,10 @@ bench( pkg+':mode', function benchmark( bm ) { bench( pkg+':skewness', function benchmark( bm ) { var dist; + var opts; var a; var b; + var x; var y; var i; @@ -251,9 +289,14 @@ bench( pkg+':skewness', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, EPS, 100.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - dist.a = ( 100.0*randu() ) + EPS; + dist.a = x[ i % x.length ]; y = dist.skewness; if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); @@ -269,8 +312,10 @@ bench( pkg+':skewness', function benchmark( bm ) { bench( pkg+':stdev', function benchmark( bm ) { var dist; + var opts; var a; var b; + var x; var y; var i; @@ -278,9 +323,14 @@ bench( pkg+':stdev', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, EPS, 100.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - dist.a = ( 100.0*randu() ) + EPS; + dist.a = x[ i % x.length ]; y = dist.stdev; if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); @@ -296,8 +346,10 @@ bench( pkg+':stdev', function benchmark( bm ) { bench( pkg+':variance', function benchmark( bm ) { var dist; + var opts; var a; var b; + var x; var y; var i; @@ -305,9 +357,14 @@ bench( pkg+':variance', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, EPS, 100.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - dist.a = ( 100.0*randu() ) + EPS; + dist.a = x[ i % x.length ]; y = dist.variance; if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); @@ -323,6 +380,7 @@ bench( pkg+':variance', function benchmark( bm ) { bench( pkg+':cdf', function benchmark( bm ) { var dist; + var opts; var a; var b; var x; @@ -333,10 +391,14 @@ bench( pkg+':cdf', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - x = randu(); - y = dist.cdf( x ); + y = dist.cdf( x[ i % x.length ] ); if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); } @@ -351,6 +413,7 @@ bench( pkg+':cdf', function benchmark( bm ) { bench( pkg+':logcdf', function benchmark( bm ) { var dist; + var opts; var a; var b; var x; @@ -361,10 +424,14 @@ bench( pkg+':logcdf', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - x = randu(); - y = dist.logcdf( x ); + y = dist.logcdf( x[ i % x.length ] ); if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); } @@ -379,6 +446,7 @@ bench( pkg+':logcdf', function benchmark( bm ) { bench( pkg+':logpdf', function benchmark( bm ) { var dist; + var opts; var a; var b; var x; @@ -389,10 +457,14 @@ bench( pkg+':logpdf', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - x = randu(); - y = dist.logpdf( x ); + y = dist.logpdf( x[ i % x.length ] ); if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); } @@ -407,6 +479,7 @@ bench( pkg+':logpdf', function benchmark( bm ) { bench( pkg+':pdf', function benchmark( bm ) { var dist; + var opts; var a; var b; var x; @@ -417,10 +490,14 @@ bench( pkg+':pdf', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - x = randu(); - y = dist.pdf( x ); + y = dist.pdf( x[ i % x.length ] ); if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); } @@ -435,6 +512,7 @@ bench( pkg+':pdf', function benchmark( bm ) { bench( pkg+':quantile', function benchmark( bm ) { var dist; + var opts; var a; var b; var x; @@ -445,10 +523,14 @@ bench( pkg+':quantile', function benchmark( bm ) { b = 55.54321; dist = new Kumaraswamy( a, b ); + opts = { + 'dtype': 'float64' + }; + x = uniform( 100, 0.0, 1.0, opts ); + bm.tic(); for ( i = 0; i < bm.iterations; i++ ) { - x = randu(); - y = dist.quantile( x ); + y = dist.quantile( x[ i % x.length ] ); if ( isnan( y ) ) { bm.fail( 'should not return NaN' ); }