Class ExponentialHistogramQuantile

java.lang.Object
org.elasticsearch.exponentialhistogram.ExponentialHistogramQuantile

public class ExponentialHistogramQuantile extends Object
Provides quantile estimation for ExponentialHistogram instances. All algorithms assume that the values of each histogram bucket have exactly the same value, which is defined by ExponentialScaleUtils.getPointOfLeastRelativeError(long, int).
  • Constructor Details

    • ExponentialHistogramQuantile

      public ExponentialHistogramQuantile()
  • Method Details

    • getQuantile

      public static double getQuantile(ExponentialHistogram histo, double quantile)
      Estimates a quantile for the distribution represented by the given histogram. It returns the value of the element at rank max(0, min(n - 1, (quantile * (n + 1)) - 1)), where n is the total number of values and rank starts at 0. If the rank is fractional, the result is linearly interpolated from the values of the two neighboring ranks. The result is clamped to the histogram's minimum and maximum values.
      Parameters:
      histo - the histogram representing the distribution
      quantile - the quantile to query, in the range [0, 1]
      Returns:
      the estimated quantile value, or Double.NaN if the histogram is empty
    • estimateRank

      public static long estimateRank(ExponentialHistogram histo, double value, boolean inclusive)
      Estimates the rank of a given value in the distribution represented by the histogram. In other words, returns the number of values which are less than (or less-or-equal, if inclusive is true) the provided value.
      Parameters:
      histo - the histogram to query
      value - the value to estimate the rank for
      inclusive - if true, counts values equal to the given value as well
      Returns:
      the number of elements less than (or less-or-equal, if inclusive is true) the given value