g01am finds specified quantiles from a vector of unsorted data.
- Type: array<System..::..Double>()An array of size [n]On entry: the vector whose quantiles are to be determined.On exit: the order of the elements in rv is not, in general, preserved.
- Type: System..::..Int32On entry: the number of quantiles requested.Constraint: .
- Type: array<System..::..Double>()An array of size [nq]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.Constraints:
- , for ;
- , for .
- Type: array<System..::..Double>()An array of size [nq]On exit: contains the quantile specified by the value provided in , or an interpolated value if the quantile falls between two data values.
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.
g01am 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. ACM 12 185–187
Errors or warnings detected by the method:
On entry, . On entry, .
- On entry, some or .
- On entry, q is not in ascending order.
The average time taken by g01am is approximately proportional to . The worst case time is proportional to but this is extremely unlikely to occur.
This example computes a list of quantiles from an array of reals and an array of point values.