diff --git a/lib/node_modules/@stdlib/stats/base/dists/planck/logpmf/README.md b/lib/node_modules/@stdlib/stats/base/dists/planck/logpmf/README.md index bd177c1db4d7..83b5da545fe6 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/planck/logpmf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/planck/logpmf/README.md @@ -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. @@ -133,6 +133,104 @@ for ( i = 0; i < lambda.length; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/planck/logpmf.h" +``` + +#### stdlib_base_dists_planck_logpmf( x, lambda ) + +Evaluates the logarithm of the probability mass function (PMF) of a Planck distribution with shape parameter `lambda`. + +```c +double out = stdlib_base_dists_planck_logpmf( 4.0 , 0.3 ); +// returns ~-2.5502 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **lambda**: `[in] double` shape parameter. + +```c +double stdlib_base_dists_planck_logpmf( const double x, const double lambda ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/planck/logpmf.h" +#include +#include +static int random_discrete_uniform( const int min, const int max ) { + return min + ( rand() % ( max - min + 1 ) ); +} + +static double random_uniform( const double min, const double max ) { + double v = (double)rand() / ( (double)RAND_MAX + 1.0 ); + return min + ( v * ( max - min ) ); +} + +int main( void ) { + double lambda; + double y; + int x; + int i; + + for ( i = 0; i < 10; i++ ) { + x = random_discrete_uniform( 0, 5 ); + lambda = random_uniform( 0.1, 5.0 ); + y = stdlib_base_dists_planck_logpmf( x, lambda ); + printf( "x: %d, lambda: %lf, F(x; lambda): %lf\n", x, lambda ,y ); + } +} +``` + +
+ + + +
+ + +