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. ACM 12 185–187
Not applicable.
This example computes a list of quantiles from an array of doubles and an array of point values.
Example 2 in
m01dsc
demonstrates how to calculate weighted quantiles using ranking, binary searches and interpolation.