Compute the p-th quantile of a sorted one-dimensional ndarray.
var quantile = require( '@stdlib/stats/base/ndarray/quantile' );Computes the p-th quantile of a sorted one-dimensional ndarray.
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var xbuf = [ 1.0, 2.0, 3.0, 4.0 ];
var x = new ndarray( 'generic', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
var v = quantile( [x], 0.5 );
// returns 2.5The function has the following parameters:
- arrays: array-like object containing a sorted one-dimensional input ndarray.
- p: quantile probability in the interval 0 and 1.
- If provided an empty ndarray, the function returns
NaN.
var linspace = require( '@stdlib/array/linspace' );
var ndarray = require( '@stdlib/ndarray/base/ctor' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var quantile = require( '@stdlib/stats/base/ndarray/quantile' );
// Create a linearly spaced sorted array:
var xbuf = linspace( 0.0, 10.0, 11 );
var x = new ndarray( 'generic', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );
var v = quantile( [ x ], 0.5 );
console.log( v );