Class QuantityBucketSelectors
- java.lang.Object
-
- com.pervasivecode.utils.stats.histogram.measure.QuantityBucketSelectors
-
public class QuantityBucketSelectors extends Object
BucketSelector factory methods for basic bucketing strategies, working with values that are instances ofQuantity<T>.- See Also:
BucketingSystem,BucketSelectors
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T extends Quantity<T>>
BucketSelector<Quantity<T>>exponential(double base, Unit<T> baseUnit, QuantityFactory<T> quantityFactory, double minPower, int numBuckets)Get a BucketSelector that has upper bound values that areQuantity<T>instances whose numeric component is part of an exponential series.static <T extends Quantity<T>>
BucketSelector<Quantity<T>>linear(Unit<T> baseUnit, QuantityFactory<T> quantityFactory, Quantity<T> lowestUpperBound, Quantity<T> highestUpperBound, int numBuckets)Get a BucketSelector that has upper bound values that are evenly distributed between a smallest and largest value.static <T extends Quantity<T>>
BucketSelector<Quantity<T>>powerOf2(int minPower, Unit<T> baseUnit, QuantityFactory<T> quantityFactory, int numBuckets)Get a BucketSelector that has upper bound values that areQuantity<T>instances whose numeric component is part of an exponential series made up of consecutive whole-number powers of 2.
-
-
-
Method Detail
-
powerOf2
public static <T extends Quantity<T>> BucketSelector<Quantity<T>> powerOf2(int minPower, Unit<T> baseUnit, QuantityFactory<T> quantityFactory, int numBuckets)
Get a BucketSelector that has upper bound values that areQuantity<T>instances whose numeric component is part of an exponential series made up of consecutive whole-number powers of 2.Example: arguments
minPower=2,baseUnit=Sievert,numBuckets=5would generate upper bound values of 4 Sv, 8 Sv, 16 Sv, and 32 Sv.- Type Parameters:
T- The kind of quantity that the BucketSelector will bucket. Example:Temperature.- Parameters:
minPower- The smallest power of 2 to use when generating upper bound values.baseUnit- The base "ones" unit of measurement type T in the desired system of units. Example: kilogram, meter, square foot.quantityFactory- An object that can instantiate objects of typeQuantity<T>.numBuckets- The number of buckets.- Returns:
- A
BucketSelector<Long>instance.
-
exponential
public static <T extends Quantity<T>> BucketSelector<Quantity<T>> exponential(double base, Unit<T> baseUnit, QuantityFactory<T> quantityFactory, double minPower, int numBuckets)
Get a BucketSelector that has upper bound values that areQuantity<T>instances whose numeric component is part of an exponential series. Each bucket value's exponent is 1.0 plus the exponent of the previous bucket value.Example: arguments
base=5.0,baseUnit=Acre,minPower=0.0, andnumBuckets=5would generate base and exponent values of 50 acres, 51 acres, 52 acres, and 53 acres, so the upper bound values would be 1 acre, 5 acres, 25 acres, and 125 acres.- Type Parameters:
T- The kind of quantity that the BucketSelector will bucket. Example:Temperature.- Parameters:
base- The base that will be raised to the specified exponents to generate upper bound values.baseUnit- The base "ones" unit of measurement type T in the desired system of units. Example: kilogram, meter, square foot.quantityFactory- An object that can instantiate objects of typeQuantity<T>.minPower- The smallest exponent to use when generating upper bound values.numBuckets- The number of buckets into which values should be counted.- Returns:
- A
BucketSelector<Quantity<T>>instance.
-
linear
public static <T extends Quantity<T>> BucketSelector<Quantity<T>> linear(Unit<T> baseUnit, QuantityFactory<T> quantityFactory, Quantity<T> lowestUpperBound, Quantity<T> highestUpperBound, int numBuckets)
Get a BucketSelector that has upper bound values that are evenly distributed between a smallest and largest value.arguments
baseUnit=kilogram,lowestUpperBound=0,highestUpperBound=20, andnumBuckets=6would generate upper bound values 0, 5, 10, 15, and 20. Example: 0 kg, 5 kg, 10 kg, 15 kg, 20 kg.- Type Parameters:
T- The kind of quantity that the BucketSelector will bucket. Example:Temperature.- Parameters:
baseUnit- The base "ones" unit of measurement type T in the desired system of units. Example: kilogram, meter, square foot.quantityFactory- An object that can instantiate objects of typeQuantity<T>.lowestUpperBound- The upper-bound value for the first bucket (index 0).highestUpperBound- The upper-bound value for the next-to-last bucket (index (numBuckets - 2)).numBuckets- The total number of buckets.- Returns:
- A
BucketSelector<Long>instance.
-
-