Package nl.colorize.util.stats
Class Aggregate
java.lang.Object
nl.colorize.util.stats.Aggregate
Utility class for aggregating numerical data sets. All operations assume
the data points have float precision. If the data set is empty, methods in
this class will return zero instead of throwing an exception.
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
average
(Collection<? extends Number> values) static float
correlation
(List<? extends Number> a, List<? extends Number> b) Calculates the Pearson correlation for the specified two data sets.static float
fraction
(float value, float total) static float
max
(Collection<? extends Number> values) static float
median
(Collection<? extends Number> values) static float
min
(Collection<? extends Number> values) static float
multiplyPercentage
(float percentageA, float percentageB) static float
percentage
(float value, float total) static float
percentile
(Collection<? extends Number> values, int n) Calculates the value of the Nth percentile for the specified data set.static float
sum
(Collection<? extends Number> values)
-
Method Details
-
sum
-
min
-
max
-
average
-
median
-
fraction
public static float fraction(float value, float total) -
percentage
public static float percentage(float value, float total) -
multiplyPercentage
public static float multiplyPercentage(float percentageA, float percentageB) -
percentile
Calculates the value of the Nth percentile for the specified data set. This method will interpolate between values if none of the values in the data set exactly matches the requested percentile.- Throws:
IllegalArgumentException
- ifn
is outside the range between 0 and 99 and therefore not a valid percentile.
-
correlation
Calculates the Pearson correlation for the specified two data sets. A correlation of 1.0 indicates perfect correlation, -1.0 indicates a perfect inverse correlation, 0.0 indicates no correlation.- Throws:
IllegalArgumentException
- if the two data sets are of different length, as Pearson correlation is based on pairs.
-