Top Description Inners Fields Constructors Methods
org.apache.commons.math3.stat.descriptive.rank

public Class PSquarePercentile

extends AbstractStorelessUnivariateStatistic
implements StorelessUnivariateStatistic, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic, org.apache.commons.math3.stat.descriptive.UnivariateStatistic, org.apache.commons.math3.util.MathArrays.Function
Imports
java.io.IOException, .ObjectInputStream, .Serializable, java.text.DecimalFormat, java.util.ArrayList, .Arrays, .Collection, .Collections, .List, org.apache.commons.math3.analysis.UnivariateFunction, org.apache.commons.math3.analysis.interpolation.LinearInterpolator, .NevilleInterpolator, .UnivariateInterpolator, org.apache.commons.math3.exception.InsufficientDataException, .OutOfRangeException, org.apache.commons.math3.exception.util.LocalizedFormats, org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic, .StorelessUnivariateStatistic, org.apache.commons.math3.util.MathArrays, .MathUtils, .Precision

A StorelessUnivariateStatistic estimating percentiles using the P2 Algorithm as explained by Raj Jain and Imrich Chlamtac in P2 Algorithm for Dynamic Calculation of Quantiles and Histogram Without Storing Observations.

Note

This implementation is not synchronized and produces an approximate result. For small samples, where data can be stored and processed in memory, Percentile should be used.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
PSquarePercentile.FixedCapacityList<E>

A simple fixed capacity list that has an upper bound to growth.

private static class
PSquarePercentile.Marker

The class modeling the attributes of the marker of the P-square algorithm

private static class
PSquarePercentile.Markers

Markers is an encapsulation of the five markers/buckets as indicated in the original works.

protected static interface
PSquarePercentile.PSquareMarkers

An interface that encapsulates abstractions of the P-square algorithm markers as is explained in the original works.

Field Summary

Modifier and TypeField and Description
private long
countOfObservations

Counter to count the values/observations accepted into this data set

private static final DecimalFormat
DECIMAL_FORMAT

A decimal formatter for print convenience

private static final double
DEFAULT_QUANTILE_DESIRED

A Default quantile needed in case if user prefers to use default no argument constructor.

private final List<Double>
initialFive

Initial list of 5 numbers corresponding to 5 markers

Note

watch out for the add methods that are overloaded

private transient double
lastObservation

lastObservation is the last observation value/input sample.

private PSquarePercentile.PSquareMarkers
markers

Markers is the marker collection object which comes to effect only after 5 values are inserted

private static final int
PSQUARE_CONSTANT

The maximum array size used for psquare algorithm

private double
pValue

Computed p value (i,e percentile value of data set hither to received)

private final double
quantile

The quantile needed should be in range of 0-1.

private static final long

Constructor Summary

AccessConstructor and Description
public
PSquarePercentile(final double
the percentile
p
)

Constructs a PSquarePercentile with the specific percentile value.

pack-priv
PSquarePercentile()

Default constructor that assumes a default quantile needed

Method Summary

Modifier and TypeMethod and Description
public void
public StorelessUnivariateStatistic
public boolean

Returns:

true if o is a PSquarePercentile with equivalent internal state
equals
(Object
object to compare
o
)

Overrides org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic.equals.

Returns true iff o is a PSquarePercentile returning the same values as this for getResult() and getN() and also having equal markers

public long
getN()

Implements org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic.getN.

Returns the number of values that have been added.

public double
public int
hashCode()

Overrides org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic.hashCode.

Returns hash code based on getResult() and getN()

public void
increment(final double
the observation currently being added.
observation
)

Implements abstract org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic.increment.

Implements org.apache.commons.math3.stat.descriptive.StorelessUnivariateStatistic.increment.

Updates the internal state of the statistic to reflect the addition of the new value.The internal state updated due to the new value in this context is basically of the marker positions and computation of the approximate quantile.

private double

Returns:

maximum in the data set added to this statistic
maximum
()

private double

Returns:

minimum in the data set added to this statistic
minimum
()

public static PSquarePercentile.PSquareMarkers

Returns:

an instance of PSquareMarkers
newMarkers
(final List<Double>
list of initial five elements
initialFive
,
final double
the quantile desired
p
)

A creation method to build Markers

public double

Returns:

quantile estimated by getResult()
quantile
()

Returns the quantile estimated by this statistic in the range [0.0-1.0]

public String

Returns:

string representation of state data
toString
()

Overrides java.lang.Object.toString.

Returns a string containing the last observation, the current estimate of the quantile and all markers.

Inherited from org.apache.commons.math3.stat.descriptive.AbstractStorelessUnivariateStatistic:
evaluateevaluateincrementAllincrementAll