Skip to content

Conversation

@manit2004
Copy link
Contributor

@manit2004 manit2004 commented Jan 2, 2026

Progresses #209

Description

This is a WIP pull request. Currently the core functionalities of Wald Distribution mean 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?

This pull request has the following related issues:

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.

I have used this Wiki page as a reference.

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 2, 2026
@stdlib-bot stdlib-bot added the Potential Duplicate There might be another pull request resolving the same issue. label Jan 3, 2026
@Planeshifter Planeshifter self-requested a review January 4, 2026 06:40
Comment on lines +35 to +41
* @example
* var y = mean( 0.0, 1.0 );
* // returns NaN
*
* @example
* var y = mean( 1.0, 0.0 );
* // returns NaN
Copy link
Member

@Planeshifter Planeshifter Jan 4, 2026

Choose a reason for hiding this comment

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

First examples should always showcase valid inputs (this is something that should be addressed in various files).

// MAIN //

/**
* Returns the expected value for a wald distribution with mean `mu` and standard deviation `sigma`.
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
* Returns the expected value for a wald distribution with mean `mu` and standard deviation `sigma`.
* Returns the expected value for a Wald distribution with mean `mu` and standard deviation `sigma`.

// MAIN //

/**
* Evaluates the expected value for a Wald distribution with mean `mu` and standard deviation `sigma`.
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
* Evaluates the expected value for a Wald distribution with mean `mu` and standard deviation `sigma`.
* Returns the expected value for a Wald distribution with mean `mu` and standard deviation `sigma`.

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.

As in #9324, the Wald distribution has a second shape parameter lambda and not standard deviation sigma, so this will have to be updated across this PR.

@manit2004 manit2004 requested a review from Planeshifter January 4, 2026 12:43
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 4, 2026

Coverage Report

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

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

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 for the edits!

The PR is currently missing README.md, benchmarks, and also contains extraneous changes to normal/mean that should be reverted.

Signed-off-by: Philipp Burckhardt <[email protected]>
Comment on lines 29 to 32
* y = mean( 4.0, 2.0 );
* // returns 4.0
*
* var y = mean( 0.0, 1.0 );
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 = mean( 4.0, 2.0 );
* // returns 4.0
*
* var y = mean( 0.0, 1.0 );
* var y = mean( 4.0, 2.0 );
* // returns 4.0
*
* y = mean( 0.0, 1.0 );

Comment on lines 25 to 30
> y = {{alias}}( 4.0, 2.0 )
4.0
> var y = {{alias}}( 0.0, 1.0 )
NaN
> var y = {{alias}}( 1.0, 0.0 )
NaN
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 = {{alias}}( 4.0, 2.0 )
4.0
> var y = {{alias}}( 0.0, 1.0 )
NaN
> var y = {{alias}}( 1.0, 0.0 )
NaN
> var y = {{alias}}( 4.0, 2.0 )
4.0
> y = {{alias}}( 0.0, 1.0 )
NaN
> y = {{alias}}( 1.0, 0.0 )
NaN


<section class="intro">

The [expected value][mean] for a [wald][wald-distribution] random variable with mean `μ` and shape parameter `λ > 0` is
Copy link
Member

Choose a reason for hiding this comment

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

Since the distribution is named after a person, Abraham Wald, we should capitalize it here and elsewhere and use "Wald distribution".


The [expected value][mean] for a [wald][wald-distribution] random variable with mean `μ` and shape parameter `λ > 0` is

<!-- <equation class="equation" label="eq:wald_expectation" align="center" raw="\mathbb{E}\left[ X \right] = \mu" alt="Expected value for a normal distribution."> -->
Copy link
Member

Choose a reason for hiding this comment

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

Incorrectly referring to normal distribution here and below.


b.tic();
for ( i = 0; i < b.iterations; i++ ) {
mu = ( randu()*100.0 ) + EPS;
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 update the benchmark files to use the random array functions like in the example code to move the random number generation out of the benchmarking loop.

Copy link
Member

Choose a reason for hiding this comment

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

Consult other stats packages for how this should look these days.

Comment on lines 23 to 25
#ifndef STDLIB_CONSTANT_FLOAT64_EPS
#define STDLIB_CONSTANT_FLOAT64_EPS 2.22044604925031308e-16
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Not needed; let's just use the same example as in the README.md and use 0.1 instead of STDLIB_CONSTANT_FLOAT64_EPS for the minimum value. In general, the example block in the README.md should match what is in the example files.

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.

Left a bunch more comments.

@Planeshifter Planeshifter added Needs Changes Pull request which needs changes before being merged. and removed Needs Review A pull request which needs code review. Potential Duplicate There might be another pull request resolving the same issue. labels Jan 7, 2026
@manit2004 manit2004 requested a review from Planeshifter January 7, 2026 07:54
@stdlib-bot stdlib-bot added the Needs Review A pull request which needs code review. label Jan 7, 2026
Signed-off-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>
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.

LGTM! Thanks for cleaning the PR up and getting it into a good shape!

@Planeshifter Planeshifter added the Ready To Merge A pull request which is ready to be merged. label Jan 7, 2026
@stdlib-bot stdlib-bot removed Needs Review A pull request which needs code review. Needs Changes Pull request which needs changes before being merged. labels Jan 7, 2026
@stdlib-bot
Copy link
Contributor

PR Commit Message

feat: add Wald distribution mean package

PR-URL: https://github.com/stdlib-js/stdlib/pull/9502
Closes: https://github.com/stdlib-js/stdlib/issues/209

Co-authored-by: Philipp Burckhardt <[email protected]>
Reviewed-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>

Please review the above commit message and make any necessary adjustments.

@Planeshifter Planeshifter merged commit 92d23f5 into stdlib-js:develop Jan 7, 2026
36 checks passed
@stdlib-bot stdlib-bot removed the Ready To Merge A pull request which is ready to be merged. label Jan 7, 2026
@manit2004 manit2004 deleted the feat/wald-distribution-mean-209 branch January 8, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants