Class GKArray

java.lang.Object
uk.ac.starlink.ttools.filter.GKArray

public class GKArray extends Object
An implementation of the quantile sketch of Greenwald and Khanna. Acquired from https://github.com/DataDog/sketches-java.
  • 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 by count.
      Parameters:
      value - the value to be added
      count - the number of times the value is to be added
      Throws:
      IllegalArgumentException - if count 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:
      NullPointerException - if other is null
    • 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:
      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