Class QuantilesUtil
- java.lang.Object
-
- org.apache.datasketches.quantilescommon.QuantilesUtil
-
public final class QuantilesUtil extends Object
Utilities for the quantiles sketches.- Author:
- Lee Rhodes
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkDoublesSplitPointsOrder(double[] values)
Checks the sequential validity of the given array of double values.static void
checkFloatsSplitPointsOrder(float[] values)
Checks the sequential validity of the given array of float values.static void
checkNormalizedRankBounds(double nRank)
Checks that the given normalized rank: 0 ≤ nRank ≤ 1.0.static double[]
equallyWeightedRanks(int num)
Returns a double array of ranks that defines equally weighted regions between 0.0, inclusive and 1.0, inclusive.static double[]
evenlyLogSpaced(double value1, double value2, int num)
Returns a double array of values between min and max inclusive where the log of the returned values are evenly spaced.static double[]
evenlySpacedDoubles(double value1, double value2, int num)
Returns a double array of evenly spaced values between value1, inclusive, and value2 inclusive.static float[]
evenlySpacedFloats(float value1, float value2, int num)
Returns a float array of evenly spaced values between value1, inclusive, and value2 inclusive.
-
-
-
Method Detail
-
checkNormalizedRankBounds
public static final void checkNormalizedRankBounds(double nRank)
Checks that the given normalized rank: 0 ≤ nRank ≤ 1.0.- Parameters:
nRank
- the given normalized rank.
-
checkDoublesSplitPointsOrder
public static final void checkDoublesSplitPointsOrder(double[] values)
Checks the sequential validity of the given array of double values. They must be unique, monotonically increasing and not NaN.- Parameters:
values
- the given array of double values
-
checkFloatsSplitPointsOrder
public static final void checkFloatsSplitPointsOrder(float[] values)
Checks the sequential validity of the given array of float values. They must be unique, monotonically increasing and not NaN.- Parameters:
values
- the given array of double values
-
equallyWeightedRanks
public static double[] equallyWeightedRanks(int num)
Returns a double array of ranks that defines equally weighted regions between 0.0, inclusive and 1.0, inclusive. The 0.0 and 1.0 end points are part of the returned array and are the getMinItem() and getMaxItem() values of the sketch. For example, if num == 2, three values will be returned: 0.0, .5, and 1, where the two equally weighted regions are 0.0 to 0.5, and 0.5 to 1.0.- Parameters:
num
- the total number of equally weighted regions between 0.0 and 1.0 defined by the ranks in the returned array. num must be 1 or greater.- Returns:
- a double array of num + 1 ranks that define the boundaries of num equally weighted regions between 0.0, inclusive and 1.0, inclusive.
- Throws:
IllegalArgumentException
- if num is less than 1.
-
evenlySpacedFloats
public static float[] evenlySpacedFloats(float value1, float value2, int num)
Returns a float array of evenly spaced values between value1, inclusive, and value2 inclusive. If value2 > value1, the resulting sequence will be increasing. If value2 < value1, the resulting sequence will be decreasing.- Parameters:
value1
- will be in index 0 of the returned arrayvalue2
- will be in the highest index of the returned arraynum
- the total number of values including value1 and value2. Must be 2 or greater.- Returns:
- a float array of evenly spaced values between value1, inclusive, and value2 inclusive.
-
evenlySpacedDoubles
public static double[] evenlySpacedDoubles(double value1, double value2, int num)
Returns a double array of evenly spaced values between value1, inclusive, and value2 inclusive. If value2 > value1, the resulting sequence will be increasing. If value2 < value1, the resulting sequence will be decreasing.- Parameters:
value1
- will be in index 0 of the returned arrayvalue2
- will be in the highest index of the returned arraynum
- the total number of values including value1 and value2. Must be 2 or greater.- Returns:
- a float array of evenly spaced values between value1, inclusive, and value2 inclusive.
-
evenlyLogSpaced
public static double[] evenlyLogSpaced(double value1, double value2, int num)
Returns a double array of values between min and max inclusive where the log of the returned values are evenly spaced. If value2 > value1, the resulting sequence will be increasing. If value2 < value1, the resulting sequence will be decreasing.- Parameters:
value1
- will be in index 0 of the returned array, and must be greater than zero.value2
- will be in the highest index of the returned array, and must be greater than zero.num
- the total number of values including value1 and value2. Must be 2 or greater- Returns:
- a double array of exponentially spaced values between value1 and value2 inclusive.
-
-