Class AbstractTDigest

    • Field Detail

      • gen

        final java.util.Random gen
      • recordAllData

        boolean recordAllData
    • Constructor Detail

      • AbstractTDigest

        public AbstractTDigest()
    • Method Detail

      • weightedAverageSorted

        private static double weightedAverageSorted​(double x1,
                                                    double w1,
                                                    double x2,
                                                    double w2)
        Compute the weighted average between x1 with a weight of w1 and x2 with a weight of w2. This expects x1 to be less than or equal to x2 and is guaranteed to return a number between x1 and x2.
      • interpolate

        static double interpolate​(double x,
                                  double x0,
                                  double x1)
      • encode

        static void encode​(java.nio.ByteBuffer buf,
                           int n)
      • decode

        static int decode​(java.nio.ByteBuffer buf)
      • add

        abstract void add​(double x,
                          int w,
                          Centroid base)
      • quantile

        static double quantile​(double index,
                               double previousIndex,
                               double nextIndex,
                               double previousMean,
                               double nextMean)
        Computes an interpolated value of a quantile that is between two centroids. Index is the quantile desired multiplied by the total number of samples - 1.
        Parameters:
        index - Denormalized quantile desired
        previousIndex - The denormalized quantile corresponding to the center of the previous centroid.
        nextIndex - The denormalized quantile corresponding to the center of the following centroid.
        previousMean - The mean of the previous centroid.
        nextMean - The mean of the following centroid.
        Returns:
        The interpolated mean.
      • recordAllData

        public TDigest recordAllData()
        Sets up so that all centroids will record all data assigned to them. For testing only, really.
        Specified by:
        recordAllData in class TDigest
        Returns:
        This TDigest so that configurations can be done in fluent style.
      • add

        public void add​(double x)
        Adds a sample to a histogram.
        Specified by:
        add in class TDigest
        Parameters:
        x - The value to add.
      • add

        public void add​(TDigest other)
        Description copied from class: TDigest
        Add all of the centroids of another TDigest to this one.
        Specified by:
        add in class TDigest
        Parameters:
        other - The other TDigest
      • createCentroid

        protected Centroid createCentroid​(double mean,
                                          int id)