The function may be called by the names: g01amc, nag_stat_quantiles or nag_double_quantiles.
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.
g01amc 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.
Singleton R C (1969) An efficient algorithm for sorting with minimal storage: Algorithm 347 Comm. ACM12 185–187
1: – IntegerInput
On entry: the number of elements in the input vector rv.
2: – doubleInput/Output
On entry: the vector whose quantiles are to be determined.
On exit: the order of the elements in rv is not, in general, preserved.
3: – IntegerInput
On entry: the number of quantiles requested.
4: – const doubleInput
On entry: the quantiles to be calculated, in ascending order. Note that these must be between and , with returning the smallest element and the largest.
, for ;
, for .
5: – doubleOutput
On exit: contains the quantile specified by the value provided in , or an interpolated value if the quantile falls between two data values.
6: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
On entry, argument had an illegal value.
On entry, .
On entry, .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.