naginterfaces.library.stat.quantiles¶
- naginterfaces.library.stat.quantiles(rv, q)[source]¶
quantiles
finds specified quantiles from a vector of unsorted data.For full information please refer to the NAG Library document for g01am
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g01/g01amf.html
- Parameters
- rvfloat, array-like, shape
The vector whose quantiles are to be determined.
- qfloat, array-like, shape
The quantiles to be calculated, in ascending order. Note that these must be between and , with returning the smallest element and the largest.
- Returns
- qvfloat, ndarray, shape
contains the quantile specified by the value provided in , or an interpolated value if the quantile falls between two data values.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, an element of was less than or greater than .
- (errno )
On entry, was not in ascending order.
- Notes
A quantile is a value which divides a frequency distribution such that there is a given proportion of data values below the quantile. For example, the median of a dataset is the quantile because half the values are less than or equal to it; and the quantile is the th percentile.
quantiles
uses a modified version of Singleton’s ‘median-of-three’ Quicksort algorithm (Singleton (1969)) to determine specified quantiles of a vector of real values. The input vector is partially sorted, as far as is required to compute desired quantiles; for a single quantile, this is much faster than sorting the entire vector. Where necessary, linear interpolation is also carried out to return the values of quantiles which lie between two data points.
- References
Singleton, R C, 1969, An efficient algorithm for sorting with minimal storage: Algorithm 347, Comm. ACM (12), 185–187