Package org.apache.datasketches
Class QuantilesHelper
java.lang.Object
org.apache.datasketches.QuantilesHelper
public class QuantilesHelper extends Object
Common static methods for quantiles sketches
-
Constructor Summary
Constructors Constructor Description QuantilesHelper() -
Method Summary
Modifier and Type Method Description static intchunkContainingPos(long[] wtArr, long pos)This is written in terms of a plain array to facilitate testing.static longconvertToPrecedingCummulative(long[] array)Convert the weights into totals of the weights preceding each item.static longposOfPhi(double phi, long n)Returns the zero-based index (position) of a value in the hypothetical sorted stream of values of size n.
-
Constructor Details
-
QuantilesHelper
public QuantilesHelper()
-
-
Method Details
-
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
-
posOfPhi
public static long posOfPhi(double phi, long n)Returns the zero-based index (position) of a value in the hypothetical sorted stream of values of size n.- Parameters:
phi- 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 cumlative weights array consisting of chunkspos- the position- Returns:
- the index of the chunk containing the position
-