Class Statistics


  • @Immutable
    public final class Statistics
    extends java.lang.Object
    Statistics analysis. Contains:
    • Number of samples
    • Sum
    • Mean value
    • Standard deviation
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Statistics NIL
      "null" statistics with every value set to zero.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double getMean()
      Gets the arithmetic mean of the samples.
      int getNumSamples()
      Gets the number of samples.
      double getStandardDeviation()
      Gets the standard deviation in the samples.
      double getSum()
      Gets the sum of all the samples.
      double hotness​(double value)
      Calculates the 'hotness' of the given value based on these statistics.
      static Statistics of​(double... samples)
      Calculates the statistics of the given samples.
      static Statistics of​(java.util.Collection<? extends java.lang.Number> samples)
      Calculates the statistics of the given samples.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • NIL

        public static final Statistics NIL
        "null" statistics with every value set to zero.
    • Method Detail

      • of

        public static Statistics of​(double... samples)
        Calculates the statistics of the given samples.
        Parameters:
        samples - the samples to analyze
        Returns:
        a statistical analysis of the given samples
      • of

        public static Statistics of​(java.util.Collection<? extends java.lang.Number> samples)
        Calculates the statistics of the given samples.
        Parameters:
        samples - the samples to analyze
        Returns:
        a statistical analysis of the given samples
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getNumSamples

        public int getNumSamples()
        Gets the number of samples.
      • getSum

        public double getSum()
        Gets the sum of all the samples.
      • getMean

        public double getMean()
        Gets the arithmetic mean of the samples.
      • getStandardDeviation

        public double getStandardDeviation()
        Gets the standard deviation in the samples.
      • hotness

        public double hotness​(double value)
        Calculates the 'hotness' of the given value based on these statistics. Using a value that is not in the data set used to create these statistics will most likely have a useless result. Hotness is equal to the number of standard deviations above the mean, or zero if the input value is not above the mean. Effectively, this means hotness(x) == max(0, ((x - mean) / standard deviation)).

        If this set of statistics was calculated from less than two data points, 'hotness' doesn't mean anything and this method will always return zero.

        Parameters:
        value - the value to calculate the hotness of
        Returns:
        the hotness of the given value.