Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: |
rv is no longer an output parameter |
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.
nag_stat_quantiles (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
Not applicable.
This example computes a list of quantiles from an array of doubles and an array of point values.
function g01am_example
fprintf('g01am example results\n\n');
rv = [4.9 7 3.9 9.5 1.3 3.1 9.7 0.3 8.5 0.6 6.2];
q = [0.25 0.5 1];
[qv, ifail] = g01am(rv, q);
fprintf('Quantile Result\n');
fprintf('%7.2f %7.4f\n',[q; qv']);