Skip to content

Home / Shared Math Details / Shared Estimators and Tests / Type 8 (Hyndman-Fan) Quantiles

Type 8 (Hyndman-Fan) Quantiles

This page defines the sample quantile Quantum XL uses whenever a tool reports a median, a quartile, or a percentile. It is the Type 8 estimator of Hyndman and Fan (1996), which is approximately median-unbiased and makes no distributional assumption.

Notation

Term Description
\(p\) requested probability, \(0 \le p \le 1\)
\(n\) number of data values
\(x_{(1)} \le x_{(2)} \le \cdots \le x_{(n)}\) the data sorted in ascending order (order statistics)
\(\lfloor h \rfloor\) the greatest integer not exceeding \(h\)
\(f_i\) frequency (repeat count) of a value when the data are frequency-weighted
\(N\) total count \(\sum_i f_i\) (equals \(n\) when every \(f_i = 1\))

Quantile Q(p)

For a probability \(p\), Quantum XL computes a fractional position and interpolates between the two neighboring order statistics:

\[ h = \left(n + \tfrac{1}{3}\right)p + \tfrac{1}{3} \]
\[ Q(p) = x_{(\lfloor h \rfloor)} + \left(h - \lfloor h \rfloor\right)\left(x_{(\lfloor h \rfloor + 1)} - x_{(\lfloor h \rfloor)}\right) \]

The two indices are clamped to the range \([1, n]\) and the interpolation weight \(h - \lfloor h \rfloor\) is clamped to \([0, 1]\), so the ends behave as \(Q(0) = x_{(1)}\) (the minimum) and \(Q(1) = x_{(n)}\) (the maximum).

Frequency-weighted data

When each value carries a frequency \(f_i\), Quantum XL applies the same estimator to the virtual sample formed by repeating each value \(f_i\) times, without physically expanding it. The total count is \(N = \sum_i f_i\), and the position becomes:

\[ h = \left(N + \tfrac{1}{3}\right)p + \tfrac{1}{3} \]

Let \(V(t)\) be the value at position \(t\) of the sorted virtual sample, that is the smallest value whose cumulative frequency reaches \(t\). The quantile is:

\[ Q(p) = V(\lfloor h \rfloor) + \left(h - \lfloor h \rfloor\right)\left(V(\lfloor h \rfloor + 1) - V(\lfloor h \rfloor)\right) \]

with the same end clamping. This gives exactly the result of expanding the data and applying the unweighted formula.

Used by

  • Box Plot: the median, the quartiles \(Q_1\) and \(Q_3\), the box and whisker percentile edges, and the minimum and maximum.
  • Summary Statistics: the median, the 1, 5, 10, 90, 95, and 99 percentiles, and custom percentiles.
  • Bar Chart: the median, minimum, and maximum bar-height aggregations.

See Also

References

  1. Hyndman, R. J., and Fan, Y. (1996). Sample quantiles in statistical packages. The American Statistician, 50(4), 361-365.
  2. NIST/SEMATECH e-Handbook of Statistical Methods, section on percentiles.