diff --git a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf/README.md b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf/README.md index 5ec8befb6a4a..2798e66e45ab 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/hypergeometric/logpmf/README.md @@ -157,6 +157,109 @@ for ( i = 0; i < 10; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/hypergeometric/logpmf.h" +``` + +#### stdlib_base_dists_hypergeometric_logpmf( x, N, K, n ) + +Evaluates the natural logarithm of the [probability mass function][pmf] (PMF) for a [hypergeometric][hypergeometric-distribution] distribution with parameters `N` (population size), `K` (subpopulation size), and `n` (number of draws). + +```c +double out = stdlib_base_dists_hypergeometric_logpmf( 1.0, 8, 4, 2 ); +// returns ~-0.56 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **N**: `[in] int32_t` population size. +- **K**: `[in] int32_t` subpopulation size. +- **n**: `[in] int32_t` number of draws. + +```c +double stdlib_base_dists_hypergeometric_logpmf ( const double x, const int32_t N, const int32_t K, const int32_t n ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/hypergeometric/logpmf.h" +#include "stdlib/math/base/special/round.h" +#include +#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 ) { + int32_t N; + int32_t K; + int32_t n; + double y; + double x; + int i; + + for ( i = 0; i < 10; i++ ) { + x = stdlib_base_round( random_uniform( 0.0, 5.0 ) ); + N = stdlib_base_round( random_uniform( 0.0, 20.0 ) ); + K = stdlib_base_round( random_uniform( 0.0, N ) ); + n = stdlib_base_round( random_uniform( 0.0, N ) ); + y = stdlib_base_dists_hypergeometric_logpmf( x, N, K, n ); + printf( "x: %lf, N: %d, K: %d, n: %d, ln(P(X=x;N,K,n)): %lf\n", x, N, K, n, y ); + } +} +``` + +
+ + + +
+ + +