|
||
---|---|---|
.. | ||
docs | ||
lib | ||
package.json | ||
README.md |
Quantile Function
Erlang distribution quantile function.
The quantile function for an Erlang random variable is
for 0 <= p < 1
, where k
is the shape parameter and lambda
is the rate parameter of the distribution. P^{-1}
is the inverse of the lower regularized incomplete gamma function. The Erlang distribution is a special case of the gamma distribution, as k
is constrained to the natural numbers.
Usage
var quantile = require( '@stdlib/stats/base/dists/erlang/quantile' );
quantile( p, k, lambda )
Evaluates the quantile function for an Erlang distribution with parameters k
(shape parameter) and lambda
(rate parameter).
var y = quantile( 0.8, 2, 1.0 );
// returns ~2.994
y = quantile( 0.5, 4, 2.0 );
// returns ~1.836
If provided a probability p
outside the interval [0,1]
, the function returns NaN
.
var y = quantile( 1.9, 1, 1.0 );
// returns NaN
y = quantile( -0.1, 1, 1.0 );
// returns NaN
If provided NaN
as any argument, the function returns NaN
.
var y = quantile( NaN, 1, 1.0 );
// returns NaN
y = quantile( 0.0, NaN, 1.0 );
// returns NaN
y = quantile( 0.0, 1, NaN );
// returns NaN
If provided a k
which is not a nonnegative integer, the function returns NaN
.
var y = quantile( 0.4, -1, 1.0 );
// returns NaN
y = quantile( 0.4, 2.5, 1.0 );
// returns NaN
If provided k = 0
, the function evaluates the quantile function of a degenerate distribution centered at 0
.
var y = quantile( 0.3, 0, 2.0 );
// returns 0.0
y = quantile( 0.9, 0, 2.0 );
// returns 0.0
If provided lambda <= 0
, the function returns NaN
.
var y = quantile( 0.4, 1, -1.0 );
// returns NaN
quantile.factory( k, lambda )
Returns a function for evaluating the quantile function of an Erlang distribution with parameters k
(shape parameter) and lambda
(rate parameter).
var myquantile = quantile.factory( 2, 2.0 );
var y = myquantile( 0.8 );
// returns ~1.497
y = myquantile( 0.4 );
// returns ~0.688
Examples
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var quantile = require( '@stdlib/stats/base/dists/erlang/quantile' );
var lambda;
var k;
var p;
var y;
var i;
for ( i = 0; i < 20; i++ ) {
p = randu();
k = round( randu() * 10.0 );
lambda = randu() * 5.0;
y = quantile( p, k, lambda );
console.log( 'p: %d, k: %d, λ: %d, Q(p;k,λ): %d', p.toFixed( 4 ), k, lambda.toFixed( 4 ), y.toFixed( 4 ) );
}