suramadu.util.stats
Class StatPack

java.lang.Object
  extended bysuramadu.util.stats.StatPack

public class StatPack
extends java.lang.Object

Static helper class to compute various statistical values of collections and arrays.

Author:
mbi

Constructor Summary
StatPack()
           
 
Method Summary
static double[] diff(double[] doubleArray)
          Given an array of doubles of length n, returns an array of length n-1 whos elements consist of the difference between each consecutive element of the specified array.
static double[] diff(double[] doubleArray, int offset)
           
static float[] diff(float[] floatArray)
          Given an array of floats of length n, returns an array of length n-1 whos elements consist of the difference between each consecutive element of the specified array.
static float[] diff(float[] floatArray, int offset)
           
static int[] diff(int[] intArray)
          Given an array of ints of length n, returns an array of length n-1 whos elements consist of the difference between each consecutive element of the specified array.
static int[] diff(int[] intArray, int offset)
           
static long[] diff(long[] longArray)
          Given an array of longs of length n, returns an array of length n-1 whos elements consist of the difference between each consecutive element of the specified array.
static long[] diff(long[] longArray, int offset)
           
static double max(java.util.Collection c)
          Calculate the statistical maximum of Collection of Numbers.
static double max(double[] doubleArray)
          Calculate the statistical maximum of an array of doubles.
static double max(float[] floatArray)
          Calculate the statistical maximum of an array of floats.
static double max(int[] intArray)
          Calculate the statistical maximum of an array of ints.
static double max(long[] longArray)
          Calculate the statistical maximum of an array of longs.
static double mean(java.util.Collection c)
          Calculate the statistical mean of Collection of Numbers.
static double mean(double[] doubleArray)
          Calculate the statistical mean of an array of doubles.
static double mean(float[] floatArray)
          Calculate the statistical mean of an array of floats.
static double mean(int[] intArray)
          Calculate the statistical mean of an array of ints.
static double mean(long[] longArray)
          Calculate the statistical mean of an array of longs.
static double median(java.util.Collection c)
          Calculate the statistical median of Collection of Numbers.
static double median(double[] doubleArray)
          Calculate the statistical median of an array of doubles.
static double median(float[] floatArray)
          Calculate the statistical median of an array of floats.
static double median(int[] intArray)
          Calculate the statistical median of an array of ints.
static double median(long[] longArray)
          Calculate the statistical median of an array of longs.
static double min(java.util.Collection c)
          Calculate the statistical minimum of Collection of Numbers.
static double min(double[] doubleArray)
          Calculate the statistical minimum of an array of doubles.
static double min(float[] floatArray)
          Calculate the statistical minimum of an array of floats.
static double min(int[] intArray)
          Calculate the statistical minimum of an array of ints.
static double min(long[] longArray)
          Calculate the statistical minimum of an array of longs.
static Range mode(java.util.Collection c, java.lang.Number numBins)
          Calculate the statistical mode of a Collection of Numbers.
static Range mode(double[] doubleArray)
          Calculate the statistical mode of an array of doubles.
static Range mode(double[] doubleArray, double numBins)
          Calculate the statistical mode of an array of doubles.
static Range mode(float[] floatArray)
          Calculate the statistical mode of an array of floats.
static Range mode(float[] floatArray, float numBins)
          Calculate the statistical mode of an array of floats.
static Range mode(int[] intArray)
          Calculate the statistical mode of an array of ints.
static Range mode(int[] intArray, int numBins)
          Calculate the statistical mode of an array of ints.
static Range mode(long[] longArray)
          Calculate the statistical mode of an array of longs.
static Range mode(long[] longArray, long numBins)
          Calculate the statistical mode of an array of longs.
static double stddev(java.util.Collection c)
          Calculate the statistical standard deviation of Collection of Numbers.
static double stddev(double[] doubleArray)
          Calculate the statistical standard deviation of an array of doubles.
static double stddev(float[] floatArray)
          Calculate the statistical standard deviation of an array of floats.
static double stddev(int[] intArray)
          Calculate the statistical standard deviation of an array of ints.
static double stddev(long[] longArray)
          Calculate the statistical standard deviation of an array of longs.
static java.util.Collection toCollection(double[] doubleArray)
          Utility method for converting array of double to a Collection.
static java.util.Collection toCollection(float[] floatArray)
          Utility method for converting array of float to a Collection.
static java.util.Collection toCollection(int[] intArray)
          Utility method for converting array of int to a Collection.
static java.util.Collection toCollection(long[] longArray)
          Utility method for converting array of long to a Collection.
static double[] toDoubleArray(java.util.Collection c)
          Utility method for converting Collection Number objects to an array of doubles.
static float[] toFloatArray(java.util.Collection c)
          Utility method for converting Collection Number objects to an array of floats.
static int[] toIntArray(java.util.Collection c)
          Utility method for converting Collection Number objects to an array of ints.
static long[] toLongArray(java.util.Collection c)
          Utility method for converting Collection Number objects to an array of longs.
static double variance(java.util.Collection c)
          Calculate the statistical variance of Collection of Numbers.
static double variance(double[] doubleArray)
          Calculate the statistical variance of an array of doubles.
static double variance(float[] floatArray)
          Calculate the statistical variance of an array of floats.
static double variance(int[] intArray)
          Calculate the statistical variance of an array of ints.
static double variance(long[] longArray)
          Calculate the statistical variance of an array of longs.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StatPack

public StatPack()
Method Detail

diff

public static int[] diff(int[] intArray)
Given an array of ints of length n, returns an array of length n-1 whos elements consist of the difference between each consecutive element of the specified array.

Parameters:
intArray - array of ints to be differenced
Returns:
an array of ints one element short of the original array that consists of the differences between each consecutive element of the origianl array.
See Also:
Collection

diff

public static int[] diff(int[] intArray,
                         int offset)

diff

public static long[] diff(long[] longArray)
Given an array of longs of length n, returns an array of length n-1 whos elements consist of the difference between each consecutive element of the specified array.

Parameters:
longArray - array of longs to be differenced
Returns:
an array of longs one element short of the original array that consists of the differences between each consecutive element of the origianl array.
See Also:
Collection

diff

public static long[] diff(long[] longArray,
                          int offset)

diff

public static float[] diff(float[] floatArray)
Given an array of floats of length n, returns an array of length n-1 whos elements consist of the difference between each consecutive element of the specified array.

Parameters:
floatArray - array of floats to be differenced
Returns:
an array of floats one element short of the original array that consists of the differences between each consecutive element of the origianl array.
See Also:
Collection

diff

public static float[] diff(float[] floatArray,
                           int offset)

diff

public static double[] diff(double[] doubleArray)
Given an array of doubles of length n, returns an array of length n-1 whos elements consist of the difference between each consecutive element of the specified array.

Parameters:
doubleArray - array of doubles to be differenced
Returns:
an array of doubles one element short of the original array that consists of the differences between each consecutive element of the origianl array.
See Also:
Collection

diff

public static double[] diff(double[] doubleArray,
                            int offset)

toCollection

public static java.util.Collection toCollection(int[] intArray)
Utility method for converting array of int to a Collection.

Parameters:
intArray - an array of ints to be converted to a Collection
Returns:
a collection of Integer objects representing the origianl array of ints.
See Also:
Collection

toCollection

public static java.util.Collection toCollection(long[] longArray)
Utility method for converting array of long to a Collection.

Parameters:
longArray - an array of ints to be converted to a Collection
Returns:
a collection of Long objects representing the origianl array of longs.
See Also:
Collection

toCollection

public static java.util.Collection toCollection(float[] floatArray)
Utility method for converting array of float to a Collection.

Parameters:
floatArray - an array of floats to be converted to a Collection
Returns:
a collection of Float objects representing the origianl array of floats.
See Also:
Collection

toCollection

public static java.util.Collection toCollection(double[] doubleArray)
Utility method for converting array of double to a Collection.

Parameters:
doubleArray - an array of doubles to be converted to a Collection
Returns:
a collection of Doubles objects representing the origianl array of doubles.
See Also:
Collection

toIntArray

public static int[] toIntArray(java.util.Collection c)
Utility method for converting Collection Number objects to an array of ints.

Parameters:
c - a Collection of Number objects
Returns:
an array of ints representing the origianl Collection of Numbers.
See Also:
Collection

toLongArray

public static long[] toLongArray(java.util.Collection c)
Utility method for converting Collection Number objects to an array of longs.

Parameters:
c - a Collection of Number objects
Returns:
an array of longs representing the origianl Collection of Numbers.
See Also:
Collection

toFloatArray

public static float[] toFloatArray(java.util.Collection c)
Utility method for converting Collection Number objects to an array of floats.

Parameters:
c - a Collection of Number objects
Returns:
an array of floats representing the origianl Collection of Numbers.
See Also:
Collection

toDoubleArray

public static double[] toDoubleArray(java.util.Collection c)
Utility method for converting Collection Number objects to an array of doubles.

Parameters:
c - a Collection of Number objects
Returns:
an array of doubles representing the origianl Collection of Numbers.

mode

public static Range mode(int[] intArray)
Calculate the statistical mode of an array of ints. The mode is the range of numbers that occurs most frequently in a list. Bin size defaults to 1.

Parameters:
intArray - an array of ints to on which to calculate the statistical mode.
Returns:
a Range representing the statisticl mode of the specified array of ints.
See Also:
Range

mode

public static Range mode(int[] intArray,
                         int numBins)
Calculate the statistical mode of an array of ints. The mode is the range of numbers that occurs most frequently in a list.

Parameters:
intArray - an array of ints to on which to calculate the statistical mode.
numBins - the number of bins to create for the Histogram to calculate the mode.
Returns:
a Range representing the statisticl mode of the specified array of ints.
See Also:
Range

mode

public static Range mode(long[] longArray)
Calculate the statistical mode of an array of longs. The mode is the range of numbers that occurs most frequently in a list. Bin size defaults to 1.

Parameters:
longArray - an array of longs to on which to calculate the statistical mode.
Returns:
a Range representing the statisticl mode of the specified array of longs.
See Also:
Range

mode

public static Range mode(long[] longArray,
                         long numBins)
Calculate the statistical mode of an array of longs. The mode is the range of numbers that occurs most frequently in a list.

Parameters:
longArray - an array of longs to on which to calculate the statistical mode.
numBins - the number of bins to create for the Histogram to calculate the mode.
Returns:
a Range representing the statisticl mode of the specified array of longs.
See Also:
Range

mode

public static Range mode(float[] floatArray)
Calculate the statistical mode of an array of floats. The mode is the range of numbers that occurs most frequently in a list. Bin size defaults to 1.

Parameters:
floatArray - an array of floats to on which to calculate the statistical mode.
Returns:
a Range representing the statisticl mode of the specified array of floats.
See Also:
Range

mode

public static Range mode(float[] floatArray,
                         float numBins)
Calculate the statistical mode of an array of floats. The mode is the range of numbers that occurs most frequently in a list.

Parameters:
floatArray - an array of floats to on which to calculate the statistical mode.
numBins - the number of bins to create for the Histogram to calculate the mode.
Returns:
a Range representing the statisticl mode of the specified array of floats.
See Also:
Range

mode

public static Range mode(double[] doubleArray)
Calculate the statistical mode of an array of doubles. The mode is the range of numbers that occurs most frequently in a list. Bin size defaults to 1.

Parameters:
doubleArray - an array of doubles to on which to calculate the statistical mode.
Returns:
a Range representing the statisticl mode of the specified array of doubles.
See Also:
Range

mode

public static Range mode(double[] doubleArray,
                         double numBins)
Calculate the statistical mode of an array of doubles. The mode is the range of numbers that occurs most frequently in a list.

Parameters:
doubleArray - an array of doubles to on which to calculate the statistical mode.
numBins - the number of bins to create for the Histogram to calculate the mode.
Returns:
a Range representing the statisticl mode of the specified array of doubles.
See Also:
Range

mode

public static Range mode(java.util.Collection c,
                         java.lang.Number numBins)
Calculate the statistical mode of a Collection of Numbers. The mode is the range of numbers that occurs most frequently in a list.

Parameters:
c - a collection of Comparables on which to calculate the statistical mode.
numBins - the number of bins to create for the Histogram to calculate the mode.
Returns:
a Range representing the statisticl mode of the specified array of ints.
See Also:
Range, Collection, Comparable, Number

variance

public static double variance(int[] intArray)
Calculate the statistical variance of an array of ints.

Parameters:
intArray - an array of ints to on which to calculate the statistical mode.
Returns:
the value of the statistical variance.

variance

public static double variance(long[] longArray)
Calculate the statistical variance of an array of longs.

Parameters:
longArray - an array of longs to on which to calculate the statistical mode.
Returns:
the value of the statistical variance.

variance

public static double variance(float[] floatArray)
Calculate the statistical variance of an array of floats.

Parameters:
floatArray - an array of float to on which to calculate the statistical mode.
Returns:
the value of the statistical variance.

variance

public static double variance(double[] doubleArray)
Calculate the statistical variance of an array of doubles.

Parameters:
doubleArray - an array of doubles to on which to calculate the statistical mode.
Returns:
the value of the statistical variance.

variance

public static double variance(java.util.Collection c)
Calculate the statistical variance of Collection of Numbers.

Parameters:
c - a Collection of Number objects over which to calculate the statistical varience
Returns:
the value of the statistical variance.
See Also:
Collection, Number

stddev

public static double stddev(int[] intArray)
Calculate the statistical standard deviation of an array of ints.

Parameters:
intArray - an array of ints to on which to calculate the statistical mode.
Returns:
the value of the statistical standard deviation.

stddev

public static double stddev(long[] longArray)
Calculate the statistical standard deviation of an array of longs.

Parameters:
longArray - an array of longs to on which to calculate the statistical mode.
Returns:
the value of the statistical standard deviation.

stddev

public static double stddev(float[] floatArray)
Calculate the statistical standard deviation of an array of floats.

Parameters:
floatArray - an array of float to on which to calculate the statistical mode.
Returns:
the value of the statistical standard deviation.

stddev

public static double stddev(double[] doubleArray)
Calculate the statistical standard deviation of an array of doubles.

Parameters:
doubleArray - an array of doubles to on which to calculate the statistical mode.
Returns:
the value of the statistical standard deviation.

stddev

public static double stddev(java.util.Collection c)
Calculate the statistical standard deviation of Collection of Numbers.

Parameters:
c - a Collection of Number objects over which to calculate the statistical varience
Returns:
the value of the statistical standard deviation.
See Also:
Collection, Number

mean

public static double mean(int[] intArray)
Calculate the statistical mean of an array of ints.

Parameters:
intArray - an array of ints to on which to calculate the statistical mode.
Returns:
the value of the statistical mean.

mean

public static double mean(long[] longArray)
Calculate the statistical mean of an array of longs.

Parameters:
longArray - an array of longs to on which to calculate the statistical mode.
Returns:
the value of the statistical mean.

mean

public static double mean(float[] floatArray)
Calculate the statistical mean of an array of floats.

Parameters:
floatArray - an array of float to on which to calculate the statistical mode.
Returns:
the value of the statistical mean.

mean

public static double mean(double[] doubleArray)
Calculate the statistical mean of an array of doubles.

Parameters:
doubleArray - an array of doubles to on which to calculate the statistical mode.
Returns:
the value of the statistical mean.

mean

public static double mean(java.util.Collection c)
Calculate the statistical mean of Collection of Numbers.

Parameters:
c - a Collection of Number objects over which to calculate the statistical varience
Returns:
the value of the statistical mean.
See Also:
Collection, Number

median

public static double median(int[] intArray)
Calculate the statistical median of an array of ints.

Parameters:
intArray - an array of ints to on which to calculate the statistical mode.
Returns:
the value of the statistical median.

median

public static double median(long[] longArray)
Calculate the statistical median of an array of longs.

Parameters:
longArray - an array of longs to on which to calculate the statistical mode.
Returns:
the value of the statistical median.

median

public static double median(float[] floatArray)
Calculate the statistical median of an array of floats.

Parameters:
floatArray - an array of float to on which to calculate the statistical mode.
Returns:
the value of the statistical median.

median

public static double median(double[] doubleArray)
Calculate the statistical median of an array of doubles.

Parameters:
doubleArray - an array of doubles to on which to calculate the statistical mode.
Returns:
the value of the statistical median.

median

public static double median(java.util.Collection c)
Calculate the statistical median of Collection of Numbers.

Parameters:
c - a Collection of Number objects over which to calculate the statistical varience
Returns:
the value of the statistical median.
See Also:
Collection, Number

min

public static double min(int[] intArray)
Calculate the statistical minimum of an array of ints.

Parameters:
intArray - an array of ints to on which to calculate the statistical mode.
Returns:
the value of the statistical minimum.

min

public static double min(long[] longArray)
Calculate the statistical minimum of an array of longs.

Parameters:
longArray - an array of longs to on which to calculate the statistical mode.
Returns:
the value of the statistical minimum.

min

public static double min(float[] floatArray)
Calculate the statistical minimum of an array of floats.

Parameters:
floatArray - an array of float to on which to calculate the statistical mode.
Returns:
the value of the statistical minimum.

min

public static double min(double[] doubleArray)
Calculate the statistical minimum of an array of doubles.

Parameters:
doubleArray - an array of doubles to on which to calculate the statistical mode.
Returns:
the value of the statistical minimum.

min

public static double min(java.util.Collection c)
Calculate the statistical minimum of Collection of Numbers.

Parameters:
c - a Collection of Number objects over which to calculate the statistical varience
Returns:
the value of the statistical minimum.
See Also:
Collection, Number

max

public static double max(int[] intArray)
Calculate the statistical maximum of an array of ints.

Parameters:
intArray - an array of ints to on which to calculate the statistical mode.
Returns:
the value of the statistical maximum.

max

public static double max(long[] longArray)
Calculate the statistical maximum of an array of longs.

Parameters:
longArray - an array of longs to on which to calculate the statistical mode.
Returns:
the value of the statistical maximum.

max

public static double max(float[] floatArray)
Calculate the statistical maximum of an array of floats.

Parameters:
floatArray - an array of float to on which to calculate the statistical mode.
Returns:
the value of the statistical maximum.

max

public static double max(double[] doubleArray)
Calculate the statistical maximum of an array of doubles.

Parameters:
doubleArray - an array of doubles to on which to calculate the statistical mode.
Returns:
the value of the statistical maximum.

max

public static double max(java.util.Collection c)
Calculate the statistical maximum of Collection of Numbers.

Parameters:
c - a Collection of Number objects over which to calculate the statistical varience
Returns:
the value of the statistical maximum.
See Also:
Collection, Number