diff --git a/lib/node_modules/@stdlib/stats/base/dists/triangular/pdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/triangular/pdf/README.md index bb5659703e59..8b6f4c0f66be 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/triangular/pdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/triangular/pdf/README.md @@ -148,6 +148,109 @@ for ( i = 0; i < 25; i++ ) { + + +
+ + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/triangular/pdf.h" +``` + +#### stdlib_base_dists_triangular_pdf( x, a, b, c ) + +Evaluates the [probability density function][pdf] (PDF) of a [triangular][triangular-distribution] distribution with parameters `a` (lower limit), `b` (upper limit) and `c` (mode). + +```c +double y = stdlib_base_dists_triangular_pdf( 0.5, -1.0, 1.0, 0.0 ); +// returns 0.5 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **a**: `[in] double` lower limit. +- **b**: `[in] double` upper limit. +- **c**: `[in] double` mode. + +```c +double stdlib_base_dists_triangular_pdf( const double x, const double a, const double b, const double c ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/triangular/pdf.h" +#include "stdlib/constants/float64/eps.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 ) { + double a; + double b; + double c; + double x; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + x = random_uniform( 0.0, 30.0 ); + a = random_uniform( 0.0, 10.0 ); + b = random_uniform( a, 40.0 ) + STDLIB_CONSTANT_FLOAT64_EPS; + c = a + random_uniform( 0.0, b - a ); + y = stdlib_base_dists_triangular_pdf( x, a, b, c ); + printf( "x: %lf, a: %lf, b: %lf, c: %lf, f(x;a,b,c): %lf\n", x, a, b, c, y ); + } +} +``` + +
+ + +