-
-
Notifications
You must be signed in to change notification settings - Fork 592
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 C implementation for stats/base/dists/levy/median
#4076
base: develop
Are you sure you want to change the base?
Conversation
Coverage Report
The above coverage report was generated for the changes in this PR. |
/stdlib update-copyright-years |
* // returns ~0.795 | ||
*/ | ||
double stdlib_base_dists_levy_median( const double mu, const double c ) { | ||
double DENOM = 2.0 * stdlib_base_pow( stdlib_base_erfcinv( 0.5 ), 2.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.
@vivekmaurya001 We should pre-compute this constant as a static const
in the outer scope since erfcinv(0.5)
is constant and doesn't change with the inputs.
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.
ook
#include "stdlib/math/base/special/pow.h" | ||
|
||
|
||
/** |
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.
#include "stdlib/math/base/special/pow.h" | |
/** | |
#include "stdlib/math/base/special/pow.h" | |
/** |
|
||
#### stdlib_base_dists_levy_median( mu, c ) | ||
|
||
Evaluates the [median][median] for a [Lévy][levy-distribution] distribution with location parameter `mu` and scale parameter `c`. |
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 [median][median] for a [Lévy][levy-distribution] distribution with location parameter `mu` and scale parameter `c`. | |
Returns the [median][median] for a [Lévy][levy-distribution] distribution with location parameter `mu` and scale parameter `c`. |
int i; | ||
|
||
for ( i = 0; i < 25; i++ ) { | ||
mu = random_uniform( 0.0, 10.0 ) - 5.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.
mu = random_uniform( 0.0, 10.0 ) - 5.0; | |
mu = random_uniform( -5.0, 5.0 ); |
int i; | ||
|
||
for ( i = 0; i < 25; i++ ) { | ||
mu = random_uniform( 0.0, 10.0 ) - 5.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.
mu = random_uniform( 0.0, 10.0 ) - 5.0; | |
mu = random_uniform( -5.0, 5.0 ); |
mu[ i ] = random_uniform( 0.0, 100.0 ) - 50.0; | ||
c[ i ] = random_uniform( 0.0, 20.0 ) + STDLIB_CONSTANT_FLOAT64_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.
mu[ i ] = random_uniform( 0.0, 100.0 ) - 50.0; | |
c[ i ] = random_uniform( 0.0, 20.0 ) + STDLIB_CONSTANT_FLOAT64_EPS; | |
mu[ i ] = random_uniform( -50.0, 50.0 ); | |
c[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 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.
Left a comment on how to optimize the source implementation and pointed out a bunch of other small issues. Should be ready to land once these are addressed.
Resolves #3727.
Description
This pull request:
@stdlib/stats/base/dists/levy/median
#3727Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers