@stdlib/stats-base-dists-cosine-quantile
v0.3.1
Published
Raised cosine distribution quantile function.
Downloads
21,028
Readme
Quantile Function
Raised cosine distribution quantile function.
Installation
npm install @stdlib/stats-base-dists-cosine-quantileUsage
var quantile = require( '@stdlib/stats-base-dists-cosine-quantile' );quantile( p, mu, s )
Evaluates the quantile function for a raised cosine distribution with parameters mu (location parameter) and s (scale parameter).
var y = quantile( 0.5, 0.0, 1.0 );
// returns ~0.0
y = quantile( 0.2, 4.0, 2.0 );
// returns ~3.345If provided a probability p outside the interval [0,1], the function returns NaN.
var y = quantile( 1.9, 0.0, 1.0 );
// returns NaN
y = quantile( -0.1, 0.0, 1.0 );
// returns NaNIf provided NaN as any argument, the function returns NaN.
var y = quantile( NaN, 0.0, 1.0 );
// returns NaN
y = quantile( 0.0, NaN, 1.0 );
// returns NaN
y = quantile( 0.0, 0.0, NaN );
// returns NaNIf provided s < 0, the function returns NaN.
var y = quantile( 0.4, 0.0, -1.0 );
// returns NaNIf provided s = 0, the function evaluates the quantile function of a degenerate distribution centered at mu.
var y = quantile( 0.3, 8.0, 0.0 );
// returns 8.0
y = quantile( 0.9, 8.0, 0.0 );
// returns 8.0quantile.factory( mu, s )
Returns a function for evaluating the quantile function of a raised cosine distribution with parameters mu and s.
var myQuantile = quantile.factory( 10.0, 2.0 );
var y = myQuantile( 0.2 );
// returns ~9.345
y = myQuantile( 0.9 );
// returns ~10.964Examples
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var quantile = require( '@stdlib/stats-base-dists-cosine-quantile' );
var opts = {
'dtype': 'float64'
};
var p = uniform( 10, 0.0, 1.0, opts );
var mu = uniform( 10, 0.0, 10.0, opts );
var s = uniform( 10, 0.0, 10.0, opts );
logEachMap( 'p: %0.4f, µ: %0.4f, s: %0.4f, Q(p;µ,s): %0.4f', p, mu, s, quantile );C APIs
Usage
#include "stdlib/stats/base/dists/cosine/quantile.h"stdlib_base_dists_cosine_quantile( p, mu, s )
Evaluates the quantile function for a raised cosine distribution with parameters mu (location parameter) and s (scale parameter).
double out = stdlib_base_dists_cosine_quantile( 0.8, 0.0, 1.0 );
// returns ~0.327The function accepts the following arguments:
- p:
[in] doubleinput value. - mu:
[in] doublelocation parameter. - s:
[in] doublescale parameter.
double stdlib_base_dists_cosine_quantile( const double p, const double mu, const double s );Examples
#include "stdlib/stats/base/dists/cosine/quantile.h"
#include "stdlib/constants/float64/eps.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 mu;
double s;
double p;
double y;
int i;
for ( i = 0; i < 10; i++ ) {
p = random_uniform( 0.0, 1.0 );
mu = random_uniform( -50.0, 50.0 );
s = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 );
y = stdlib_base_dists_cosine_quantile( p, mu, s );
printf( "p: %.4f, µ: %.4f, s: %.4f, Q(p;µ,s): %.4f\n", p, mu, s, 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.
