public class PSquarePercentile extends AbstractStorelessUnivariateStatistic implements StorelessUnivariateStatistic, Serializable
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 |
---|---|
protected static interface |
PSquarePercentile.PSquareMarkers
An interface that encapsulates abstractions of the
P-square algorithm markers as is explained in the original works.
|
Constructor and Description |
---|
PSquarePercentile(double p)
Constructs a PSquarePercentile with the specific percentile value.
|
PSquarePercentile(PSquarePercentile original)
Copy constructor, creates a new
PSquarePercentile identical
to the original . |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the internal state of the Statistic
|
PSquarePercentile |
copy()
Returns a copy of the statistic with the same internal state.
|
boolean |
equals(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 |
getQuantile() |
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.
|
static PSquarePercentile.PSquareMarkers |
newMarkers(List<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]
|
String |
toString()
Returns a string containing the last observation, the current estimate
of the quantile and all markers.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
accept, evaluate, incrementAll, incrementAll
evaluate
andThen
public PSquarePercentile(double p)
p
- the percentileMathIllegalArgumentException
- if p is not greater than 0 and less
than or equal to 100public PSquarePercentile(PSquarePercentile original)
PSquarePercentile
identical
to the original
.original
- the PSquarePercentile
instance to copyNullArgumentException
- if original is nullpublic int hashCode()
hashCode
in class AbstractStorelessUnivariateStatistic
public boolean equals(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 String toString()
toString
in class AbstractStorelessUnivariateStatistic
public long getN()
getN
in interface StorelessUnivariateStatistic
public PSquarePercentile 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.public double getQuantile()
public static PSquarePercentile.PSquareMarkers newMarkers(List<Double> initialFive, double p)
initialFive
- list of initial five elementsp
- the quantile desiredCopyright © 2016-2022 CS GROUP. All rights reserved.