Quantile Function

Geometric distribution quantile function.

The quantile function for a geometric random variable is

for 0 < r < 1, where p is the success probability.

Usage

var quantile = require( '@stdlib/stats/base/dists/geometric/quantile' );

quantile( r, p )

Evaluates the quantile function for a geometric distribution with success probability p at a value r.

var y = quantile( 0.8, 0.4 );
// returns 3

y = quantile( 0.5, 0.4 );
// returns 1

y = quantile( 0.9, 0.1 );
// returns 21

If provided an input probability r 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 NaN

If provided NaN as any argument, the function returns NaN.

var y = quantile( NaN, 1.0 );
// returns NaN

y = quantile( 0.0, NaN );
// returns NaN

If provided a success probability p outside the interval [0,1], the function returns NaN.

var y = quantile( 0.4, -1.0 );
// returns NaN

y = quantile( 0.4, 1.5 );
// returns NaN

quantile.factory( p )

Returns a function for evaluating the quantile function for a geometric distribution with success probability p.

var myquantile = quantile.factory( 0.4 );
var y = myquantile( 0.4 );
// returns 0

y = myquantile( 0.8 );
// returns 3

y = myquantile( 1.0 );
// returns Infinity

Examples

var randu = require( '@stdlib/random/base/randu' );
var quantile = require( '@stdlib/stats/base/dists/geometric/quantile' );

var p;
var r;
var y;
var i;

for ( i = 0; i < 10; i++ ) {
    r = randu();
    p = randu();
    y = quantile( r, p );
    console.log( 'r: %d, p: %d, Q(r;p): %d', r.toFixed( 4 ), p.toFixed( 4 ), y.toFixed( 4 ) );
}
Did you find this page helpful?