Skip to content

Resolves #4982 by improving benchmark accuracy and performance. #5124

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

Closed
wants to merge 1 commit into from

Conversation

Mohammad-Tamerr
Copy link

Refactor Benchmarking for Pareto Type I Distribution

Description

This PR refactors the benchmarking code for the stats/base/dists/pareto-type1 module to improve accuracy and performance measurements.

Changes:

  • Replaced randu() with uniform() for more precise random number generation.
  • Moved random number generation outside the benchmarking loop to reduce overhead.
  • Ensured uniform() is correctly imported from @stdlib/random/base/uniform.

Issue

Fix #4988.

Testing

  • Verified benchmarks run correctly.
  • Ensured results are consistent and performance is improved.

Checklist

  • Code changes follow the project’s style guide.
  • Changes were tested and validated.
  • Related issue is linked.

@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. Needs Review A pull request which needs code review. labels Feb 8, 2025
@stdlib-bot
Copy link
Contributor

Hello! Thank you for your contribution to stdlib.

We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:

  1. Please read our contributing guidelines.

  2. Update your pull request description to include this checked box:

    - [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)

This acknowledgment confirms that you've read the guidelines, which include:

  • The developer's certificate of origin
  • Your agreement to license your contributions under the project's terms

We can't review or accept contributions without this acknowledgment.

Thank you for your understanding and cooperation. We look forward to reviewing your contribution!

Copy link
Contributor

@stdlib-bot stdlib-bot left a comment

Choose a reason for hiding this comment

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

👋 Hi there! 👋

And thank you for opening your first pull request! We will review it shortly. 🏃 💨

@stdlib-bot
Copy link
Contributor

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/pareto-type1/cdf $\color{green}239/239$
$\color{green}+100.00\%$
$\color{green}23/23$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}239/239$
$\color{green}+100.00\%$

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

@Mohammad-Tamerr
Copy link
Author

@anandkaranubc
Can you check this PR if you are available?

Comment on lines +34 to +35
var alpha = uniform( EPS, 100.0 );
var beta = 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
var alpha = uniform( EPS, 100.0 );
var beta = uniform( EPS, 100.0 );
var alpha;
var beta;

Variable declarations happen at the top and separately from their initializations.

}
}
for ( i = 0; i < b.iterations; i++ ) {
x = 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.

The use of uniform should be moved out of the benchmarking loop so it doesn't interfere with the benchmark results.

Comment on lines +57 to +58
var beta = 55.54321;
var mycdf = cdf.factory( alpha, beta );
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.

@anandkaranubc
Copy link
Contributor

@anandkaranubc Can you check this PR if you are available?

Hii @Mohammad-Tamerr,

I just had a look. I suggest reviewing the reference PR first to get a clearer understanding of how to approach this issue. There are some major changes that need to be made.

@kgryte
Copy link
Member

kgryte commented Feb 9, 2025

Additionally, please make sure you have followed the development guide and setup EditorConfig. Your indentation is off for various files.

@kgryte kgryte added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Feb 9, 2025
@kgryte kgryte added the autoclose: Project Conventions Pull request which should be auto-closed due to not following project conventions. label Mar 31, 2025
@stdlib-bot
Copy link
Contributor

Thank you for working on this pull request. However, we cannot accept your contribution as this pull request does not follow project conventions.

We place a high value on consistency throughout the stdlib codebase, and this pull request was found to significantly deviate from stdlib conventions. We encourage you to closely examine other packages in stdlib and attempt to emulate the practices and conventions found therein.

  • If you are attempting to contribute a new package, sometimes the best approach is to simply copy the contents of an existing package and then modify the minimum amount necessary to implement the feature (e.g., changing descriptions, parameter names, and implementation).
  • If you are contributing tests, find a package implementing a similar feature and emulate the tests of that package.
  • If you are updating documentation, examine several similar packages and emulate the content, style, and prose of those packages.

In short, the more effort you put in to ensure that your contribution looks and feels like stdlib—including variables names, bracket spacing, line breaks, etc—the more likely that your contribution will be reviewed and ultimately accepted. We encourage you to closely study the codebase before continuing to work on this pull request.

Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions.

@stdlib-bot stdlib-bot closed this Mar 31, 2025
@stdlib-bot stdlib-bot added the Good First PR A pull request resolving a Good First Issue. label Mar 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autoclose: Project Conventions Pull request which should be auto-closed due to not following project conventions. First-time Contributor A pull request from a contributor who has never previously committed to the project repository. 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/t
4 participants