Skip to content

Commit

Permalink
chore: refactor random number generation in stats/base/dists/rayleigh
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ekambains and Planeshifter authored Feb 8, 2025
1 parent 556ec54 commit d8c1025
Showing 1 changed file with 10 additions and 5 deletions.
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 @@ bench( pkg, function benchmark( b ) {
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, function benchmark( b ) {
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 );
}

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

3 comments on commit d8c1025

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/rayleigh/cdf $\color{green}288/288$
$\color{green}+100.00\%$
$\color{green}27/27$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}288/288$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

@kgryte
Copy link
Member

@kgryte kgryte commented on d8c1025 Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Planeshifter What's the command for creating a Git note again, given that the Closes needs to be updated to Ref?

@Planeshifter
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't have one yet (didn't finish it due to no ability to trigger workflows from commit comments).

Please sign in to comment.