-
-
Notifications
You must be signed in to change notification settings - Fork 817
feat: add C implementation for stats/base/dists/planck/logpmf
#5001
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?
Conversation
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
Coverage Report
The above coverage report was generated for the changes in this PR. |
lib/node_modules/@stdlib/stats/base/dists/planck/logpmf/README.md
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/base/dists/planck/logpmf/README.md
Outdated
Show resolved
Hide resolved
"@stdlib/math/base/assert/is-nan", | ||
"@stdlib/math/base/assert/is-nonnegative-integer", | ||
"@stdlib/math/base/special/expm1", | ||
"@stdlib/constants/float64/pi", |
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.
pi
should be removed as it is not used in the main.c
file right.
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 goes for the other builds as well!
@@ -21,8 +21,10 @@ | |||
// MODULES // | |||
|
|||
var bench = require( '@stdlib/bench' ); | |||
var Float64Array = require( '@stdlib/array/float64' ); | |||
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
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.
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); |
should be removed as it is not used in the file anywhere
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 for the native file as well
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.
actually it is been used in pkg+':factory'(benchmark 2) , as it uses random/array/discrete-uniform , so i made two variable one for array and one for base .
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.
Yeah, but the the ::factory
code block should have the discreteUniformbase
number generation logic for len = 100
and var x
having a Float64array
val just as you did it for the above code block!!
...dules/@stdlib/stats/base/dists/planck/logpmf/include/stdlib/stats/base/dists/planck/logpmf.h
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/base/dists/planck/logpmf/src/main.c
Outdated
Show resolved
Hide resolved
@yuvi-mittal |
--- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
stats/base/dists/planck/logpmf
@Planeshifter , this PR is ready to be merged too i believe ! |
* @private | ||
* @param {number} x - input value | ||
* @param {number} lambda - shape parameter | ||
* @returns {number} evaluated log(PMF) |
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 {number} evaluated log(PMF) | |
* @returns {number} evaluated logPMF |
* | ||
* @param x input value | ||
* @param lambda shape parameter | ||
* @return evaluated log PMF |
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 evaluated log PMF | |
* @return evaluated logPMF |
@@ -101,7 +101,7 @@ y = mylogpmf( 1.0 ); | |||
|
|||
## Notes | |||
|
|||
- In virtually all cases, using the `logpmf` or `logcdf` functions is preferable to manually computing the logarithm of the `pmf` or `cdf`, respectively, since the latter is prone to overflow and underflow. | |||
In virtually all cases, using the `logpmf` or `logcdf` functions is preferable to manually computing the logarithm of the `pmf` or `cdf`, respectively, since the latter is prone to overflow and underflow. |
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.
In virtually all cases, using the `logpmf` or `logcdf` functions is preferable to manually computing the logarithm of the `pmf` or `cdf`, respectively, since the latter is prone to overflow and underflow. | |
- In virtually all cases, using the `logpmf` or `logcdf` functions is preferable to manually computing the logarithm of the `pmf` or `cdf`, respectively, since the latter is prone to overflow and underflow. |
#include <stdio.h> | ||
static int random_discrete_uniform( const int min, const int max ) { | ||
return min + ( rand() % ( max - min + 1 ) ); | ||
} |
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 <stdio.h> | |
static int random_discrete_uniform( const int min, const int max ) { | |
return min + ( rand() % ( max - min + 1 ) ); | |
} | |
#include <stdio.h> | |
static int random_discrete_uniform( const int min, const int max ) { | |
return min + ( rand() % ( max - min + 1 ) ); | |
} |
x[i] = discreteUniformBase(0, 40); | ||
lambda[i] = uniformBase(1.0, 10.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.
x[i] = discreteUniformBase(0, 40); | |
lambda[i] = uniformBase(1.0, 10.0); | |
x[i] = discreteUniformBase( 0, 40 ); | |
lambda[i] = uniformBase( 1.0, 10.0 ); |
* @param total total number of tests | ||
* @param passing total number of passing tests | ||
*/ | ||
|
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.
Shouldn't have empty lines between documentation blocks and functions in this file.
/** | ||
* Generates a random number on the interval [min,max). | ||
* | ||
* @param min minimum value (inclusive) | ||
* @param max maximum value (exclusive) | ||
* @return random number | ||
*/ | ||
|
||
static int random_discrete_uniform( int min, int max ) { | ||
return min + rand() % ( max - min + 1 ); | ||
} | ||
|
||
static double random_uniform( double min, double max ) { | ||
double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); | ||
return min + ( v * ( max - min ) ); | ||
} |
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.
Need to document both functions here.
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 your efforts, @yuvi-mittal! This should be fairly close, but there are a bunch of errors that need to be resolved before it can be merged.
I will check them by EOD, but I have one question—why aren't these linting errors showing on my local system? There are no lint errors locally. |
@yuvi-mittal Thanks for taking care of these! All checks are green on CI too, so there is nothing wrong with your local setup. Simple explanation is that we have various conventions that are currently not yet enforced via automated linting because we didn't have the bandwidth to do so or which would be infeasible to automatically check. |
@kgryte , The PR looks good to me , can you please review if there is any issue ! |
@yuvi-mittal The comments I left still need to be addressed. |
Yess , Sorry . I will look into that ! |
Resolves #5000
Description
This pull request:
Add C implementation for @stdlib/stats/base/dists/planck/logpmf
Related Issues
This pull request:
@stdlib/stats/base/dists/planck/logpmf
#5000Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers