## 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.

• "R. J. Hyndman, and Y. Fan, "Sample quantiles in statistical packages," American Statistician, 50, 361-365, 1996."
• Wikipedia: Quantile
• ### Nested Class Summary

Nested Classes
Modifier and Type Class Description
static class  Quantile.QuantileType
the available quantile definitions
• ### Method Summary

All Methods
Modifier and Type Method Description
void addData​(double... data)
Recompute the statistic with more data, incrementally if possible.
long N()
Get the size of the sample.
double value()
Get the value of the statistic.
double value​(double q)
Compute the sample value corresponding to a quantile.
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Constructor Detail

• #### Quantile

public Quantile​(double[] data,
Quantile.QuantileType type)
Construct a Quantile calculator.
Parameters:
data - the data
type - the algorithm to compute Q(q)
• ### 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

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