diff --git a/lib/node_modules/@stdlib/stats/base/dists/normal/pdf/README.md b/lib/node_modules/@stdlib/stats/base/dists/normal/pdf/README.md index b548d577444b..179ac77d9690 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/normal/pdf/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/normal/pdf/README.md @@ -142,6 +142,106 @@ for ( i = 0; i < 10; i++ ) { + + +
+ + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/normal/pdf.h" +``` + +#### stdlib_base_dists_normal_pdf( x, mu, sigma ) + +Evaluates the [probability density function][pdf] (PDF) for a [normal][normal-distribution] distribution with parameters `mu` (mean) and `sigma` (standard deviation). + +```c +double y = stdlib_base_dists_normal_pdf( 2.0, 0.0, 1.0 ); +// returns ~0.054 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **mu**: `[in] double` mean. +- **sigma**: `[in] double` standard deviation. + +```c +double stdlib_base_dists_normal_pdf( const double x, const double mu, const double sigma ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/normal/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 sigma; + double mu; + double x; + double y; + int i; + + for ( i = 0; i < 10; i++ ) { + x = random_uniform( 0.0, 10.0 ); + mu = random_uniform( -5.0, 5.0 ); + sigma = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 ); + y = stdlib_base_dists_normal_pdf( x, mu, sigma ); + printf( "x: %lf, µ: %lf, σ: %lf, f(x;µ,σ): %lf\n", x, mu, sigma, y ); + } +} +``` + +
+ + +