QUANTILE Function
Computes quantiles in a distribution.
Usage
q = QUANTILE(data, fvalues, f=f)
Input Parameters
data—A vector of any Real data-type.
fvalues—A vector of values in the range (0,1], for which the quantiles are computed.
Returned Value
q—A 1D vector of doubles of same length as fvalues, where q(i) is the quantile of the distribution (possibly interpolated) associated with fvalues(i).
Keywords
f—(Output) A 1D vector of doubles (of the same length as data) of f-values, where f(i) is the f-value of data(i).
Discussion
The ith quantile is defined in terms of X(k), the kth order statistic: if 0 < ith < 1 and 1 <= k <= n, quantile is X(ceil(n*Ith)) if n*Ith is not integral, otherwise (X(n*Ith)+ X(n*Ith + 1))/2.
From The Elements of Graphing Data, Cleveland, 1994, pg 136: "An f quantile of a distribution is a number, q, such that approximately a fraction f of the values of the distribution is less than or equal to q. f is the f-value of q. The median is the 0.5 quantile, the lower quartile is the 0.25 quantile, and the upper quartile is the 0.75 quantile".
Example
data = [5, 1, 9, 3, 14, 9, 7]
fvalues = [0.01, 0.25, 0.6, 0.75, 0.928472, 0.99]
q = QUANTILE(data, fvalues, f=f)
PM, ' Observation Data f-value'
obs = LINDGEN(N_ELEMENTS(data))
FOR i=0L, N_ELEMENTS(data)-1 DO $
PRINT, obs(i), ' ', data(i), ' ',f(i)
PM, ''
; PV-WAVE prints:
; 0 5 0.35714286
; 1 1 0.071428571
; 2 9 0.78571429
; 3 3 0.21428571
; 4 14 0.92857143
; 5 9 0.64285714
; 6 7 0.50000000
PM, ' Input f-values Associated quantiles '
FOR i=0L, N_ELEMENTS(fvalues)-1 DO $
PRINT, fvalues(i), ' ', q(i)
; PV-WAVE prints:
; 0.0100000 1.0000000
; 0.250000 3.5000000
; 0.600000 8.4000003
; 0.750000 9.0000000
; 0.928472 13.996519
; 0.990000 14.000000
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.