public class PSquarePercentile extends AbstractStorelessUnivariateStatistic implements StorelessUnivariateStatistic, java.io.Serializable
StorelessUnivariateStatistic
estimating percentiles using the
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.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.
|
Modifier and Type | Field and Description |
---|---|
private long |
countOfObservations
Counter to count the values/observations accepted into this data set
|
private static java.text.DecimalFormat |
DECIMAL_FORMAT
A decimal formatter for print convenience
|
private static double |
DEFAULT_QUANTILE_DESIRED
A Default quantile needed in case if user prefers to use default no
argument constructor.
|
private java.util.List<java.lang.Double> |
initialFive
Initial list of 5 numbers corresponding to 5 markers.
|
private 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 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 double |
quantile
The quantile needed should be in range of 0-1.
|
private static long |
serialVersionUID
Serial ID
|
Constructor and Description |
---|
PSquarePercentile()
Default constructor that assumes a
default quantile needed |
PSquarePercentile(double p)
Constructs a PSquarePercentile with the specific percentile value.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the internal state of the Statistic
|
StorelessUnivariateStatistic |
copy()
Returns a copy of the statistic with the same internal state.
|
boolean |
equals(java.lang.Object o)
Returns true iff
o is a PSquarePercentile returning the
same values as this for getResult() and getN() and also
having equal markers |
long |
getN()
Returns the number of values that have been added.
|
double |
getResult()
Returns the current value of the Statistic.
|
int |
hashCode()
Returns hash code based on getResult() and getN()
|
void |
increment(double observation)
Updates the internal state of the statistic to reflect the addition of the new value.
|
private double |
maximum() |
private double |
minimum() |
static PSquarePercentile.PSquareMarkers |
newMarkers(java.util.List<java.lang.Double> initialFive,
double p)
A creation method to build Markers
|
double |
quantile()
Returns the quantile estimated by this statistic in the range [0.0-1.0]
|
java.lang.String |
toString()
Returns a string containing the last observation, the current estimate
of the quantile and all markers.
|
evaluate, evaluate, incrementAll, incrementAll
evaluate, getData, getDataRef, setData, setData, test, test, test, test
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
incrementAll, incrementAll
evaluate, evaluate
private static final int PSQUARE_CONSTANT
private static final double DEFAULT_QUANTILE_DESIRED
private static final long serialVersionUID
private static final java.text.DecimalFormat DECIMAL_FORMAT
private final java.util.List<java.lang.Double> initialFive
private final double quantile
PSquarePercentile(double)
ensures that passed in percentile is
divided by 100.private transient double lastObservation
private PSquarePercentile.PSquareMarkers markers
private double pValue
private long countOfObservations
public PSquarePercentile(double p)
p
- the percentileOutOfRangeException
- if p is not greater than 0 and less
than or equal to 100PSquarePercentile()
default quantile
neededpublic int hashCode()
hashCode
in class AbstractStorelessUnivariateStatistic
public boolean equals(java.lang.Object o)
o
is a PSquarePercentile
returning the
same values as this for getResult()
and getN()
and also
having equal markersequals
in class AbstractStorelessUnivariateStatistic
o
- object to compareo
is a PSquarePercentile
with
equivalent internal statepublic void increment(double observation)
increment
in interface StorelessUnivariateStatistic
increment
in class AbstractStorelessUnivariateStatistic
observation
- the observation currently being added.public java.lang.String toString()
toString
in class java.lang.Object
public long getN()
getN
in interface StorelessUnivariateStatistic
public StorelessUnivariateStatistic copy()
copy
in interface StorelessUnivariateStatistic
copy
in interface UnivariateStatistic
copy
in class AbstractStorelessUnivariateStatistic
public double quantile()
getResult()
public void clear()
clear
in interface StorelessUnivariateStatistic
clear
in class AbstractStorelessUnivariateStatistic
public double getResult()
getResult
in interface StorelessUnivariateStatistic
getResult
in class AbstractStorelessUnivariateStatistic
Double.NaN
if it
has been cleared or just instantiated.private double maximum()
private double minimum()
public static PSquarePercentile.PSquareMarkers newMarkers(java.util.List<java.lang.Double> initialFive, double p)
initialFive
- list of initial five elementsp
- the quantile desired