-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add Wald distribution variance package #9730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: add Wald distribution variance package #9730
Conversation
| stdlib_base_is_nan( mu ) || | ||
| stdlib_base_is_nan( lambda ) || | ||
| lambda <= 0.0 || | ||
| mu <= 0.0 |
There was a problem hiding this comment.
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.
| mu <= 0.0 | |
| mu <= 0.0 |
Planeshifter
left a comment
There was a problem hiding this 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.
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
@Planeshifter variance package has been implemented fully. Please take a look. |
Neerajpathak07
left a comment
There was a problem hiding this 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. |
There was a problem hiding this comment.
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.
| opts = { | ||
| 'dtype': 'float64' | ||
| }; | ||
| mu = uniform( 100, EPS, 100.0, opts ); | ||
| lambda = uniform( 100, EPS, 20.0, opts ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment
| double elapsed; | ||
| double lambda[ 100 ]; | ||
| double mu[ 100 ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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 ] ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| y = stdlib_base_dists_wald_variance( mu[ i % 100 ], lambda[ i % 100 ] ); | |
| y = stdlib_base_dists_wald_variance( mu[ i%100 ], lambda[ i%100 ] ); |
| μ: number | ||
| Location parameter. |
There was a problem hiding this comment.
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?
| mu = random_uniform( 0.1, 10.0 ); | ||
| lambda = random_uniform( 0.1, 20.0 ); |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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."> |
There was a problem hiding this comment.
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
|
@Neerajpathak07 suggestions have been implemented |
Progresses #209 .
Description
Tests, docs, examples and benchmark is yet to added, pending approval of the core implementation.
Related Issues
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers