Skip to content

Conversation

@manit2004
Copy link
Contributor

Progresses #209 .

Description

What is the purpose of this pull request?

  • This is a WIP pull request. Currently the core functionalities of Wald Distribution variance package has been implemented. Feedback needed on this implementation.

Tests, docs, examples and benchmark is yet to added, pending approval of the core implementation.

Related Issues

Does this pull request have any related issues?

  • None

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.

AI Assistance

When authoring the changes proposed in this PR, did you use any kind of AI assistance?

  • Yes
  • No

If you answered "yes" above, how did you use AI assistance?

  • Code generation (e.g., when writing an implementation or fixing a bug)
  • Test/benchmark generation
  • Documentation (including examples)
  • Research and understanding

Disclosure

If you answered "yes" to using AI assistance, please provide a short disclosure indicating how you used AI assistance. This helps reviewers determine how much scrutiny to apply when reviewing your contribution. Example disclosures: "This PR was written primarily by Claude Code." or "I consulted ChatGPT to understand the codebase, but the proposed changes were fully authored manually by myself.".


@stdlib-js/reviewers

@stdlib-bot stdlib-bot added Statistics Issue or pull request related to statistical functionality. Needs Review A pull request which needs code review. labels Jan 13, 2026
@Planeshifter Planeshifter self-requested a review January 13, 2026 17:53
stdlib_base_is_nan( mu ) ||
stdlib_base_is_nan( lambda ) ||
lambda <= 0.0 ||
mu <= 0.0
Copy link
Member

Choose a reason for hiding this comment

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

This line is missing an indentation level - it should have two tabs to match the other conditions above it.

Suggested change
mu <= 0.0
mu <= 0.0

Copy link
Member

@Planeshifter Planeshifter left a comment

Choose a reason for hiding this comment

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

Thanks!

First thing I noticed is that README.md is missing and should be added.

@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. labels Jan 13, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 18, 2026

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/wald/variance $\color{green}176/176$
$\color{green}+0.00%$
$\color{green}10/10$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{green}176/176$
$\color{green}+0.00%$

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

@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 18, 2026
@manit2004
Copy link
Contributor Author

@Planeshifter variance package has been implemented fully. Please take a look.

Copy link
Member

@Neerajpathak07 Neerajpathak07 left a comment

Choose a reason for hiding this comment

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

@manit2004 Thanks for this!! Left out a few comments

#/
# @license Apache-2.0
#
# Copyright (c) 2025 The Stdlib Authors.
Copy link
Member

Choose a reason for hiding this comment

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

Let's revert this.
Normally while adding a new package we avoid making changes to the upstream packages.

Comment on lines 40 to 44
opts = {
'dtype': 'float64'
};
mu = uniform( 100, EPS, 100.0, opts );
lambda = uniform( 100, EPS, 20.0, opts );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
opts = {
'dtype': 'float64'
};
mu = uniform( 100, EPS, 100.0, opts );
lambda = uniform( 100, EPS, 20.0, opts );
len = 100;
mu = uniform( len, EPS, 100.0 );
lambda = uniform( len, EPS, 20.0 );


b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = variance( mu[ i % 100 ], lambda[ i % 100 ] );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
y = variance( mu[ i % 100 ], lambda[ i % 100 ] );
y = variance( mu[ i%len ], lambda[ i%len ] );

'dtype': 'float64'
};
mu = uniform( 100, EPS, 100.0, arrayOpts );
lambda = uniform( 100, EPS, 20.0, arrayOpts );
Copy link
Member

Choose a reason for hiding this comment

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

same comment

Comment on lines 95 to 97
double elapsed;
double lambda[ 100 ];
double mu[ 100 ];
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
double elapsed;
double lambda[ 100 ];
double mu[ 100 ];
double lambda[ 100 ];
double mu[ 100 ];
double elapsed;

order by length


t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
y = stdlib_base_dists_wald_variance( mu[ i % 100 ], lambda[ i % 100 ] );
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
y = stdlib_base_dists_wald_variance( mu[ i % 100 ], lambda[ i % 100 ] );
y = stdlib_base_dists_wald_variance( mu[ i%100 ], lambda[ i%100 ] );

Comment on lines 12 to 13
μ: number
Location parameter.
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused since mu represents mean but here it is described it as Location parameter. Mind updating this?

Comment on lines 35 to 36
mu = random_uniform( 0.1, 10.0 );
lambda = random_uniform( 0.1, 20.0 );
Copy link
Member

Choose a reason for hiding this comment

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

Lets update the examples with STDLIB_CONSTANT_FLOAT64_EPS as well.

) {
return NaN;
}
return (mu*mu*mu) / lambda;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return (mu*mu*mu) / lambda;
return ( mu * mu * mu ) / lambda;

```

<!-- <div class="equation" align="center" data-raw-text="\operatorname{Var}\left[ X \right] = \frac{\mu^{3}}{\lambda}" data-equation="eq:wald_variance">
<img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@51534079fef45e990850102147e8945fb023d1d0/lib/node_modules/@stdlib/stats/base/dists/wald/variance/docs/img/equation_wald_variance.svg" alt="Variance for a Wald distribution.">
Copy link
Member

Choose a reason for hiding this comment

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

Better to remove this link since you haven't added the svg file for wald/variance

@manit2004
Copy link
Contributor Author

@Neerajpathak07 suggestions have been implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Changes Pull request which needs changes before being merged. Needs Review A pull request which needs code review. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants