IMSL Statistics Reference Guide > Basic Statistics > EMPIRICAL_QUANTILES Function (PV-WAVE Advantage)
  

EMPIRICAL_QUANTILES Function (PV-WAVE Advantage)
Computes empirical quantiles.
Usage
result = EMPIRICAL_QUANTILES ( x, qprop)
Input Parameters
x—An array of length n_observations, where n_observations is the number of observations, containing the data.
qprop—An array of length n_qprop, where n_qprop is the number of empirical quantiles requested, containing the desired quantile proportions. Each value must lie in the interval (0,1).
Returned Value
result—An array of length n_qprop containing the empirical quantiles corresponding to the input proportions in qprop.
Keywords
N_miss—The number of missing values, if any, in x.
Xlo—An array of length n_qprop containing the largest element of x less than or equal to the desired quantile.
Xhi—An array of length n_qprop containing the smallest element of x greater than or equal to the desired quantile.
Double—If present and nonzero, then double precision is used.
Discussion
EMPIRICAL_QUANTILES determines the empirical quantiles, as indicated in the vector qprop, from the data in x. EMPIRICAL_QUANTILES first checks to see if x is sorted; if x is not sorted, the routine does either a complete or partial sort, depending on how many order statistics are required to compute the quantiles requested.
This function returns the empirical quantiles and, for each quantile, the two order statistics from the sample that are at least as large and at least as small as the quantile. For a sample of size n, the quantile corresponding to the proportion p is defined as:
Q(p) = (1 – f)x(j) + fx(j+1)
where j = p(n + 1), f = p(n + 1) − j, and x(j) is the jth order statistic, if 1  j < n; otherwise, the empirical quantile is the smallest or largest order statistic.
Example
In this example, five empirical quantiles from a sample of size 30 are obtained. Notice that the 0.5 quantile corresponds to the sample median. The data is from Hinkley (1977) and Velleman and Hoaglin (1981). They are the measurements (in inches) of precipitation in Minneapolis/St. Paul during the month of March for 30 consecutive years.
PRO empirical_quantiles_ex1
  x = $ 
    [0.77, 1.74, 0.81, 1.20, 1.95,$  
    1.20, 0.47, 1.43, 3.37, 2.20, $ 
    3.00, 3.09, 1.51, 2.10, 0.52, $ 
    1.62, 1.31, 0.32, 0.59, 0.81, $ 
    2.81, 1.87, 1.18, 1.35, 4.75, $ 
    2.48, 0.96, 1.89, 0.90, 2.05] 
  qprop = $ 
    [0.01, 0.5,  0.9,  0.95, 0.99] 
  p_q = empirical_quantiles(x, qprop, $  
                   Xlo=p_xlo, Xhi=p_xhi)   
 
  PRINT,"          Smaller  Empirical  Larger" 
  PRINT,"Quantile   Datum    Quantile   Datum" 
  FOR i=0L, 4 DO BEGIN 
    PRINT, STRING(qprop(i),Format="(f4.2)"), "    ",$
           STRING(p_xlo(i),Format="(f7.2)"), "    ",$
           STRING(p_q(i),Format="(f7.2)"), "   ",$
           STRING(p_xhi(i),Format="(f7.2)")   
  ENDFOR
END
Output
          Smaller  Empirical  Larger
Quantile   Datum    Quantile   Datum
  0.01      0.32      0.32      0.32
  0.50      1.43      1.47      1.51
  0.90      3.00      3.08      3.09
  0.95      3.37      3.99      4.75
  0.99      4.75      4.75      4.75

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.