Class MathUtil
- java.lang.Object
-
- ai.libs.jaicore.ml.classification.singlelabel.timeseries.util.MathUtil
-
public class MathUtil extends java.lang.ObjectUtility class consisting of mathematical utility functions.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static intargmax(int[] array)Calculates the index of the maximum value in the givenarray(argmax).static doubleintManhattanDistance(int[] a, int[] b)Simple Manhattan distance (sum of the absolute differences between the vectors' elements) implementation for arrays of Integer.static doublemean(double[] vector, int t1, int t2)Function calculating the mean of the interval [t1, t2 (inclusive)] of the givenvector.static doublesigmoid(double z)Function to calculate the sigmoid for the given valuez.static doublesingleSquaredEuclideanDistance(double[] vector1, double[] vector2)Computes the single squared Euclidean distance between two vectors.static doubleslope(double[] vector, int t1, int t2)Function calculating the slope of the interval [t1, t2 (inclusive)] of the givenvector.static doublestddev(double[] vector, int t1, int t2, boolean useBiasCorrection)Function calculating the standard deviation of the interval [t1, t2 (inclusive)] of the givenvector.static doublesum(double[] array)Sums the values of the givenarray.
-
-
-
Method Detail
-
sigmoid
public static double sigmoid(double z)
Function to calculate the sigmoid for the given valuez.- Parameters:
z- Parameter z- Returns:
- Returns the sigmoid for the parameter
z.
-
sum
public static double sum(double[] array)
Sums the values of the givenarray.- Parameters:
array- The array to be summed- Returns:
- Returns the sum of the values
-
singleSquaredEuclideanDistance
public static double singleSquaredEuclideanDistance(double[] vector1, double[] vector2)Computes the single squared Euclidean distance between two vectors.- Parameters:
vector1- First argument vectorvector2- Second argument vector- Returns:
- Returns the single squared Euclidean distance between two vectors
-
intManhattanDistance
public static double intManhattanDistance(int[] a, int[] b)Simple Manhattan distance (sum of the absolute differences between the vectors' elements) implementation for arrays of Integer.- Parameters:
a- First argument vectorb- Second argument vector- Returns:
- Returns the Manhattan distance of the two given vectors
-
mean
public static double mean(double[] vector, int t1, int t2)Function calculating the mean of the interval [t1, t2 (inclusive)] of the givenvector.- Parameters:
vector- Vector which is used for the calculationt1- Interval startt2- Interval end (inclusive)- Returns:
- Returns the mean of the vector's interval [t1, t2 (inclusive)]
-
stddev
public static double stddev(double[] vector, int t1, int t2, boolean useBiasCorrection)Function calculating the standard deviation of the interval [t1, t2 (inclusive)] of the givenvector.- Parameters:
vector- Vector which is used for the calculationt1- Interval startt2- Interval end (inclusive)useBiasCorrection- Indicator whether the bias (Bessel's) correction should be used- Returns:
- Returns the standard deviation of the vector's interval [t1, t2 (inclusive)]
-
slope
public static double slope(double[] vector, int t1, int t2)Function calculating the slope of the interval [t1, t2 (inclusive)] of the givenvector.- Parameters:
vector- Vector which is used for the calculationt1- Interval startt2- Interval end (inclusive)- Returns:
- Returns the slope of the vector's interval [t1, t2 (inclusive)]
-
argmax
public static int argmax(int[] array)
Calculates the index of the maximum value in the givenarray(argmax).- Parameters:
array- Array to be checked. Must not be null or empty- Returns:
- Returns the index of the maximum value
-
-