time-to-botec/squiggle/node_modules/@stdlib/stats/base/dists/bernoulli/quantile
NunoSempere b6addc7f05 feat: add the node modules
Necessary in order to clearly see the squiggle hotwiring.
2022-12-03 12:44:49 +00:00
..
docs feat: add the node modules 2022-12-03 12:44:49 +00:00
lib feat: add the node modules 2022-12-03 12:44:49 +00:00
package.json feat: add the node modules 2022-12-03 12:44:49 +00:00
README.md feat: add the node modules 2022-12-03 12:44:49 +00:00

Quantile Function

Bernoulli distribution quantile function.

The quantile function for a Bernoulli random variable is

Quantile function for a Bernoulli distribution.

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

Usage

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

quantile( r, p )

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

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

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

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

If provided r <= 0 or r >= 0, 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 Bernoulli distribution with success probability p.

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

y = myquantile( 0.8 );
// returns 1

y = myquantile( 1.0 );
// returns 1

Examples

var randu = require( '@stdlib/random/base/randu' );
var quantile = require( '@stdlib/stats/base/dists/bernoulli/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 ) );
}