Package uk.ac.starlink.ttools.filter
Class GKArray
- java.lang.Object
-
- uk.ac.starlink.ttools.filter.GKArray
-
public class GKArray extends java.lang.Object
An implementation of the quantile sketch of Greenwald and Khanna. Acquired from https://github.com/DataDog/sketches-java.
-
-
Constructor Summary
Constructors Constructor Description GKArray(double rankAccuracy)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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
.GKArray
copy()
double
getCount()
double
getMaxValue()
double
getMinValue()
double
getRankAccuracy()
double
getValueAtQuantile(double quantile)
double[]
getValuesAtQuantiles(double[] quantiles)
boolean
isEmpty()
void
mergeWith(GKArray other)
Merges the other sketch into this one.
-
-
-
Method Detail
-
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:
java.lang.IllegalArgumentException
- ifcount
is negative
-
mergeWith
public void mergeWith(GKArray other)
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:
java.lang.NullPointerException
- ifother
isnull
-
copy
public GKArray 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:
java.util.NoSuchElementException
- if the sketch is empty
-
getMaxValue
public double getMaxValue()
- Returns:
- the maximum value that has been added to this sketch
- Throws:
java.util.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:
java.util.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:
java.util.NoSuchElementException
- if the sketch is empty
-
-