feat: add Wald distribution mean package#9502
feat: add Wald distribution mean package#9502Planeshifter merged 23 commits intostdlib-js:developfrom
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.
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.
| * 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.
| * 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.
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.
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 <pburckhardt@outlook.com>
| * y = mean( 4.0, 2.0 ); | ||
| * // returns 4.0 | ||
| * | ||
| * var y = mean( 0.0, 1.0 ); |
There was a problem hiding this comment.
| * 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.
| > 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.
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.
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.
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.
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.
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.
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 <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Planeshifter
left a comment
There was a problem hiding this comment.
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