Skip to content

Commit 5b02960

Browse files
authored
bench: update random value generation
PR-URL: #9737 Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com> Signed-off-by: Harsh <149176984+hrshya@users.noreply.github.com>
1 parent 5e9a7cd commit 5b02960

File tree

23 files changed

+219
-215
lines changed

23 files changed

+219
-215
lines changed

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/cdf/benchmark/benchmark.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,23 @@ var cdf = require( './../lib' );
3131
// MAIN //
3232

3333
bench( pkg, function benchmark( b ) {
34-
var len;
34+
var opts;
3535
var a;
3636
var s;
3737
var x;
3838
var y;
3939
var i;
4040

41-
len = 100;
42-
x = uniform( len, 0.0, 1.0 );
43-
a = uniform( len, EPS, 5.0 + EPS );
44-
s = uniform( len, EPS, 5.0 + EPS );
41+
opts = {
42+
'dtype': 'float64'
43+
};
44+
x = uniform( 100, 0.0, 1.0, opts );
45+
a = uniform( 100, EPS, 5.0 + EPS, opts );
46+
s = uniform( 100, EPS, 5.0 + EPS, opts );
4547

4648
b.tic();
4749
for ( i = 0; i < b.iterations; i++ ) {
48-
y = cdf( x[ i % len ], a[ i % len ], s[ i % len ] );
50+
y = cdf( x[ i % x.length ], a[ i % a.length ], s[ i % s.length ] );
4951
if ( isnan( y ) ) {
5052
b.fail( 'should not return NaN' );
5153
}
@@ -60,6 +62,7 @@ bench( pkg, function benchmark( b ) {
6062

6163
bench( pkg+':factory', function benchmark( b ) {
6264
var mycdf;
65+
var opts;
6366
var a;
6467
var s;
6568
var x;
@@ -69,7 +72,11 @@ bench( pkg+':factory', function benchmark( b ) {
6972
a = 100.56789;
7073
s = 55.54321;
7174
mycdf = cdf.factory( a, s );
72-
x = uniform( 100, -2.0, 2.0 );
75+
76+
opts = {
77+
'dtype': 'float64'
78+
};
79+
x = uniform( 100, -2.0, 2.0, opts );
7380

7481
b.tic();
7582
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/cdf/benchmark/benchmark.native.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,23 @@ var opts = {
4040
// MAIN //
4141

4242
bench( pkg+'::native', opts, function benchmark( b ) {
43-
var len;
43+
var opts;
4444
var a;
4545
var s;
4646
var x;
4747
var y;
4848
var i;
4949

50-
len = 100;
51-
x = uniform( len, 0.0, 1.0 );
52-
a = uniform( len, EPS, 5.0 );
53-
s = uniform( len, EPS, 5.0 );
50+
opts = {
51+
'dtype': 'float64'
52+
};
53+
x = uniform( 100, 0.0, 1.0, opts );
54+
a = uniform( 100, EPS, 5.0, opts );
55+
s = uniform( 100, EPS, 5.0, opts );
5456

5557
b.tic();
5658
for ( i = 0; i < b.iterations; i++ ) {
57-
y = cdf( x[ i % len ], a[ i % len ], s[ i % len ] );
59+
y = cdf( x[ i % x.length ], a[ i % a.length ], s[ i % s.length ] );
5860
if ( isnan( y ) ) {
5961
b.fail( 'should not return NaN' );
6062
}

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/kurtosis/benchmark/benchmark.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,19 @@ var kurtosis = require( './../lib' );
3333
bench( pkg, function benchmark( b ) {
3434
var shape1;
3535
var shape2;
36-
var len;
36+
var opts;
3737
var y;
3838
var i;
3939

40-
len = 100;
41-
shape1 = uniform( len, EPS, 10.0 );
42-
shape2 = uniform( len, EPS, 10.0 );
40+
opts = {
41+
'dtype': 'float64'
42+
};
43+
shape1 = uniform( 100, EPS, 10.0, opts );
44+
shape2 = uniform( 100, EPS, 10.0, opts );
4345

4446
b.tic();
4547
for ( i = 0; i < b.iterations; i++ ) {
46-
y = kurtosis( shape1[ i % len ], shape2[ i % len ] );
48+
y = kurtosis( shape1[ i % shape1.length ], shape2[ i % shape2.length ] );
4749
if ( isnan( y ) ) {
4850
b.fail( 'should not return NaN' );
4951
}

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/kurtosis/benchmark/benchmark.native.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,19 @@ var opts = {
4242
bench( pkg+'::native', opts, function benchmark( b ) {
4343
var shape1;
4444
var shape2;
45-
var len;
45+
var opts;
4646
var y;
4747
var i;
4848

49-
len = 100;
50-
shape1 = uniform( len, EPS, 10.0 );
51-
shape2 = uniform( len, EPS, 10.0 );
49+
opts = {
50+
'dtype': 'float64'
51+
};
52+
shape1 = uniform( 100, EPS, 10.0, opts );
53+
shape2 = uniform( 100, EPS, 10.0, opts );
5254

5355
b.tic();
5456
for ( i = 0; i < b.iterations; i++ ) {
55-
y = kurtosis( shape1[ i % len ], shape2[ i % len ] );
57+
y = kurtosis( shape1[ i % shape1.length ], shape2[ i % shape2.length ] );
5658
if ( isnan( y ) ) {
5759
b.fail( 'should not return NaN' );
5860
}

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/logcdf/benchmark/benchmark.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var Float64Array = require( '@stdlib/array/float64' );
2524
var uniform = require( '@stdlib/random/array/uniform' );
26-
var randu = require( '@stdlib/random/base/randu' );
2725
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2826
var EPS = require( '@stdlib/constants/float64/eps' );
2927
var pkg = require( './../package.json' ).name;
@@ -33,26 +31,23 @@ var logcdf = require( './../lib' );
3331
// MAIN //
3432

3533
bench( pkg, function benchmark( b ) {
36-
var len;
34+
var opts;
3735
var a;
3836
var s;
3937
var x;
4038
var y;
4139
var i;
4240

43-
len = 100;
44-
x = new Float64Array( len );
45-
a = new Float64Array( len );
46-
s = new Float64Array( len );
47-
for ( i = 0; i < len; i++ ) {
48-
x[ i ] = randu();
49-
a[ i ] = ( randu()*5.0 ) + EPS;
50-
s[ i ] = ( randu()*5.0 ) + EPS;
51-
}
41+
opts = {
42+
'dtype': 'float64'
43+
};
44+
x = uniform( 100, 0.0, 1.0, opts );
45+
a = uniform( 100, EPS, 5.0, opts );
46+
s = uniform( 100, EPS, 5.0, opts );
5247

5348
b.tic();
5449
for ( i = 0; i < b.iterations; i++ ) {
55-
y = logcdf( x[ i % len ], a[ i % len ], s[ i % len ] );
50+
y = logcdf( x[ i % x.length ], a[ i % a.length ], s[ i % s.length ] );
5651
if ( isnan( y ) ) {
5752
b.fail( 'should not return NaN' );
5853
}
@@ -67,6 +62,7 @@ bench( pkg, function benchmark( b ) {
6762

6863
bench( pkg+':factory', function benchmark( b ) {
6964
var mylogcdf;
65+
var opts;
7066
var a;
7167
var s;
7268
var x;
@@ -76,7 +72,11 @@ bench( pkg+':factory', function benchmark( b ) {
7672
a = 100.56789;
7773
s = 55.54321;
7874
mylogcdf = logcdf.factory( a, s );
79-
x = uniform( 100, -2.0, 2.0 );
75+
76+
opts = {
77+
'dtype': 'float64'
78+
};
79+
x = uniform( 100, -2.0, 2.0, opts );
8080

8181
b.tic();
8282
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/logcdf/benchmark/benchmark.native.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var Float64Array = require( '@stdlib/array/float64' );
26-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var EPS = require( '@stdlib/constants/float64/eps' );
2928
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -41,26 +40,23 @@ var opts = {
4140
// MAIN //
4241

4342
bench( pkg+'::native', opts, function benchmark( b ) {
44-
var len;
43+
var opts;
4544
var a;
4645
var s;
4746
var x;
4847
var y;
4948
var i;
5049

51-
len = 100;
52-
x = new Float64Array( len );
53-
a = new Float64Array( len );
54-
s = new Float64Array( len );
55-
for ( i = 0; i < len; i++ ) {
56-
x[ i ] = randu();
57-
a[ i ] = ( randu()*5.0 ) + EPS;
58-
s[ i ] = ( randu()*5.0 ) + EPS;
59-
}
50+
opts = {
51+
'dtype': 'float64'
52+
};
53+
x = uniform( 100, 0.0, 1.0, opts );
54+
a = uniform( 100, EPS, 5.0, opts );
55+
s = uniform( 100, EPS, 5.0, opts );
6056

6157
b.tic();
6258
for ( i = 0; i < b.iterations; i++ ) {
63-
y = logcdf( x[ i % len ], a[ i % len ], s[ i % len ] );
59+
y = logcdf( x[ i % x.length ], a[ i % a.length ], s[ i % s.length ] );
6460
if ( isnan( y ) ) {
6561
b.fail( 'should not return NaN' );
6662
}

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/logpdf/benchmark/benchmark.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var Float64Array = require( '@stdlib/array/float64' );
2524
var uniform = require( '@stdlib/random/array/uniform' );
26-
var randu = require( '@stdlib/random/base/randu' );
2725
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2826
var EPS = require( '@stdlib/constants/float64/eps' );
2927
var pkg = require( './../package.json' ).name;
@@ -33,26 +31,23 @@ var logpdf = require( './../lib' );
3331
// MAIN //
3432

3533
bench( pkg, function benchmark( b ) {
36-
var len;
34+
var opts;
3735
var a;
3836
var s;
3937
var x;
4038
var y;
4139
var i;
4240

43-
len = 100;
44-
x = new Float64Array( len );
45-
a = new Float64Array( len );
46-
s = new Float64Array( len );
47-
for ( i = 0; i < len; i++ ) {
48-
x[ i ] = randu();
49-
a[ i ] = ( randu()*5.0 ) + EPS;
50-
s[ i ] = ( randu()*5.0 ) + EPS;
51-
}
41+
opts = {
42+
'dtype': 'float64'
43+
};
44+
x = uniform( 100, 0.0, 1.0, opts );
45+
a = uniform( 100, EPS, 5.0, opts );
46+
s = uniform( 100, EPS, 5.0, opts );
5247

5348
b.tic();
5449
for ( i = 0; i < b.iterations; i++ ) {
55-
y = logpdf( x[ i % len ], a[ i % len ], s[ i % len ] );
50+
y = logpdf( x[ i % x.length ], a[ i % a.length ], s[ i % s.length ] );
5651
if ( isnan( y ) ) {
5752
b.fail( 'should not return NaN' );
5853
}
@@ -67,6 +62,7 @@ bench( pkg, function benchmark( b ) {
6762

6863
bench( pkg+':factory', function benchmark( b ) {
6964
var mylogpdf;
65+
var opts;
7066
var a;
7167
var s;
7268
var x;
@@ -76,7 +72,11 @@ bench( pkg+':factory', function benchmark( b ) {
7672
a = 100.56789;
7773
s = 55.54321;
7874
mylogpdf = logpdf.factory( a, s );
79-
x = uniform( 100, -2.0, 2.0 );
75+
76+
opts = {
77+
'dtype': 'float64'
78+
};
79+
x = uniform( 100, -2.0, 2.0, opts );
8080

8181
b.tic();
8282
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/logpdf/benchmark/benchmark.native.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222

2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
25-
var Float64Array = require( '@stdlib/array/float64' );
26-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/array/uniform' );
2726
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2827
var EPS = require( '@stdlib/constants/float64/eps' );
2928
var tryRequire = require( '@stdlib/utils/try-require' );
@@ -41,26 +40,23 @@ var opts = {
4140
// MAIN //
4241

4342
bench( pkg+'::native', opts, function benchmark( b ) {
44-
var len;
43+
var opts;
4544
var a;
4645
var s;
4746
var x;
4847
var y;
4948
var i;
5049

51-
len = 100;
52-
x = new Float64Array( len );
53-
a = new Float64Array( len );
54-
s = new Float64Array( len );
55-
for ( i = 0; i < len; i++ ) {
56-
x[ i ] = randu();
57-
a[ i ] = ( randu()*5.0 ) + EPS;
58-
s[ i ] = ( randu()*5.0 ) + EPS;
59-
}
50+
opts = {
51+
'dtype': 'float64'
52+
};
53+
x = uniform( 100, 0.0, 1.0, opts );
54+
a = uniform( 100, EPS, 5.0, opts );
55+
s = uniform( 100, EPS, 5.0, opts );
6056

6157
b.tic();
6258
for ( i = 0; i < b.iterations; i++ ) {
63-
y = logpdf( x[ i % len ], a[ i % len ], s[ i % len ] );
59+
y = logpdf( x[ i % x.length ], a[ i % a.length ], s[ i % s.length ] );
6460
if ( isnan( y ) ) {
6561
b.fail( 'should not return NaN' );
6662
}

lib/node_modules/@stdlib/stats/base/dists/kumaraswamy/mean/benchmark/benchmark.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
// MODULES //
2222

2323
var bench = require( '@stdlib/bench' );
24-
var Float64Array = require( '@stdlib/array/float64' );
25-
var uniform= require( '@stdlib/random/base/uniform' );
24+
var uniform= require( '@stdlib/random/array/uniform' );
2625
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2726
var EPS = require( '@stdlib/constants/float64/eps' );
2827
var pkg = require( './../package.json' ).name;
@@ -34,21 +33,19 @@ var mean = require( './../lib' );
3433
bench( pkg, function benchmark( b ) {
3534
var shape1;
3635
var shape2;
37-
var len;
36+
var opts;
3837
var y;
3938
var i;
4039

41-
len = 100;
42-
shape1 = new Float64Array( len );
43-
shape2 = new Float64Array( len );
44-
for ( i = 0; i < len; i++ ) {
45-
shape1[ i ] = uniform( EPS, 10.0 );
46-
shape2[ i ] = uniform( EPS, 10.0 );
47-
}
40+
opts = {
41+
'dtype': 'float64'
42+
};
43+
shape1 = uniform( 100, EPS, 10.0, opts );
44+
shape2 = uniform( 100, EPS, 10.0, opts );
4845

4946
b.tic();
5047
for ( i = 0; i < b.iterations; i++ ) {
51-
y = mean( shape1[ i % len ], shape2[ i % len ] );
48+
y = mean( shape1[ i % shape1.length ], shape2[ i % shape2.length ] );
5249
if ( isnan( y ) ) {
5350
b.fail( 'should not return NaN' );
5451
}

0 commit comments

Comments
 (0)