Class MathUtil

java.lang.Object
  extended by MathUtil

public class MathUtil
extends java.lang.Object

class that round off floating point numbers to the specified number of decimal places givem


Field Summary
static long RAND_SEED
           
static java.util.Random random
           
 
Constructor Summary
MathUtil()
          Default constructor.
 
Method Summary
static boolean almostEqual(double val1, double val2)
          method sees if input doubles are "almost" equal
static boolean almostEqual(java.util.Vector vec1, double val2)
          method sees if input vectors are "almost" equal
static boolean almostEqual(java.util.Vector vec1, java.util.Vector vec2)
          method sees if input vectors are "almost" equal
static void betweenClass(DataPoints d, Matrix M, double rx_a, double ry_a)
          this method determines the between class scatter matrix for the class independent linear discrimination algorithm
static MyPoint computeClusterMean(java.util.Vector vec)
          methods computes and returns the mean of the given cluster
static MyPoint computeMyPointMean(java.util.Vector vec)
          methods computes and returns the mean of the given cluster
static MyPoint computePointMean(java.util.Vector vec)
          methods computes and returns the mean of the given cluster
static void copyVector(java.util.Vector<java.lang.Double> vec1_a, java.util.Vector<java.lang.Double> vec2_a, int length_a, int index1_a, int index2_a)
          Copies vector given specific parameters
static double distance(double x1, double y1, double x2, double y2)
          calculate the euclidean distance between the two points
static double doubleValue(java.util.Vector<java.lang.Double> vec_a, int index_a)
          gets the double value of the input vector at the index passed
static double grand(double mean, double stddev)
          method generates a random distribution centered about the mean with a variance that is specified by the standard deviation.
static void initDoubleVector(java.util.Vector<java.lang.Double> vec_a, double value_a)
          initializes components of vector to double value passed
static double linearKernel(java.util.Vector point1, java.util.Vector point2)
          this method evaluates the linear Kernel on the input vectors K(x,y) = (x .
static double polynomialKernel(java.util.Vector points1, java.util.Vector points2)
          this method evaluates the second degree polynomial Kernel on the input vectors K(x,y) = (x .
static double rbfKernel(java.util.Vector point1, java.util.Vector point2)
          this method evaluates the redial basis function Kernel on the input vectors with standard deviation sigma K(x,y) = exp(-gamma * ((a.a)-2*(a.b)+(b.b)))
static double rbfKernel(java.util.Vector point1, java.util.Vector point2, double gamma_a)
          this method evaluates the redial basis function Kernel on the input vectors with standard deviation sigma K(x,y) = exp(-gamma * ((a.a)-2*(a.b)+(b.b)))
static double setDecimal(double doubleNumber, int decimalPlaces)
          method takes in a decimal number and rounds to the given number of decimal places passed
static double SetDecimal(double doubleNumber, int decimalPlaces)
          method to round off floating point numbers to the specified number of decimal places given
static double vectorProduct(java.util.Vector vec1, java.util.Vector vec2)
          this method evaluates the vector dot product
static void withinClass(DataPoints data_a, double rx_a, double ry_a)
          Within Class
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

RAND_SEED

public static final long RAND_SEED
See Also:
Constant Field Values

random

public static final java.util.Random random
Constructor Detail

MathUtil

public MathUtil()
Default constructor. Empty body

Method Detail

grand

public static double grand(double mean,
                           double stddev)
method generates a random distribution centered about the mean with a variance that is specified by the standard deviation.

Parameters:
mean - mean of the distribution
stddev - standard deviation of the distribution
Returns:
random number centered about the mean

SetDecimal

public static double SetDecimal(double doubleNumber,
                                int decimalPlaces)
method to round off floating point numbers to the specified number of decimal places given

Parameters:
doubleNumber - input number
decimalPlaces - number of decimal places to round

distance

public static double distance(double x1,
                              double y1,
                              double x2,
                              double y2)
calculate the euclidean distance between the two points

Parameters:
x1 - x-coordinate of the first point
y1 - y-coordinate of the first point
x2 - x-coordinate of the second point
y2 - y-coordinate of the second point
Returns:
distance between the points

computeClusterMean

public static MyPoint computeClusterMean(java.util.Vector vec)
methods computes and returns the mean of the given cluster

Parameters:
vec - Vector of points from the cluster
Returns:
MyPoint value of the cluster mean

computePointMean

public static MyPoint computePointMean(java.util.Vector vec)
methods computes and returns the mean of the given cluster

Parameters:
vec - Vector of points from the cluster
Returns:
MyPoint value of the mean

computeMyPointMean

public static MyPoint computeMyPointMean(java.util.Vector vec)
methods computes and returns the mean of the given cluster

Parameters:
vec - point from the cluster
Returns:
MyPoint value of the mean

setDecimal

public static double setDecimal(double doubleNumber,
                                int decimalPlaces)
method takes in a decimal number and rounds to the given number of decimal places passed

Parameters:
doubleNumber - input number
decimalPlaces - number of significant decimal places
Returns:
double value of decimal with correct signifcant figures

linearKernel

public static double linearKernel(java.util.Vector point1,
                                  java.util.Vector point2)
this method evaluates the linear Kernel on the input vectors K(x,y) = (x . y)

Parameters:
point1 - First vector of points
point2 - Second vector of points
Returns:
double value of Kernel evaluation

rbfKernel

public static double rbfKernel(java.util.Vector point1,
                               java.util.Vector point2)
this method evaluates the redial basis function Kernel on the input vectors with standard deviation sigma K(x,y) = exp(-gamma * ((a.a)-2*(a.b)+(b.b)))

Parameters:
point1 - First vector of points
point2 - Second vector of points
Returns:
double value of Kernel evaluation

rbfKernel

public static double rbfKernel(java.util.Vector point1,
                               java.util.Vector point2,
                               double gamma_a)
this method evaluates the redial basis function Kernel on the input vectors with standard deviation sigma K(x,y) = exp(-gamma * ((a.a)-2*(a.b)+(b.b)))

Parameters:
point1 - First vector of points
point2 - Second vector of points
gamma_a - Double value of gamma
Returns:
double value of Kernel evaluation

polynomialKernel

public static double polynomialKernel(java.util.Vector points1,
                                      java.util.Vector points2)
this method evaluates the second degree polynomial Kernel on the input vectors K(x,y) = (x . y + 1)^p

Parameters:
points1 - First vector of points
points2 - Second vector of points
Returns:
Double value of Kernel evaluation

vectorProduct

public static double vectorProduct(java.util.Vector vec1,
                                   java.util.Vector vec2)
this method evaluates the vector dot product

Parameters:
vec1 - First vector of points
vec2 - Second vector of points
Returns:
dot product

almostEqual

public static boolean almostEqual(java.util.Vector vec1,
                                  java.util.Vector vec2)
method sees if input vectors are "almost" equal

Parameters:
vec1 - First vector of points
vec2 - Second vector of points
Returns:
True if all input vector components are "almost" equal

almostEqual

public static boolean almostEqual(java.util.Vector vec1,
                                  double val2)
method sees if input vectors are "almost" equal

Parameters:
vec1 - First vector of points
val2 - Value to compare to
Returns:
True if all input vector components are "almost" equal

almostEqual

public static boolean almostEqual(double val1,
                                  double val2)
method sees if input doubles are "almost" equal

Parameters:
val1 - First double value
val2 - Second double value
Returns:
True if doubles are "almost" equal

initDoubleVector

public static void initDoubleVector(java.util.Vector<java.lang.Double> vec_a,
                                    double value_a)
initializes components of vector to double value passed

Parameters:
vec_a - point from the cluster
value_a - value to set to vector

doubleValue

public static double doubleValue(java.util.Vector<java.lang.Double> vec_a,
                                 int index_a)
gets the double value of the input vector at the index passed

Parameters:
vec_a - point from the cluster
index_a -
Returns:
double value of vector at indexed value

copyVector

public static void copyVector(java.util.Vector<java.lang.Double> vec1_a,
                              java.util.Vector<java.lang.Double> vec2_a,
                              int length_a,
                              int index1_a,
                              int index2_a)
Copies vector given specific parameters

Parameters:
vec1_a - vector to be overwritten/copyied to
vec2_a - vector to be copied from
length_a - number of elements to be copyied
index1_a - index to start copying to first vector
index2_a - index to start copying from second vector

withinClass

public static void withinClass(DataPoints data_a,
                               double rx_a,
                               double ry_a)
Within Class

Parameters:
data_a - input data points
rx_a - double input of x
ry_a - double input of y

betweenClass

public static void betweenClass(DataPoints d,
                                Matrix M,
                                double rx_a,
                                double ry_a)
this method determines the between class scatter matrix for the class independent linear discrimination algorithm

Parameters:
d - input data points
M - between class scatter matrix
rx_a - double input of x
ry_a - double input of y