@stdlib/stats-base-dists-planck-quantile
v0.1.1
Published
Planck (discrete exponential) distribution quantile function.
Downloads
101
Readme
Quantile Function
Planck (discrete exponential) distribution quantile function.
The quantile function for a Planck random variable is
for 0 < p < 1 and where λ is the shape parameter.
Installation
npm install @stdlib/stats-base-dists-planck-quantileUsage
var quantile = require( '@stdlib/stats-base-dists-planck-quantile' );quantile( p, lambda )
Evaluates the quantile function for a Planck distribution with shape parameter lambda at a probability p.
var y = quantile( 0.8, 0.4 );
// returns 4.0
y = quantile( 0.5, 1.4 );
// returns 0.0
y = quantile( 0.9, 2.1 );
// returns 1.0If provided an input probability p outside the interval [0,1], the function returns NaN.
var y = quantile( 1.9, 0.5 );
// returns NaN
y = quantile( -0.1, 0.5 );
// returns NaNIf provided NaN as any argument, the function returns NaN.
var y = quantile( NaN, 1.0 );
// returns NaN
y = quantile( 0.0, NaN );
// returns NaNIf provided a shape parameter lambda which is nonpositive, the function returns NaN.
var y = quantile( 0.4, -1.0 );
// returns NaNquantile.factory( lambda )
Returns a function for evaluating the quantile function for a Planck distribution with shape parameter lambda.
var myquantile = quantile.factory( 0.4 );
var y = myquantile( 0.4 );
// returns 1.0
y = myquantile( 0.8 );
// returns 4.0
y = myquantile( 1.0 );
// returns InfinityExamples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var quantile = require( '@stdlib/stats-base-dists-planck-quantile' );
var opts = {
'dtype': 'float64'
};
var lambda = uniform( 10, 0.1, 10.0, opts );
var p = uniform( 10, 0.0, 1.0, opts );
logEachMap( 'p: %0.4f, λ: %0.4f, Q(p;λ): %0.4f', p, lambda, quantile );C APIs
Usage
#include "stdlib/stats/base/dists/planck/quantile.h"stdlib_base_dists_planck_quantile( p, lambda )
Evaluates the quantile function for a Planck (discrete exponential) distribution with probability p and shape parameter lambda.
double out = stdlib_base_dists_planck_quantile( 0.8, 0.4 );
// returns 4.0The function accepts the following arguments:
- p:
[in] doubleinput probability. - lambda:
[in] doubleshape parameter.
double stdlib_base_dists_planck_quantile( const double p, const double lambda );Examples
#include "stdlib/stats/base/dists/planck/quantile.h"
#include <stdlib.h>
#include <stdio.h>
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 p;
double lambda;
double y;
int i;
for ( i = 0; i < 25; i++ ) {
p = random_uniform( 0.0, 1.0 );
lambda = random_uniform( 0.1, 5.0 );
y = stdlib_base_dists_planck_quantile( p, lambda );
printf( "p: %lf, λ: %lf, Q(p;λ): %lf\n", p, lambda, y );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
