diff --git a/lib/node_modules/@stdlib/stats/base/dists/chi/quantile/README.md b/lib/node_modules/@stdlib/stats/base/dists/chi/quantile/README.md index 483cf284d7a8..7aa2e22a6e1c 100644 --- a/lib/node_modules/@stdlib/stats/base/dists/chi/quantile/README.md +++ b/lib/node_modules/@stdlib/stats/base/dists/chi/quantile/README.md @@ -26,17 +26,12 @@ limitations under the License. The [quantile function][quantile-function] for a [chi][chi-distribution] random variable is - + ```math -Q(p; k) = 2 \cdot P^{-1}( p, k/2 ) +Q(p; k) = \sqrt{ 2 \cdot P^{-1}( p, k/2 ) } ``` - - for `0 <= p < 1`, where `k` is the degrees of freedom and `P^{-1}` is the inverse of the lower, regularized [incomplete gamma function][@stlib/math/base/special/gammaincinv]. @@ -147,6 +142,101 @@ logEachMap( 'p: %0.4f, k: %0.4f, Q(p;k): %0.4f', p, k, quantile ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dists/chi/quantile.h" +``` + +#### stdlib_base_dists_chi_quantile( p, k ) + +Evaluates the [quantile function][quantile-function] for a [chi][chi-distribution] distribution with degrees of freedom `k`. + +```c +double out = stdlib_base_dists_chi_quantile( 0.8, 1.0 ); +// returns ~1.282 +``` + +The function accepts the following arguments: + +- **p**: `[in] double` input probability. +- **k**: `[in] double` degrees of freedom. + +```c +double stdlib_base_dists_chi_quantile( const double p, const double k ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dists/chi/quantile.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 k; + double p; + double y; + int i; + + for ( i = 0; i < 25; i++ ) { + p = random_uniform( 0.0, 1.0 ); + k = random_uniform( 0.1, 20.0 ); + y = stdlib_base_dists_chi_quantile( p, k ); + printf( "p: %lf, k: %lf, Q(p;k): %lf\n", p, k, y ); + } +} +``` + +
+ + + +
+ + +