diff --git a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/logpmf/README.md b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/logpmf/README.md index 0143acf5f34a..0907e401ea2b 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/logpmf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/negative-binomial/logpmf/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2026 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -157,6 +157,105 @@ logEachMap( 'x: %d, r: %0.4f, p: %0.4f, ln(P(X=x;r,p)): %0.4f', x, r, p, logpmf + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/negative-binomial/logpmf.h" +``` + +#### stdlib_base_dists_negative_binomial_logpmf( x, r, p ) + +Evaluates the natural logarithm of the probability mass function (PMF) for a negative binomial distribution with number of successes until experiment is stopped `r` and success probability `p`. + +```c +double out = stdlib_base_dists_negative_binomial_logpmf( 5.0, 20.0, 0.8 ); +// returns ~-1.853 +``` + +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_logpmf( const double x, const double r, const double p ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/negative-binomial/logpmf.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 r; + double p; + double x; + 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_logpmf( x, r, p ); + printf( "x: %lf, r: %lf, p: %lf, ln(P(X=x;r,p)): %lf\n", x, r, p, y ); + } +} +``` + +
+ + + +
+ + +