Skip to content

Conversation

yuvimittal
Copy link
Contributor

Resolves #4980

Description

What is the purpose of this pull request?

This pull request:

  • Refactor random number generation in JS benchmarks

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

---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
@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 2, 2025
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Feb 2, 2025

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/negative-binomial/cdf $\color{green}272/272$
$\color{green}+100.00\%$
$\color{green}29/29$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}272/272$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/ctor $\color{green}420/420$
$\color{green}+100.00\%$
$\color{green}31/31$
$\color{green}+100.00\%$
$\color{green}16/16$
$\color{green}+100.00\%$
$\color{green}420/420$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/kurtosis $\color{green}122/122$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}122/122$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/logpmf $\color{red}523/566$
$\color{green}+92.40\%$
$\color{red}45/51$
$\color{green}+88.24\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{red}523/566$
$\color{green}+92.40\%$
stats/base/dists/negative-binomial/mean $\color{green}126/126$
$\color{green}+100.00\%$
$\color{green}10/10$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}126/126$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/mgf $\color{green}235/235$
$\color{green}+100.00\%$
$\color{green}22/22$
$\color{green}+100.00\%$
$\color{green}3/3$
$\color{green}+100.00\%$
$\color{green}235/235$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/mode $\color{green}123/123$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}123/123$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/pmf $\color{red}532/562$
$\color{green}+94.66\%$
$\color{red}49/57$
$\color{green}+85.96\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{red}532/562$
$\color{green}+94.66\%$
stats/base/dists/negative-binomial/quantile $\color{green}402/402$
$\color{green}+100.00\%$
$\color{green}52/52$
$\color{green}+100.00\%$
$\color{green}5/5$
$\color{green}+100.00\%$
$\color{green}402/402$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/skewness $\color{green}123/123$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}123/123$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/stdev $\color{green}123/123$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}123/123$
$\color{green}+100.00\%$
stats/base/dists/negative-binomial/variance $\color{green}122/122$
$\color{green}+100.00\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{green}1/1$
$\color{green}+100.00\%$
$\color{green}122/122$
$\color{green}+100.00\%$

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

@anandkaranubc
Copy link
Contributor

Thanks, @yuvi-mittal, for working on this. I left a few comments for you to review. These suggestions are applicable throughout the PR.

Also, can you change the title to:

bench: refactor random number generation in stats/base/dists/negative-binomial

@yuvimittal yuvimittal changed the title feat : refactor random number generation in JS benchmarks stats/base/dists/negative-binomial bench: refactor random number generation in stats/base/dists/negative-binomial Feb 2, 2025
@kgryte kgryte requested a review from anandkaranubc February 3, 2025 08:20
@anandkaranubc anandkaranubc added the Needs Changes Pull request which needs changes before being merged. label Feb 3, 2025
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
  - task: run_javascript_examples
    status: na
  - task: run_c_examples
    status: na
  - task: run_cpp_examples
    status: na
  - task: run_javascript_readme_examples
    status: na
  - task: run_c_benchmarks
    status: na
  - task: run_cpp_benchmarks
    status: na
  - task: run_fortran_benchmarks
    status: na
  - task: run_javascript_benchmarks
    status: na
  - task: run_julia_benchmarks
    status: na
  - task: run_python_benchmarks
    status: na
  - task: run_r_benchmarks
    status: na
  - task: run_javascript_tests
    status: na
---
p = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
x[ i ] = uniform( 0, 100.0 );
r[ i ] = discreteUniform( 1.0, 100 );
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
r[ i ] = discreteUniform( 1.0, 100 );
r[ i ] = discreteUniform( 1, 100 );

r = new Float64Array( len );
p = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
r[ i ] = discreteUniform( 1.0, 50 );
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
r[ i ] = discreteUniform( 1.0, 50 );
r[ i ] = discreteUniform( 1, 50 );

This change is consistent throughout the PR.

len = 100;
y = new Float64Array( len );
for ( i = 0; i < len; i++ ) {
y[ i ] = discreteUniform( 1.0, 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
y[ i ] = discreteUniform( 1.0, 100.0 );
y[ i ] = discreteUniform( 1, 50 );

Make sure the range is still the same for consistency.

Comment on lines +168 to +169
dist.p = y[i % len];
if ( dist.p !== 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
dist.p = y[i % len];
if ( dist.p !== y[i % len] ) {
dist.p = y[ i % len ];
if ( dist.p !== y[ i % len ] ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
dist.r = ceil( ( 100.0*randu() ) + EPS );
dist.r = x[i % 100];
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
dist.r = x[i % 100];
dist.r = x[ 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.

This change is consistent throughout the PR.

@anandkaranubc anandkaranubc removed the Needs Review A pull request which needs code review. label Feb 5, 2025
@stdlib-bot stdlib-bot removed the First-time Contributor A pull request from a contributor who has never previously committed to the project repository. label Feb 15, 2025
@Planeshifter Planeshifter added the autoclose: Already Resolved Pull request which should be auto-closed due proposed changes duplicating already included changes. label Jun 22, 2025
@stdlib-bot
Copy link
Contributor

Thank you for working on this pull request. However, we cannot accept your contribution as the issue this pull request seeks to resolve has already been addressed in a different pull request or commit.

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

@stdlib-bot stdlib-bot closed this Jun 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autoclose: Already Resolved Pull request which should be auto-closed due proposed changes duplicating already included changes. 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/negative-binomial

4 participants