Class QuantilesHelper

• public class QuantilesHelper
extends Object
Common static methods for quantiles sketches
• Constructor Summary

Constructors
Constructor and Description
QuantilesHelper()
• Method Summary

All Methods
Modifier and Type Method and Description
static int chunkContainingPos(long[] arr, long pos)
This is written in terms of a plain array to facilitate testing.
static long convertToPrecedingCummulative(long[] array)
Convert the weights into totals of the weights preceding each item
static double[] getEvenlySpacedRanks(int n)
Compute an array of evenly spaced normalized ranks from 0 to 1 inclusive.
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.
• 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
Parameters:
array - of weights
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[] arr,
long pos)
This is written in terms of a plain array to facilitate testing.
Parameters:
arr - the chunk containing the position
pos - the position
Returns:
the index of the chunk containing the position
• getEvenlySpacedRanks

public static double[] getEvenlySpacedRanks(int n)
Compute an array of evenly spaced normalized ranks from 0 to 1 inclusive. A value of 1 will result in , 2 will result in [0, 1], 3 will result in [0, .5, 1] and so on.
Parameters:
n - number of ranks needed (must be greater than 0)
Returns:
array of ranks