SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.descriptive.rank
Class Quantile

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.descriptive.rank.Quantile
All Implemented Interfaces:
Statistic

public class Quantile
extends java.lang.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:

Nested Class Summary
static class Quantile.Type
          the quantile definitions available For details, please refer to Sample quantiles in statistical packages by Hyndman, R.
 
Field Summary
 Quantile.Type type
          the quantile definition
 
Constructor Summary
Quantile(double[] data)
          Construct a Quantile instance using the default type: APPROXIMATELY_MEDIAN_UNBIASED.
Quantile(double[] data, Quantile.Type type)
          Construct a Quantile instance.
 
Method Summary
 void addData(double... data)
          Recompute the statistic, 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 probability.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

type

public final Quantile.Type type
the quantile definition

Constructor Detail

Quantile

public Quantile(double[] data,
                Quantile.Type type)
Construct a Quantile instance.

Parameters:
data - the data
type - the algorithm to compute Q(q)

Quantile

public Quantile(double[] data)
Construct a Quantile instance using the default type: APPROXIMATELY_MEDIAN_UNBIASED.

Parameters:
data - the data
Method Detail

addData

public void addData(double... data)
Description copied from interface: Statistic
Recompute the statistic, 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

value

public double value(double q)
Compute the sample value corresponding to a probability.

Parameters:
q - a quantile
Returns:
the value for the q quantile

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

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.