diff --git a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/pmf/README.md b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/pmf/README.md index 606fbb194ecc..f7e37825b010 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/pmf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/pmf/README.md @@ -157,6 +157,111 @@ logEachMap( 'x: %d, r: %0.4f, p: %0.4f, P(X=x;r,p): %0.4f', x, r, p, pmf ); + + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/negative-binomial/pmf.h" +``` + +#### stdlib_base_dists_negative_binomial_pmf( x, r, p ) + +Evaluates the [probability mass function][pmf] (PMF) for a [negative binomial][negative-binomial-distribution] distribution with number of successes until experiment is stopped `r` and success probability `p` at a value `x`. + +```c +double out = stdlib_base_dists_negative_binomial_pmf( 5.0, 20.0, 0.8 ); +// returns ~0.157 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **r**: `[in] double` number of successes until experiment is stopped. +- **p**: `[in] double` success probability. + +```c +double stdlib_base_dists_negative_binomial_pmf( const double x, const double r, const double p ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/negative-binomial/pmf.h" +#include "stdlib/math/base/special/ceil.h" +#include +#include + +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 x; + double r; + double p; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + x = stdlib_base_ceil( random_uniform( 0.0, 30.0 ) ); + r = random_uniform( 0.0, 50.0 ); + p = random_uniform( 0.0, 1.0 ); + y = stdlib_base_dists_negative_binomial_pmf( x, r, p ); + printf( "x: %lf, r: %lf, p: %lf, P(X=x;r,p): %lf\n", x, r, p, y ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + +