@stdlib/stats-base-dists-weibull-quantile
v0.3.1
Published
Weibull distribution quantile function.
Readme
Quantile Function
Weibull distribution quantile function.
The quantile function for a Weibull random variable is
for 0 <= p < 1, where lambda > 0 is the scale parameter and k > 0 is the shape parameter.
Installation
npm install @stdlib/stats-base-dists-weibull-quantileUsage
var quantile = require( '@stdlib/stats-base-dists-weibull-quantile' );quantile( p, k, lambda )
Evaluates the quantile function for a Weibull distribution with shape parameter k and scale parameter lambda.
var y = quantile( 0.5, 1.0, 1.0 );
// returns ~0.693
y = quantile( 0.2, 2.0, 4.0 );
// returns ~1.89If 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.0, NaN, 1.0 );
// returns NaN
y = quantile( 0.0, 1.0, NaN );
// returns NaNIf provided k <= 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 lambda <= 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( k, lambda )
Returns a function for evaluating the quantile function of a Weibull distribution with shape parameter k and scale parameter lambda.
var myquantile = quantile.factory( 2.0, 10.0 );
var y = myquantile( 0.2 );
// returns ~4.724
y = myquantile( 0.8 );
// returns ~12.686Examples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var quantile = require( '@stdlib/stats-base-dists-weibull-quantile' );
var opts = {
'dtype': 'float64'
};
var lambda = uniform( 10, 0.0, 10.0, opts );
var k = uniform( 10, 0.0, 10.0, opts );
var p = uniform( 10, 0.0, 1.0, opts );
logEachMap( 'p: %0.4f, k: %0.4f, λ: %0.4f, Q(p;k,λ): %0.4f', p, k, lambda, quantile );C APIs
Usage
#include "stdlib/stats/base/dists/weibull/quantile.h"stdlib_base_dists_weibull_quantile( p, k, lambda )
Evaluates the quantile function for a Weibull distribution with shape parameter k and scale parameter lambda.
double out = stdlib_base_dists_weibull_quantile( 0.5, 1.0, 1.0 );
// returns ~0.693The function accepts the following arguments:
- p:
[in] doubleinput probability. - k:
[in] doubleshape parameter. - lambda:
[in] doublescale parameter.
double stdlib_base_dists_weibull_quantile( const double p, const double k, const double lambda );Examples
#include "stdlib/stats/base/dists/weibull/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 lambda;
double p;
double k;
double y;
int i;
for ( i = 0; i < 25; i++ ) {
p = random_uniform( 0.0, 1.0 );
k = random_uniform( 0.1, 5.0 );
lambda = random_uniform( 0.1, 5.0 );
y = stdlib_base_dists_weibull_quantile( p, k, lambda );
printf( "p: %lf, k: %lf, λ: %lf, Q(p;k,λ): %lf\n", p, k, lambda, y );
}
return 0;
}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.
