Skip to content

Commit d8c1025

Browse files
chore: refactor random number generation in stats/base/dists/rayleigh
PR-URL: #5104 Closes: #4985 Co-authored-by: Philipp Burckhardt <pburckhardt@outlook.com> Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com> Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com> Signed-off-by: ekambains <bainsinbusiness@gmail.com>
1 parent 556ec54 commit d8c1025

File tree

1 file changed

+10
-5
lines changed
  • lib/node_modules/@stdlib/stats/base/dists/rayleigh/cdf/benchmark

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
var bench = require( '@stdlib/bench' );
2424
var Float64Array = require( '@stdlib/array/float64' );
25-
var randu = require( '@stdlib/random/base/randu' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
2626
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2727
var EPS = require( '@stdlib/constants/float64/eps' );
2828
var pkg = require( './../package.json' ).name;
@@ -42,8 +42,8 @@ bench( pkg, function benchmark( b ) {
4242
x = new Float64Array( len );
4343
sigma = new Float64Array( len );
4444
for ( i = 0; i < len; i++ ) {
45-
x[ i ] = ( randu() * 100.0 ) - 100.0;
46-
sigma[ i ] = ( randu() * 20.0 ) + EPS;
45+
x[ i ] = uniform( -100.0, 100.0 );
46+
sigma[ i ] = uniform( EPS, 20.0 );
4747
}
4848

4949
b.tic();
@@ -64,17 +64,22 @@ bench( pkg, function benchmark( b ) {
6464
bench( pkg+':factory', function benchmark( b ) {
6565
var sigma;
6666
var mycdf;
67+
var len;
6768
var x;
6869
var y;
6970
var i;
7071

7172
sigma = 4.0;
7273
mycdf = cdf.factory( sigma );
74+
len = 100;
75+
x = new Float64Array( len );
76+
for ( i = 0; i < len; i++ ) {
77+
x[ i ] = uniform( -25.0, 25.0 );
78+
}
7379

7480
b.tic();
7581
for ( i = 0; i < b.iterations; i++ ) {
76-
x = ( randu()*50.0 ) - 25.0;
77-
y = mycdf( x );
82+
y = mycdf( x[ i % len ] );
7883
if ( isnan( y ) ) {
7984
b.fail( 'should not return NaN' );
8085
}

0 commit comments

Comments
 (0)