Package uk.ac.starlink.ttools.filter
Class GKArray
java.lang.Object
uk.ac.starlink.ttools.filter.GKArray
An implementation of the quantile
sketch of Greenwald and Khanna.
Acquired from https://github.com/DataDog/sketches-java.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(double value) Adds a value to the sketch.void
accept
(double value, long count) Adds a value to the sketch as many times as specified bycount
.copy()
double
getCount()
double
double
double
double
getValueAtQuantile
(double quantile) double[]
getValuesAtQuantiles
(double[] quantiles) boolean
isEmpty()
void
Merges the other sketch into this one.
-
Constructor Details
-
GKArray
public GKArray(double rankAccuracy)
-
-
Method Details
-
getRankAccuracy
public double getRankAccuracy() -
accept
public void accept(double value) Adds a value to the sketch.- Parameters:
value
- the value to be added
-
accept
public void accept(double value, long count) Adds a value to the sketch as many times as specified bycount
.- Parameters:
value
- the value to be addedcount
- the number of times the value is to be added- Throws:
IllegalArgumentException
- ifcount
is negative
-
mergeWith
Merges the other sketch into this one. After this operation, this sketch encodes the values that were added to both this and the other sketches.- Parameters:
other
- the sketch to be merged into this one- Throws:
NullPointerException
- ifother
isnull
-
copy
- Returns:
- a (deep) copy of this sketch
-
isEmpty
public boolean isEmpty()- Returns:
- iff no value has been added to this sketch
-
getCount
public double getCount()- Returns:
- the total number of values that have been added to this sketch
-
getMinValue
public double getMinValue()- Returns:
- the minimum value that has been added to this sketch
- Throws:
NoSuchElementException
- if the sketch is empty
-
getMaxValue
public double getMaxValue()- Returns:
- the maximum value that has been added to this sketch
- Throws:
NoSuchElementException
- if the sketch is empty
-
getValueAtQuantile
public double getValueAtQuantile(double quantile) - Parameters:
quantile
- a number between 0 and 1 (both included)- Returns:
- the value at the specified quantile
- Throws:
NoSuchElementException
- if the sketch is empty
-
getValuesAtQuantiles
public double[] getValuesAtQuantiles(double[] quantiles) - Parameters:
quantiles
- number between 0 and 1 (both included)- Returns:
- the values at the respective specified quantiles
- Throws:
NoSuchElementException
- if the sketch is empty
-