Skip to content
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

bench: refactor random number generation in stats/base/dists/levy #5883

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

hemantmm
Copy link
Contributor

@hemantmm hemantmm commented Mar 8, 2025

…ts/levy

Resolves #4977

Description

What is the purpose of this pull request?

This pull request:

  • Refactor random number generation in JS benchmarks for stats/base/dists/levy

Related Issues

Does this pull request have any related issues?

This pull request:

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

…ts/levy

Signed-off-by: hemantmm <hemant29mehta@gmail.com>
@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. Good First PR A pull request resolving a Good First Issue. labels Mar 8, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Mar 8, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/levy/cdf $\color{green}234/234$
$\color{green}+100.00\%$
$\color{green}21/21$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}234/234$
$\color{green}+100.00\%$
stats/base/dists/levy/ctor $\color{green}420/420$
$\color{green}+100.00\%$
$\color{green}32/32$
$\color{green}+100.00\%$
$\color{green}16/16$
$\color{green}+100.00\%$
$\color{green}420/420$
$\color{green}+100.00\%$
stats/base/dists/levy/entropy $\color{green}120/120$
$\color{green}+100.00\%$
$\color{green}7/7$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}120/120$
$\color{green}+100.00\%$
stats/base/dists/levy/logcdf $\color{green}238/238$
$\color{green}+100.00\%$
$\color{green}21/21$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}238/238$
$\color{green}+100.00\%$
stats/base/dists/levy/logpdf $\color{green}222/222$
$\color{green}+100.00\%$
$\color{green}21/21$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}222/222$
$\color{green}+100.00\%$
stats/base/dists/levy/mean $\color{green}176/176$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}176/176$
$\color{green}+100.00\%$
stats/base/dists/levy/median $\color{green}182/182$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}182/182$
$\color{green}+100.00\%$
stats/base/dists/levy/mode $\color{green}175/175$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}175/175$
$\color{green}+100.00\%$
stats/base/dists/levy/pdf $\color{green}216/216$
$\color{green}+100.00\%$
$\color{green}21/21$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}216/216$
$\color{green}+100.00\%$
stats/base/dists/levy/stdev $\color{green}176/176$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}176/176$
$\color{green}+100.00\%$
stats/base/dists/levy/variance $\color{green}176/176$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}176/176$
$\color{green}+100.00\%$

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

hemantmm added 6 commits March 8, 2025 23:42
Signed-off-by: hemantmm <hemant29mehta@gmail.com>
Signed-off-by: hemantmm <hemant29mehta@gmail.com>
Signed-off-by: hemantmm <hemant29mehta@gmail.com>
Signed-off-by: hemantmm <hemant29mehta@gmail.com>
Signed-off-by: hemantmm <hemant29mehta@gmail.com>
Signed-off-by: hemantmm <hemant29mehta@gmail.com>
@hemantmm
Copy link
Contributor Author

hemantmm commented Mar 9, 2025

@anandkaranubc have a look at the PR.

@hemantmm
Copy link
Contributor Author

hemantmm commented Mar 9, 2025

@kgryte have a look at the PR.

x = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
mu[ i ] = uniform( -50.0, 50.0 );
x[ i ] = uniform( mu[ i ], 50.0 );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
x[ i ] = uniform( mu[ i ], 50.0 );
x[ i ] = uniform( mu[ i ], 100.0 );

Copy link
Contributor

Choose a reason for hiding this comment

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

The range should remain the same as original. This also applies throughout the PR.

mycdf = cdf.factory( mu, scale );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( -4.0, 4.0 );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
x[ i ] = uniform( -4.0, 4.0 );
x[ i ] = uniform( 0.0, 4.0 );

Same comment as above.

mu = new Float64Array( len );
c = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
mu[ i ] = ( uniform( -50.0, 50.0 ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
mu[ i ] = ( uniform( -50.0, 50.0 ) );
mu[ i ] = uniform( EPS, 10.0 );

No need of outside brackets.

c = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
mu[ i ] = ( uniform( -50.0, 50.0 ) );
c[ i ] = ( uniform( EPS, 20.0 ) );
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for this c[ i ] = ( uniform( EPS, 20.0 ) ); i have to make the changes as EPS,10.0?

dist.c = y;
if ( dist.c !== y ) {
dist.c = y[ i % len ];
if ( dist.c !== y[ i % len] ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if ( dist.c !== y[ i % len] ) {
if ( dist.c !== y[ i % len ] ) {

dist = new Levy( mu, c );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( EPS, 100.0 );
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
x[ i ] = uniform( EPS, 100.0 );
x[ i ] = uniform( 1.0 + EPS, 100.0 );

@anandkaranubc
Copy link
Contributor

@hemantmm, thanks for raising a PR for this issue. I have left a few comments that need to be addressed. These comments apply throughout the PR, including areas where they were not explicitly mentioned.

Additionally, please review this discussion comment: #4993 (comment) and incorporate the suggested changes as well.

Also, the title should be updated to (for consistency):

bench: refactor random number generation in stats/base/dists/levy

(Note: The backticks should be included around stats/base/dists/levy.)

Good luck!

@anandkaranubc anandkaranubc added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Mar 9, 2025
@hemantmm hemantmm changed the title bench: refactor random number generation in JS benchmarks for stats/base/dists/levy bench: refactor random number generation in stats/base/dists/levy Mar 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First PR A pull request resolving a Good First Issue. Needs Changes Pull request which needs changes before being merged. Statistics Issue or pull request related to statistical functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC]: Refactor random number generation in JS benchmarks for stats/base/dists/levy
3 participants