Class Quantile

  • All Implemented Interfaces:
    Statistic

    public class Quantile
    extends Object
    implements Statistic
    Quantiles are points taken at regular intervals from the cumulative distribution function (CDF) of a random variable. Dividing ordered data into q essentially equal-sized data subsets is the motivation for q-quantiles; the quantiles are the data values marking the boundaries between consecutive subsets. Put another way, the k-th q-quantile for a random variable is the value x such that the probability that the random variable will be less than x is at most k/q and the probability that the random variable will be more than x is at most (q - k)/q. There are q-1 q-quantiles, with k an integer satisfying 0 < k < q. The smallest observation corresponds to probability 0 and the largest probability 1. This class implements the 9 different quantile definitions in Hyndman 1996.

    The R equivalent function is quantile.

    See Also:
    • "R. J. Hyndman, and Y. Fan, "Sample quantiles in statistical packages," American Statistician, 50, 361-365, 1996."
    • Wikipedia: Quantile
    • Method Detail

      • value

        public double value​(double q)
        Compute the sample value corresponding to a quantile.
        Parameters:
        q - a quantile
        Returns:
        the value for the q quantile
      • addData

        public void addData​(double... data)
        Description copied from interface: Statistic
        Recompute the statistic with more data, incrementally if possible.
        Specified by:
        addData in interface Statistic
        Parameters:
        data - an array of new items
      • value

        public double value()
        Description copied from interface: Statistic
        Get the value of the statistic.
        Specified by:
        value in interface Statistic
        Returns:
        the statistic
      • N

        public long N()
        Description copied from interface: Statistic
        Get the size of the sample.
        Specified by:
        N in interface Statistic
        Returns:
        the sample size