diff --git a/lib/node_modules/@stdlib/stats/base/dists/erlang/cdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/erlang/cdf/README.md index 435b8c72954f..1be7d14c9c93 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/erlang/cdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/erlang/cdf/README.md @@ -164,6 +164,105 @@ logEachMap( 'x: %0.4f, k: %d, λ: %0.4f, F(x;k,λ): %0.4f', x, k, lambda, cdf ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/erlang/cdf.h" +``` + +#### stdlib_base_dists_erlang_cdf( x, k, lambda ) + +Evaluates the [cumulative distribution function][cdf] (CDF) for an [Erlang][erlang-distribution] distribution with parameters `k` (shape parameter) and `lambda` (rate parameter). + +```c +double y = stdlib_base_dists_erlang_cdf( 2.0, 1, 1.0 ); +// returns ~0.865 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **k**: `[in] double` shape parameter. +- **lambda**: `[in] double` rate parameter. + +```c +double stdlib_base_dists_erlang_cdf( const double x, const double k, const double lambda ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/erlang/cdf.h" +#include "stdlib/math/base/special/round.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 lambda; + double k; + double x; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + k = stdlib_base_round( random_uniform( 1.0, 10.0 ) ); + lambda = random_uniform( 0.0, 10.0 ); + x = random_uniform( 0.0, 20.0 ); + y = stdlib_base_dists_erlang_cdf( x, k, lambda ); + printf( "x: %lf, k: %lf, λ: %lf, F(x;k,λ): %lf\n", x, k, lambda, y ); + } +} +``` + +
+ + + +
+ + +