Skip to content

Conversation

@shubham220420
Copy link
Contributor

Progresses: #9416

Description

What is the purpose of this pull request?

This pull request:

  • This PR adds the mean calculation for half-normal distribution function.

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.

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

Yes I took help of AI for creating test cases under the fixtures/julia directory.

{{TODO: add disclosure if applicable}}


@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 7, 2026
@stdlib-bot
Copy link
Contributor

stdlib-bot commented Jan 7, 2026

Coverage Report

Package Statements Branches Functions Lines
stats/base/dists/halfnormal/mean $\color{green}166/166$
$\color{green}+0.00%$
$\color{green}8/8$
$\color{green}+0.00%$
$\color{green}2/2$
$\color{green}+0.00%$
$\color{green}166/166$
$\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.

Flagged a bunch of issues.

@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 7, 2026
@shubham220420
Copy link
Contributor Author

shubham220420 commented Jan 7, 2026

thankyou for your reviews sir @Planeshifter , I have applied the requested changes.
Incase any lint error occurs I'll solve it, I've been working on this module from quite few hours now, and will look further tomorrow

@Planeshifter Planeshifter changed the title feat!: add implementation of halfnormal/mean feat: add implementation of halfnormal/mean Jan 7, 2026
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 your continued efforts! Should be ready to land soon.

@shubham220420
Copy link
Contributor Author

I have applied the requested suggestion sir.

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.

A few last comments.

"expected",
"halfnormal",
"univariate"
]
Copy link
Member

Choose a reason for hiding this comment

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

Can we add "mean", "average", "avg", and "expected" in its keywords?

Comment on lines +31 to +39
var sigma = uniform( 10, 0.1, 20.0, opts );
var mu = new Float64Array( sigma.length );

var i;
for ( i = 0; i < sigma.length; i++ ) {
mu[ i ] = mean( sigma[ i ] );
}

logEach( 'σ: %0.4f, E(X;σ): %0.4f', sigma, mu );
Copy link
Member

Choose a reason for hiding this comment

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

Today, we prefer to use logEachMap instead of a manual loop with logEach. This simplifies the code:

Suggested change
var sigma = uniform( 10, 0.1, 20.0, opts );
var mu = new Float64Array( sigma.length );
var i;
for ( i = 0; i < sigma.length; i++ ) {
mu[ i ] = mean( sigma[ i ] );
}
logEach( 'σ: %0.4f, E(X;σ): %0.4f', sigma, mu );
var sigma = uniform( 10, 0.1, 20.0, opts );
logEachMap( 'σ: %0.4f, E(X;σ): %0.4f', sigma, mean );

You'd also need to change the import from logEach to logEachMap and remove the Float64Array import.

if ( v === expected[i] || delta <= tol ) {
t.strictEqual( v, expected[i], 'sigma: '+sigma[i] );
} else {
t.ok( delta <= tol, 'within tolerance. σ: '+v );
Copy link
Member

Choose a reason for hiding this comment

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

The error message here has a bug - it says σ: '+v but v is the computed mean, not the sigma value. Also, the message is missing the other debugging info like expected value and delta. Compare with normal/mean/test/test.js for the full format:

Suggested change
t.ok( delta <= tol, 'within tolerance. σ: '+v );
t.ok( delta <= tol, 'within tolerance. σ: '+sigma[i]+'. y: '+v+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol+'.' );

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. Statistics Issue or pull request related to statistical functionality.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants