@stdlib/stats-base-dists-pareto-type1-quantile
v0.3.0
Published
Pareto (Type I) distribution quantile function.
Readme
Quantile Function
Pareto (Type I) distribution quantile function.
The quantile function for a Pareto (Type I) random variable is
for 0 <= p < 1, where alpha is the shape parameter and beta is the scale parameter.
Installation
npm install @stdlib/stats-base-dists-pareto-type1-quantileUsage
var quantile = require( '@stdlib/stats-base-dists-pareto-type1-quantile' );quantile( p, alpha, beta )
Evaluates the quantile function for a Pareto (Type I) distribution with parameters alpha (shape parameter) and beta (scale parameter).
var y = quantile( 0.8, 2.0, 1.0 );
// returns ~2.236
y = quantile( 0.8, 1.0, 10.0 );
// returns ~50.0
y = quantile( 0.1, 1.0, 10.0 );
// returns ~11.111If provided a probability p outside the interval [0,1], the function returns NaN.
var y = quantile( 1.9, 1.0, 1.0 );
// returns NaN
y = quantile( -0.1, 1.0, 1.0 );
// returns NaNIf provided NaN as any argument, the function returns NaN.
var y = quantile( NaN, 1.0, 1.0 );
// returns NaN
y = quantile( 0.5, NaN, 1.0 );
// returns NaN
y = quantile( 0.5, 1.0, NaN );
// returns NaNIf provided alpha <= 0, the function returns NaN.
var y = quantile( 0.4, -1.0, 1.0 );
// returns NaN
y = quantile( 0.4, 0.0, 1.0 );
// returns NaNIf provided beta <= 0, the function returns NaN.
var y = quantile( 0.4, 1.0, -1.0 );
// returns NaN
y = quantile( 0.4, 1.0, 0.0 );
// returns NaNquantile.factory( alpha, beta )
Returns a function for evaluating the quantile function of a Pareto (Type I) distribution with parameters alpha (shape parameter) and beta (scale parameter).
var myquantile = quantile.factory( 2.5, 0.5 );
var y = myquantile( 0.5 );
// returns ~0.66
y = myquantile( 0.8 );
// returns ~0.952Examples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var quantile = require( '@stdlib/stats-base-dists-pareto-type1-quantile' );
var opts = {
'dtype': 'float64'
};
var alpha = uniform( 10, 0.0, 5.0, opts );
var beta = uniform( 10, 0.0, 5.0, opts );
var p = uniform( 10, 0.0, 1.0, opts );
logEachMap( 'p: %0.4f, α: %0.4f, β: %0.4f, Q(p;α,β): %0.4f', p, alpha, beta, quantile );C APIs
Usage
#include "stdlib/stats/base/dists/pareto-type1/quantile.h"stdlib_base_dists_pareto_type1_quantile( p, alpha, beta )
Evaluates the quantile function for a Pareto (Type I) distribution with parameters alpha (shape parameter) and beta (scale parameter).
double y = stdlib_base_dists_pareto_type1_quantile( 0.8, 2.0, 1.0 );
// returns ~2.236The function accepts the following arguments:
- p:
[in] doubleinput probability. - alpha:
[in] doubleshape parameter. - beta:
[in] doublescale parameter.
double stdlib_base_dists_pareto_type1_quantile( const double p, const double alpha, const double beta );Examples
#include "stdlib/stats/base/dists/pareto-type1/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 alpha;
double beta;
double p;
double y;
int i;
for ( i = 0; i < 25; i++ ) {
p = random_uniform( 0.0, 1.0 );
alpha = random_uniform( 1.0, 10.0 );
beta = random_uniform( 1.0, 10.0 );
y = stdlib_base_dists_pareto_type1_quantile( p, alpha, beta );
printf( "p: %lf, α: %lf, β: %lf, Q(p;α,β): %lf\n", p, alpha, beta, 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.
