Skip to content

chore: refactor random number generation in stats/base/dists/rayleigh #5104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 8, 2025
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

var bench = require( '@stdlib/bench' );
var Float64Array = require( '@stdlib/array/float64' );
var randu = require( '@stdlib/random/base/randu' );
var uniform = require( '@stdlib/random/base/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var EPS = require( '@stdlib/constants/float64/eps' );
var pkg = require( './../package.json' ).name;
Expand All @@ -42,8 +42,8 @@
x = new Float64Array( len );
sigma = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = ( randu() * 100.0 ) - 100.0;
sigma[ i ] = ( randu() * 20.0 ) + EPS;
x[ i ] = uniform( -100.0, 100.0 );
sigma[ i ] = uniform( EPS, 20.0 );
}

b.tic();
Expand All @@ -64,17 +64,22 @@
bench( pkg+':factory', function benchmark( b ) {
var sigma;
var mycdf;
var len;
var x;
var y;
var i;

sigma = 4.0;
mycdf = cdf.factory( sigma );

len = 100;
x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -25.0, 25.0 );
}

Check failure on line 79 in lib/node_modules/@stdlib/stats/base/dists/rayleigh/cdf/benchmark/benchmark.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Trailing spaces not allowed
b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu()*50.0 ) - 25.0;
y = mycdf( x );
y = mycdf( x[ i % len ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Loading