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.
| Modifier and Type | Class and Description |
|---|---|
| private static class | PSquarePercentile.
A simple fixed capacity list that has an upper bound to growth. |
| private static class | PSquarePercentile.
The class modeling the attributes of the marker of the P-square algorithm |
| private static class | PSquarePercentile.
Markers is an encapsulation of the five markers/buckets as indicated in the original works. |
| protected static interface | PSquarePercentile.
An interface that encapsulates abstractions of the P-square algorithm markers as is explained in the original works. |
| Modifier and Type | Field 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 | 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. | 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 | serialVersionUID
Serial ID |
| Access | Constructor and Description |
|---|---|
| public | PSquarePercentile(final double
the percentile p)Constructs a PSquarePercentile with the specific percentile value. |
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public void | clear()
Implements abstract org. Implements org. Clears the internal state of the Statistic. |
| public StorelessUnivariateStatistic | copy()
Implements abstract org. Implements org. Returns a copy of the statistic with the same internal state. |
| public boolean | Returns: true ifo is a PSquarePercentile with
equivalent internal stateobject to compare o)Overrides org. Returns true iff |
| public long | getN()
Implements org. Returns the number of values that have been added. |
| public double | getResult()
Implements abstract org. Implements org. Returns the current value of the Statistic. |
| public int | hashCode()
Overrides org. Returns hash code based on getResult() and getN() |
| public void | increment(final double
the observation currently being added. observation)Implements abstract org. Implements org. 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 | |
| private double | |
| public static PSquarePercentile. | Returns: an instance of PSquareMarkerslist of initial five elements initialFive, final double the quantile desired p)A creation method to build Markers |
| public double | Returns: quantile estimated bygetResult()Returns the quantile estimated by this statistic in the range [0.0-1.0] |
| public String | Returns: string representation of state dataOverrides java. Returns a string containing the last observation, the current estimate of the quantile and all markers. |