8000 feat: add Wald distribution PDF by manit2004 · Pull Request #9324 · stdlib-js/stdlib · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@manit2004
Copy link
Contributor
@manit2004 manit2004 commented Dec 23, 2025

Resolves #209

Description

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

This pull request:

  • Add main.js with PDF calculation for Wald distribution
  • Add factory.js for parameterized PDF functions
  • Add index.js as entry point with factory attachment
  • Add native.js for C addon integration
  • Add C implementation (main.c) for performance
  • Add addon.c for Node.js native binding
  • Add pdf.h header file
  • Add Makefile for build cleanup

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 Dec 23, 2025
@manit2004 manit2004 changed the title New Feature: Implementing Wald Distribution #209 feat: Implementing Wald Distribution #209 Dec 23, 2025
@manit2004 manit2004 changed the title feat: Implementing Wald Distribution #209 feat: implement Wald distribution PDF Dec 23, 2025
@manit2004 manit2004 changed the title feat: implement Wald distribution PDF feat: implement Wald distribution Dec 23, 2025
Comment on lines 52 to 63
if (
isnan( mu ) ||
isnan( lambda )
) {
return constantFunction( NaN );
}
if ( mu <= 0.0 ) {
return constantFunction( NaN );
}
if ( lambda < 0.0 ) {
return constantFunction( NaN );
}
Copy link
Member

Choose a reason for hiding this comment

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

You can go ahead and consolidate these into a single if condition, given that all result in constantFunction( NaN ).

Comment on lines 97 to 109
if (
isnan( x ) ||
isnan( mu ) ||
isnan( lambda )
) {
return NaN;
}
if ( mu <= 0.0 ) {
return NaN;
}
if ( lambda < 0.0 ) {
return NaN;
}
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 about collapsing the if conditions into one.

Comment on lines 42 to 54
if (
stdlib_base_is_nan( x ) ||
stdlib_base_is_nan( mu ) ||
stdlib_base_is_nan( lambda )
) {
return 0.0/0.0; // NaN
}
if ( mu <= 0.0 ) {
return 0.0/0.0; // NaN
}
if ( lambda < 0.0 ) {
return 0.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.

Same comment.

Copy link
Member
@kgryte kgryte left a comment

Choose a reason for hiding this comment

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

Overall, this is looking good thus far!

@kgryte kgryte added the Feature Issue or pull request for adding a new feature. label Dec 23, 2025
@kgryte kgryte changed the title feat: implement Wald distribution feat: add Wald distribution PDF Dec 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature Issue or pull request for adding a new feature. Needs Review A pull request which needs code review. Statistics Issue or pull request related to statistical functionality.
4C55

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RFC: add the Wald distribution

3 participants

0