public class MathUtil
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static long |
RAND_SEED |
static java.util.Random |
random |
Constructor and Description |
---|
MathUtil()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
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
|
public static final long RAND_SEED
public static final java.util.Random random
public static double grand(double mean, double stddev)
mean
- mean of the distributionstddev
- standard deviation of the distributionpublic static double SetDecimal(double doubleNumber, int decimalPlaces)
doubleNumber
- input numberdecimalPlaces
- number of decimal places to roundpublic static double distance(double x1, double y1, double x2, double y2)
x1
- x-coordinate of the first pointy1
- y-coordinate of the first pointx2
- x-coordinate of the second pointy2
- y-coordinate of the second pointpublic static MyPoint computeClusterMean(java.util.Vector vec)
vec
- Vector of points from the clusterpublic static MyPoint computePointMean(java.util.Vector vec)
vec
- Vector of points from the clusterpublic static MyPoint computeMyPointMean(java.util.Vector vec)
vec
- point from the clusterpublic static double setDecimal(double doubleNumber, int decimalPlaces)
doubleNumber
- input numberdecimalPlaces
- number of significant decimal placespublic static double linearKernel(java.util.Vector point1, java.util.Vector point2)
point1
- First vector of pointspoint2
- Second vector of pointspublic static double rbfKernel(java.util.Vector point1, java.util.Vector point2)
point1
- First vector of pointspoint2
- Second vector of pointspublic static double rbfKernel(java.util.Vector point1, java.util.Vector point2, double gamma_a)
point1
- First vector of pointspoint2
- Second vector of pointsgamma_a
- Double value of gammapublic static double polynomialKernel(java.util.Vector points1, java.util.Vector points2)
points1
- First vector of pointspoints2
- Second vector of pointspublic static double vectorProduct(java.util.Vector vec1, java.util.Vector vec2)
vec1
- First vector of pointsvec2
- Second vector of pointspublic static boolean almostEqual(java.util.Vector vec1, java.util.Vector vec2)
vec1
- First vector of pointsvec2
- Second vector of pointspublic static boolean almostEqual(java.util.Vector vec1, double val2)
vec1
- First vector of pointsval2
- Value to compare topublic static boolean almostEqual(double val1, double val2)
val1
- First double valueval2
- Second double valuepublic static void initDoubleVector(java.util.Vector<java.lang.Double> vec_a, double value_a)
vec_a
- point from the clustervalue_a
- value to set to vectorpublic static double doubleValue(java.util.Vector<java.lang.Double> vec_a, int index_a)
vec_a
- point from the clusterindex_a
- 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)
vec1_a
- vector to be overwritten/copyied tovec2_a
- vector to be copied fromlength_a
- number of elements to be copyiedindex1_a
- index to start copying to first vectorindex2_a
- index to start copying from second vectorpublic static void withinClass(DataPoints data_a, double rx_a, double ry_a)
data_a
- input data pointsrx_a
- double input of xry_a
- double input of ypublic static void betweenClass(DataPoints d, Matrix M, double rx_a, double ry_a)
d
- input data pointsM
- between class scatter matrixrx_a
- double input of xry_a
- double input of y