com.ge.research.utils
Class MathUtils

java.lang.Object
  extended bycom.ge.research.utils.MathUtils

public class MathUtils
extends java.lang.Object

A utility class with common, useful arithmetic methods for dealing with arrays of primitive numbers and Calendar objects.

Version:
$Revision: 1.1 $ $Date: 2006/08/11 00:17:39 $
Author:
garbiras
Created on:
Aug 20, 2002

Constructor Summary
MathUtils()
           
 
Method Summary
static java.util.Calendar getMax(java.util.Calendar[] values)
          Returns the max of the values of the Calendar array.
static double getMax(double[] values)
          Returns the max of the values of the double array.
static float getMax(float[] values)
          Returns the max of the values of the float array.
static int getMax(int[] values)
          Returns the max of the values of the int array.
static long getMax(long[] values)
          Returns the max of the values of the long array.
static short getMax(short[] values)
          Returns the max of the values of the short array.
static float getMean(double[] values)
          Returns the mean of the values of the double array.
static float getMean(float[] values)
          Returns the mean of the values of the float array.
static float getMean(int[] values)
          Returns the mean of the values of the int array.
static float getMean(long[] values)
          Returns the mean of the values of the long array.
static float getMean(short[] values)
          Returns the mean of the values of the short array.
static java.util.Calendar getMedian(java.util.Calendar[] values)
          Unimplemented method
static double getMedian(double[] values)
          Unimplemented method
static float getMedian(float[] values)
          Unimplemented method
static double getMedian(int[] values)
          Unimplemented method
static double getMedian(long[] values)
          Unimplemented method
static double getMedian(short[] values)
          Unimplemented method
static java.util.Calendar getMin(java.util.Calendar[] values)
          Returns the min of the values of the Calendar array.
static double getMin(double[] values)
          Returns the min of the values of the double array.
static float getMin(float[] values)
          Returns the min of the values of the float array.
static int getMin(int[] values)
          Returns the min of the values of the int array.
static long getMin(long[] values)
          Returns the min of the values of the long array.
static short getMin(short[] values)
          Returns the min of the values of the short array.
static java.util.Calendar[] getMode(java.util.Calendar[] values)
          Returns the Calendar array of the mode values for the Calendar array.
static double[] getMode(double[] values)
          Returns the double array of the mode values for the double array.
static float[] getMode(float[] values)
          Returns the float array of the mode values for the float array.
static int[] getMode(int[] values)
          Returns the int array of the mode values for the int array.
static long[] getMode(long[] values)
          Returns the long array of the mode values for the long array.
static short[] getMode(short[] values)
          Returns the short array of the mode values for the short array.
static float getSum(double[] values)
          Returns the sum of the values of the double array.
static float getSum(float[] values)
          Returns the sum of the values of the float array.
static long getSum(int[] values)
          Returns the sum of the values of the int array.
static long getSum(long[] values)
          Returns the sum of the values of the long array.
static long getSum(short[] values)
          Returns the sum of the values of the short array.
static java.util.Calendar getVariance(java.util.Calendar[] values)
          Unimplemented method
static float getVariance(double[] values)
          Unimplemented method
static float getVariance(float[] values)
          Unimplemented method
static float getVariance(int[] values)
          Unimplemented method
static float getVariance(long[] values)
          Unimplemented method
static float getVariance(short[] values)
          Unimplemented method
static boolean hasMode(java.util.Calendar[] values)
          Tests the Calendar array for a mode value.
static boolean hasMode(double[] values)
          Tests the double array for a mode value.
static boolean hasMode(float[] values)
          Tests the float array for a mode value.
static boolean hasMode(int[] values)
          Tests the int array for a mode value.
static boolean hasMode(long[] values)
          Tests the long array for a mode value.
static boolean hasMode(short[] values)
          Tests the short array for a mode value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MathUtils

public MathUtils()
Method Detail

getSum

public static long getSum(int[] values)
                   throws java.lang.ArithmeticException
Returns the sum of the values of the int array.

Parameters:
values - the array of values to sum
Returns:
The sum of the values of the array
Throws:
java.lang.ArithmeticException - If the running sum exceeds the maximum value for a primitive long

getSum

public static long getSum(short[] values)
                   throws java.lang.ArithmeticException
Returns the sum of the values of the short array.

Parameters:
values - the array of values to sum
Returns:
The sum of the values of the array
Throws:
java.lang.ArithmeticException - If the running sum exceeds the maximum value for a primitive long

getSum

public static long getSum(long[] values)
                   throws java.lang.ArithmeticException
Returns the sum of the values of the long array.

Parameters:
values - the array of values to sum
Returns:
The sum of the values of the array
Throws:
java.lang.ArithmeticException - If the running sum exceeds the maximum value for a primitive long

getSum

public static float getSum(double[] values)
                    throws java.lang.ArithmeticException
Returns the sum of the values of the double array.

Parameters:
values - the array of values to sum
Returns:
The sum of the values of the array
Throws:
java.lang.ArithmeticException - If the running sum exceeds the maximum value for a primitive long

getSum

public static float getSum(float[] values)
                    throws java.lang.ArithmeticException
Returns the sum of the values of the float array.

Parameters:
values - the array of values to sum
Returns:
The sum of the values of the array
Throws:
java.lang.ArithmeticException - If the running sum exceeds the maximum value for a primitive long

getMean

public static float getMean(int[] values)
                     throws java.lang.ArithmeticException
Returns the mean of the values of the int array.

Parameters:
values - the array of values to calcualte the mean for
Returns:
The mean of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero, or an exception is returned computing the sum of the array
See Also:
getSum(int[])

getMean

public static float getMean(short[] values)
                     throws java.lang.ArithmeticException
Returns the mean of the values of the short array.

Parameters:
values - the array of values to calcualte the mean for
Returns:
The mean of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero, or an exception is returned computing the sum of the array
See Also:
getSum(short[])

getMean

public static float getMean(long[] values)
                     throws java.lang.ArithmeticException
Returns the mean of the values of the long array.

Parameters:
values - the array of values to calcualte the mean for
Returns:
The mean of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero, or an exception is returned computing the sum of the array
See Also:
getSum(long[])

getMean

public static float getMean(double[] values)
                     throws java.lang.ArithmeticException
Returns the mean of the values of the double array.

Parameters:
values - the array of values to calcualte the mean for
Returns:
The mean of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero, or an exception is returned computing the sum of the array
See Also:
getSum(double[])

getMean

public static float getMean(float[] values)
                     throws java.lang.ArithmeticException
Returns the mean of the values of the float array.

Parameters:
values - the array of values to calcualte the mean for
Returns:
The mean of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero, or an exception is returned computing the sum of the array
See Also:
getSum(float[])

getMin

public static int getMin(int[] values)
                  throws java.lang.ArithmeticException
Returns the min of the values of the int array.

Parameters:
values - the array of values to calcualte the min for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMin

public static short getMin(short[] values)
                    throws java.lang.ArithmeticException
Returns the min of the values of the short array.

Parameters:
values - the array of values to calcualte the min for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMin

public static long getMin(long[] values)
                   throws java.lang.ArithmeticException
Returns the min of the values of the long array.

Parameters:
values - the array of values to calcualte the min for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMin

public static double getMin(double[] values)
                     throws java.lang.ArithmeticException
Returns the min of the values of the double array.

Parameters:
values - the array of values to calcualte the min for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMin

public static float getMin(float[] values)
                    throws java.lang.ArithmeticException
Returns the min of the values of the float array.

Parameters:
values - the array of values to calcualte the min for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMin

public static java.util.Calendar getMin(java.util.Calendar[] values)
                                 throws java.lang.ArithmeticException
Returns the min of the values of the Calendar array.

Parameters:
values - the array of values to calcualte the min for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMax

public static int getMax(int[] values)
                  throws java.lang.ArithmeticException
Returns the max of the values of the int array.

Parameters:
values - the array of values to calcualte the max for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMax

public static short getMax(short[] values)
                    throws java.lang.ArithmeticException
Returns the max of the values of the short array.

Parameters:
values - the array of values to calcualte the max for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMax

public static long getMax(long[] values)
                   throws java.lang.ArithmeticException
Returns the max of the values of the long array.

Parameters:
values - the array of values to calcualte the max for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMax

public static double getMax(double[] values)
                     throws java.lang.ArithmeticException
Returns the max of the values of the double array.

Parameters:
values - the array of values to calcualte the max for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMax

public static float getMax(float[] values)
                    throws java.lang.ArithmeticException
Returns the max of the values of the float array.

Parameters:
values - the array of values to calcualte the max for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

getMax

public static java.util.Calendar getMax(java.util.Calendar[] values)
                                 throws java.lang.ArithmeticException
Returns the max of the values of the Calendar array.

Parameters:
values - the array of values to calcualte the max for
Returns:
The min of the values of the array
Throws:
java.lang.ArithmeticException - If the array is of length zero

hasMode

public static boolean hasMode(int[] values)
Tests the int array for a mode value.

Parameters:
values - the array of values to inspect for a mode
Returns:
true if a mode exists for the array; false if a mode does not exist for the array

hasMode

public static boolean hasMode(short[] values)
Tests the short array for a mode value.

Parameters:
values - the array of values to inspect for a mode
Returns:
true if a mode exists for the array; false if a mode does not exist for the array

hasMode

public static boolean hasMode(long[] values)
Tests the long array for a mode value.

Parameters:
values - the array of values to inspect for a mode
Returns:
true if a mode exists for the array; false if a mode does not exist for the array

hasMode

public static boolean hasMode(double[] values)
Tests the double array for a mode value.

Parameters:
values - the array of values to inspect for a mode
Returns:
true if a mode exists for the array; false if a mode does not exist for the array

hasMode

public static boolean hasMode(float[] values)
Tests the float array for a mode value.

Parameters:
values - the array of values to inspect for a mode
Returns:
true if a mode exists for the array; false if a mode does not exist for the array

hasMode

public static boolean hasMode(java.util.Calendar[] values)
Tests the Calendar array for a mode value.

Parameters:
values - the array of values to inspect for a mode
Returns:
true if a mode exists for the array; false if a mode does not exist for the array

getMode

public static int[] getMode(int[] values)
                     throws java.lang.ArithmeticException,
                            java.lang.Exception
Returns the int array of the mode values for the int array.

Parameters:
values - the array of values to inspect for a mode
Returns:
The array of mode values for the array
Throws:
java.lang.ArithmeticException - If the array does not have a mode
java.lang.Exception - If an internal invalid state is reached while producing the mode array

getMode

public static short[] getMode(short[] values)
                       throws java.lang.ArithmeticException,
                              java.lang.Exception
Returns the short array of the mode values for the short array.

Parameters:
values - the array of values to inspect for a mode
Returns:
The array of mode values for the array
Throws:
java.lang.ArithmeticException - If the array does not have a mode
java.lang.Exception - If an internal invalid state is reached while producing the mode array

getMode

public static long[] getMode(long[] values)
                      throws java.lang.ArithmeticException,
                             java.lang.Exception
Returns the long array of the mode values for the long array.

Parameters:
values - the array of values to inspect for a mode
Returns:
The array of mode values for the array
Throws:
java.lang.ArithmeticException - If the array does not have a mode
java.lang.Exception - If an internal invalid state is reached while producing the mode array

getMode

public static double[] getMode(double[] values)
                        throws java.lang.ArithmeticException,
                               java.lang.Exception
Returns the double array of the mode values for the double array.

Parameters:
values - the array of values to inspect for a mode
Returns:
The array of mode values for the array
Throws:
java.lang.ArithmeticException - If the array does not have a mode
java.lang.Exception - If an internal invalid state is reached while producing the mode array

getMode

public static float[] getMode(float[] values)
                       throws java.lang.ArithmeticException,
                              java.lang.Exception
Returns the float array of the mode values for the float array.

Parameters:
values - the array of values to inspect for a mode
Returns:
The array of mode values for the array
Throws:
java.lang.ArithmeticException - If the array does not have a mode
java.lang.Exception - If an internal invalid state is reached while producing the mode array

getMode

public static java.util.Calendar[] getMode(java.util.Calendar[] values)
                                    throws java.lang.ArithmeticException,
                                           java.lang.Exception
Returns the Calendar array of the mode values for the Calendar array.

Parameters:
values - the array of values to inspect for a mode
Returns:
The array of mode values for the array
Throws:
java.lang.ArithmeticException - If the array does not have a mode
java.lang.Exception - If an internal invalid state is reached while producing the mode array

getMedian

public static double getMedian(int[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the median for
Returns:
0
UNIMPLEMENTED
Will compute the median value of the array, when finally implemented.

getMedian

public static double getMedian(short[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the median for
Returns:
0
UNIMPLEMENTED
Will compute the median value of the array, when finally implemented.

getMedian

public static double getMedian(long[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the median for
Returns:
0
UNIMPLEMENTED
Will compute the median value of the array, when finally implemented.

getMedian

public static double getMedian(double[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the median for
Returns:
0
UNIMPLEMENTED
Will compute the median value of the array, when finally implemented.

getMedian

public static float getMedian(float[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the median for
Returns:
0
UNIMPLEMENTED
Will compute the median value of the array, when finally implemented.

getMedian

public static java.util.Calendar getMedian(java.util.Calendar[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the median for
Returns:
null
UNIMPLEMENTED
Will compute the median value of the array, when finally implemented.

getVariance

public static float getVariance(int[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the variance for
Returns:
0
UNIMPLEMENTED
Will compute the variance of the array, when finally implemented.

getVariance

public static float getVariance(short[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the variance for
Returns:
0
UNIMPLEMENTED
Will compute the variance of the array, when finally implemented.

getVariance

public static float getVariance(long[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the variance for
Returns:
0
UNIMPLEMENTED
Will compute the variance of the array, when finally implemented.

getVariance

public static float getVariance(double[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the variance for
Returns:
0
UNIMPLEMENTED
Will compute the variance of the array, when finally implemented.

getVariance

public static float getVariance(float[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the variance for
Returns:
0
UNIMPLEMENTED
Will compute the variance of the array, when finally implemented.

getVariance

public static java.util.Calendar getVariance(java.util.Calendar[] values)
Unimplemented method

Parameters:
values - the array of values to calculate the variance for
Returns:
null
UNIMPLEMENTED
Will compute the variance of the array, when finally implemented.