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

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

Open
wants to merge 1 commit into
base: develop
Choose a base branch
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
First-time Contributor A pull request from a contributor who has never previously committed to the project repository. 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