diff --git a/lib/node_modules/@stdlib/stats/base/dists/binomial/pmf/README.md b/lib/node_modules/@stdlib/stats/base/dists/binomial/pmf/README.md index c241e333d64b..1de196874297 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/binomial/pmf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/binomial/pmf/README.md @@ -148,6 +148,103 @@ logEachMap( 'x: %0.4f, n: %0.4f, p: %0.4f, P(X = x;n,p): %0.4f', x, n, p, pmf ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/binomial/pmf.h" +``` + +#### stdlib_base_dists_binomial_pmf( x, n, p ) + +Evaluates the probability mass function (PMF) for a binomial distribution with number of trials `n` and success probability `p` at a value `x`. + +```c +double out = stdlib_base_dists_binomial_pmf( 3.0, 20, 0.2 ); +// returns ~0.205 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **n**: `[in] double` number of trials. +- **p**: `[in] double` success probability. + +```c +double stdlib_base_dists_binomial_pmf( const double x, const double n, const double p ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/invgamma/variance.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 n; + double p; + double y; + int i; + for ( i = 0; i < 25; i++ ) { + x = random_uniform( 0.0, 20.0 ); + n = random_uniform( 0.0, 20.0 ); + n = random_uniform( 0.0, 1.0 ); + y = stdlib_base_dists_binomial_pmf( x, n, p ); + printf( "x: %lf, n: %lf, p: %lf pmf(x, n, p): %lf\n", x, n, p, y ); + } +} +``` + +
+ + + +
+ + +