Class Stats

java.lang.Object
ch.idsia.utils.statistics.Stats

public class Stats
extends java.lang.Object
This class implements some simple statistical functions on arrays of numbers, namely, the mean, variance, standard deviation, covariance, min and max.
  • Constructor Summary

    Constructors 
    Constructor Description
    Stats()  
  • Method Summary

    Modifier and Type Method Description
    static void analyse​(double[] v)
    Prints the means and standard deviation of the data to the standard output.
    static void analyse​(double[] v, java.io.PrintStream s)
    Prints the means and standard deviation of the data to the specified PrintStream
    static java.lang.String analysisString​(double[] v)  
    static double correlation​(double[] v1, double[] v2)  
    static double correlation2​(double[] v1, double[] v2)  
    static double covar​(double[] v1, double[] v2)
    Returns the covariance of the paired arrays of double.
    static void main​(java.lang.String[] args)
    Runs through some utils using the functions defined in this class.
    static double max​(double[] v)
    Returns the maximum value in the array.
    static double mean​(double[] v)
    Returns the average of an array of double.
    static double mean​(int[] v)  
    static double min​(double[] v)
    Returns the minimum value in the array.
    static java.lang.String rmsString​(double[] v)
    Returns a string that compares the root mean square of the data with the standard deviation of the data.
    static double sdev​(double[] v)
    Returns the sample standard deviation of an array of double.
    static double sqr​(double x)
    Calculates the square of a double.
    static double stderr​(double[] v)
    Returns the standard error of an array of double, where this is defined as the standard deviation of the sample divided by the square root of the sample size.
    static double[] v2a​(java.util.Vector<java.lang.Number> v)
    Converts a vector of Numbers into an array of double.
    static double variance​(double[] v)
    Returns the variance of the array of double.
    static double variance2​(double[] v)
    this alternative version was used to check correctness

    Methods inherited from class java.lang.Object

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

  • Method Details

    • v2a

      public static double[] v2a​(java.util.Vector<java.lang.Number> v)
      Converts a vector of Numbers into an array of double. This function does not necessarily belong here, but is commonly required in order to apply the statistical functions conveniently, since they only deal with arrays of double. (Note that a Number of the common superclass of all the Object versions of the primitives, such as Integer, Double etc.).
    • sqr

      public static double sqr​(double x)
      Calculates the square of a double.
      Returns:
      Returns x*x
    • mean

      public static double mean​(double[] v)
      Returns the average of an array of double.
    • mean

      public static double mean​(int[] v)
      Parameters:
      v - - sample
      Returns:
      the average of an array of int.
    • sdev

      public static double sdev​(double[] v)
      Returns the sample standard deviation of an array of double.
    • stderr

      public static double stderr​(double[] v)
      Returns the standard error of an array of double, where this is defined as the standard deviation of the sample divided by the square root of the sample size.
    • variance

      public static double variance​(double[] v)
      Returns the variance of the array of double.
    • variance2

      public static double variance2​(double[] v)
      this alternative version was used to check correctness
    • covar

      public static double covar​(double[] v1, double[] v2)
      Returns the covariance of the paired arrays of double.
    • correlation

      public static double correlation​(double[] v1, double[] v2)
    • correlation2

      public static double correlation2​(double[] v1, double[] v2)
    • max

      public static double max​(double[] v)
      Returns the maximum value in the array.
    • min

      public static double min​(double[] v)
      Returns the minimum value in the array.
    • analyse

      public static void analyse​(double[] v)
      Prints the means and standard deviation of the data to the standard output.
    • analyse

      public static void analyse​(double[] v, java.io.PrintStream s)
      Prints the means and standard deviation of the data to the specified PrintStream
      Parameters:
      v - contains the data
      s - is the corresponding PrintStream
    • analysisString

      public static java.lang.String analysisString​(double[] v)
      Parameters:
      v - contains the data
      Returns:
      A String summary of the with the mean and standard deviation of the data.
    • rmsString

      public static java.lang.String rmsString​(double[] v)
      Returns a string that compares the root mean square of the data with the standard deviation of the data. This is probably too specialised to be of much general use.
      Parameters:
      v - contains the data
      Returns:
      root mean square = <...> standard deviation = <...>
    • main

      public static void main​(java.lang.String[] args) throws java.io.IOException
      Runs through some utils using the functions defined in this class.
      Throws:
      java.io.IOException