Class QuantilesHelper


  • public class QuantilesHelper
    extends Object
    Common static methods for classic quantiles and KLL sketches
    • Constructor Detail

      • QuantilesHelper

        public QuantilesHelper()
    • Method Detail

      • convertToPrecedingCummulative

        public static long convertToPrecedingCummulative​(long[] array)
        Convert the weights into totals of the weights preceding each item. An array of {1,1,1,0} becomes {0,1,2,3}
        Parameters:
        array - of weights where first element is zero
        Returns:
        total weight
      • posOfRank

        public static long posOfRank​(double rank,
                                     long n)
        Returns the linear zero-based index (position) of a value in the hypothetical sorted stream of values of size n.
        Parameters:
        rank - the fractional position where: 0 ≤ φ ≤ 1.0.
        n - the size of the stream
        Returns:
        the index, a value between 0 and n-1.
      • posOfPhi

        @Deprecated
        public static long posOfPhi​(double rank,
                                    long n)
        Deprecated.
        use posOfRank(double, long) instead. Version 3.2.0.
        Returns the linear zero-based index (position) of a value in the hypothetical sorted stream of values of size n.
        Parameters:
        rank - the fractional position where: 0 ≤ φ ≤ 1.0.
        n - the size of the stream
        Returns:
        the index, a value between 0 and n-1.
      • chunkContainingPos

        public static int chunkContainingPos​(long[] wtArr,
                                             long pos)
        This is written in terms of a plain array to facilitate testing.
        Parameters:
        wtArr - the cumulative weights array consisting of chunks
        pos - the position
        Returns:
        the index of the chunk containing the position