Class Aggregate

java.lang.Object
nl.colorize.util.stats.Aggregate

public final class Aggregate extends Object
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 Details

    • sum

      public static float sum(Collection<? extends Number> values)
    • min

      public static float min(Collection<? extends Number> values)
    • max

      public static float max(Collection<? extends Number> values)
    • average

      public static float average(Collection<? extends Number> values)
    • median

      public static float median(Collection<? extends Number> values)
    • 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

      public static float percentile(Collection<? extends Number> values, int n)
      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 - if n is outside the range between 0 and 99 and therefore not a valid percentile.
    • correlation

      public static float correlation(List<? extends Number> a, List<? extends Number> b)
      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.