Package dev.nm.stat.descriptive.rank
Class Quantile
- java.lang.Object
-
- dev.nm.stat.descriptive.rank.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 isquantile.- See Also:
- "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 classQuantile.QuantileTypethe available quantile definitions
-
Constructor Summary
Constructors Constructor Description Quantile()Construct aQuantilecalculator using the default type:Quantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED, without initial data.Quantile(double[] data)Construct aQuantilecalculator using the default type:Quantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED.Quantile(double[] data, Quantile.QuantileType type)Construct aQuantilecalculator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddData(double... data)Recompute the statistic with more data, incrementally if possible.longN()Get the size of the sample.doublevalue()Get the value of the statistic.doublevalue(double q)Compute the sample value corresponding to a quantile.
-
-
-
Constructor Detail
-
Quantile
public Quantile(double[] data, Quantile.QuantileType type)Construct aQuantilecalculator.- Parameters:
data- the datatype- the algorithm to compute Q(q)
-
Quantile
public Quantile(double[] data)
Construct aQuantilecalculator using the default type:Quantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED.- Parameters:
data- the data
-
Quantile
public Quantile()
Construct aQuantilecalculator using the default type:Quantile.QuantileType.APPROXIMATELY_MEDIAN_UNBIASED, without initial data.
-
-
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
qquantile
-
addData
public void addData(double... data)
Description copied from interface:StatisticRecompute the statistic with more data, incrementally if possible.
-
value
public double value()
Description copied from interface:StatisticGet the value of the statistic.
-
-