Class QuantilesUtil
- java.lang.Object
-
- org.apache.datasketches.quantilescommon.QuantilesUtil
-
public final class QuantilesUtil extends Object
Utilities for the quantiles sketches.- Author:
- Lee Rhodes
-
-
Field Summary
Fields Modifier and Type Field Description static double
tailRoundingFactor
used in search to improve rounding over a wide dynamic range
-
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
checkLongsSplitPointsOrder(long[] values)
Checks the sequential validity of the given array of double values.static void
checkNormalizedRankBounds(double nRank)
Checks that the given normalized rank: 0 ≤ nRank ≤ 1.0.static double[]
equallySpacedDoubles(int num)
Returns an array of (num + 1) values that define equally sized intervals between 0.0, inclusive, and 1.0, inclusive.static long[]
equallySpacedLongs(long min, long max, int num)
Returns an array of (num + 1) longs that define, approximately, equally spaced intervals between the given max, inclusive, and min, 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.static double
getNaturalRank(double normalizedRank, long totalN, QuantileSearchCriteria searchCrit)
Computes the closest Natural Rank from a given Normalized Rank
-
-
-
Field Detail
-
tailRoundingFactor
public static final double tailRoundingFactor
used in search to improve rounding over a wide dynamic range- See Also:
- Constant Field Values
-
-
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
-
checkLongsSplitPointsOrder
public static void checkLongsSplitPointsOrder(long[] values)
Checks the sequential validity of the given array of double values. They must be unique and monotonically increasing.- 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
-
equallySpacedDoubles
public static double[] equallySpacedDoubles(int num)
Returns an array of (num + 1) values that define equally sized intervals between 0.0, inclusive, and 1.0, inclusive. The end points 0.0 and 1.0 are part of the returned array.For example, if num == 2, three values will be returned: 0.0, .5, and 1, where the two equally sized regions are {0.0,0.5}, and {0.5, 1.0}.
- Parameters:
num
- the total number of equally sized intervals between 0.0, inclusive and 1.0, inclusive. Must be 1 or greater.- Returns:
- a double array of values that define (num + 1) equally sized intervals between 0.0, inclusive and 1.0, inclusive.
- Throws:
IllegalArgumentException
- if num is less than 1.
-
equallySpacedLongs
public static long[] equallySpacedLongs(long min, long max, int num)
Returns an array of (num + 1) longs that define, approximately, equally spaced intervals between the given max, inclusive, and min, inclusive. The end points max and min are part of the returned array. Because the range of the values may not exactly divide into num intervals, the size of these intervals may vary by plus or minus one.- Parameters:
min
- the lowest positive valued (or zero) number of the rangemax
- the highest positive valued number of the range. max must be greater than minnum
- Number of requested intervals. Must be greater or equal to one, and less than or equal to max - min.- Returns:
- an array of (num + 1) longs that are approximately equally spaced between the given min and max.
-
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.
-
getNaturalRank
public static double getNaturalRank(double normalizedRank, long totalN, QuantileSearchCriteria searchCrit)
Computes the closest Natural Rank from a given Normalized Rank- Parameters:
normalizedRank
- the given normalized ranktotalN
- the total NsearchCrit
- the search criterion.- Returns:
- the closest Natural Rank from a given Normalized Rank
-
-