Class Stats

java.lang.Object
microsim.dev.statistics.Stats

public class Stats extends Object

Statistics over a collection of data.

Note that results are cached, for example calling

stats.sum();
stats.sum();
stats.mean();

calculates the sum of elements only once and reuses the results in subsequent calls and to compute the mean.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Stats(List<? extends Number> values)
    Build a Stats object for the given list of values.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    averageLast(int window)
    Average of the last window terms.
    int
    The number of values.
    org.apache.commons.math3.stat.descriptive.DescriptiveStatistics
    Create a DescriptiveStatistics object, use this if you need to access more statistical quantities (e.g. percentiles) than the one directly provided by Stats.
    double
    max()
    The maximum value.
    double
    The average of all values.
    double
    min()
    The minimum value.
    double
    sum()
    The sum of all values.
    static Supplier<Stats>
    supplier(Supplier<? extends List<? extends Number>> supplier)
    Convenience method to work with the Supplier API.
    double
    The variance of all values (this is the "biased" empirical variance).

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Stats

      public Stats(List<? extends Number> values)

      Build a Stats object for the given list of values.

      Each value is converted to a Double internally.

  • Method Details

    • supplier

      public static Supplier<Stats> supplier(Supplier<? extends List<? extends Number>> supplier)
      Convenience method to work with the Supplier API.
    • count

      public int count()
      The number of values.
    • min

      public double min()
      The minimum value.
    • max

      public double max()
      The maximum value.
    • sum

      public double sum()
      The sum of all values.
    • mean

      public double mean()
      The average of all values.
    • variance

      public double variance()
      The variance of all values (this is the "biased" empirical variance).
    • averageLast

      public double averageLast(int window)
      Average of the last window terms.
    • descrStats

      public org.apache.commons.math3.stat.descriptive.DescriptiveStatistics descrStats()
      Create a DescriptiveStatistics object, use this if you need to access more statistical quantities (e.g. percentiles) than the one directly provided by Stats.