-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add Wald distribution mean package #9502
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
feat: add Wald distribution mean package #9502
Conversation
| * @example | ||
| * var y = mean( 0.0, 1.0 ); | ||
| * // returns NaN | ||
| * | ||
| * @example | ||
| * var y = mean( 1.0, 0.0 ); | ||
| * // returns NaN |
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.
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`. |
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.
| * 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`. |
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.
| * 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`. |
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.
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.
Coverage Report
The above coverage report was generated for the changes in this PR. |
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 for the edits!
The PR is currently missing README.md, benchmarks, and also contains extraneous changes to normal/mean that should be reverted.
lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/base/dists/normal/mean/docs/types/index.d.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: Philipp Burckhardt <[email protected]>
| * y = mean( 4.0, 2.0 ); | ||
| * // returns 4.0 | ||
| * | ||
| * var y = mean( 0.0, 1.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.
| * 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 ); |
| > y = {{alias}}( 4.0, 2.0 ) | ||
| 4.0 | ||
| > var y = {{alias}}( 0.0, 1.0 ) | ||
| NaN | ||
| > var y = {{alias}}( 1.0, 0.0 ) | ||
| NaN |
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 = {{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 |
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.
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."> --> |
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.
Incorrectly referring to normal distribution here and below.
|
|
||
| b.tic(); | ||
| for ( i = 0; i < b.iterations; i++ ) { | ||
| mu = ( randu()*100.0 ) + EPS; |
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 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.
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.
Consult other stats packages for how this should look these days.
| #ifndef STDLIB_CONSTANT_FLOAT64_EPS | ||
| #define STDLIB_CONSTANT_FLOAT64_EPS 2.22044604925031308e-16 | ||
| #endif |
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.
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.
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.
Left a bunch more comments.
lib/node_modules/@stdlib/stats/base/dists/wald/mean/docs/repl.txt
Outdated
Show resolved
Hide resolved
Signed-off-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>
Signed-off-by: Philipp Burckhardt <[email protected]>
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.
LGTM! Thanks for cleaning the PR up and getting it into a good shape!
PR Commit MessagePlease review the above commit message and make any necessary adjustments. |
Progresses #209
Description
Tests, docs, examples and benchmark is yet to added, pending approval of the core implementation.
Related Issues
This pull request has the following related issues:
Questions
No.
Other
I have used this Wiki page as a reference.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
@stdlib-js/reviewers