Class MathUtil


  • public class MathUtil
    extends java.lang.Object
    Utility class consisting of mathematical utility functions.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int argmax​(int[] array)
      Calculates the index of the maximum value in the given array (argmax).
      static double intManhattanDistance​(int[] a, int[] b)
      Simple Manhattan distance (sum of the absolute differences between the vectors' elements) implementation for arrays of Integer.
      static double mean​(double[] vector, int t1, int t2)
      Function calculating the mean of the interval [t1, t2 (inclusive)] of the given vector.
      static double sigmoid​(double z)
      Function to calculate the sigmoid for the given value z.
      static double singleSquaredEuclideanDistance​(double[] vector1, double[] vector2)
      Computes the single squared Euclidean distance between two vectors.
      static double slope​(double[] vector, int t1, int t2)
      Function calculating the slope of the interval [t1, t2 (inclusive)] of the given vector.
      static double stddev​(double[] vector, int t1, int t2, boolean useBiasCorrection)
      Function calculating the standard deviation of the interval [t1, t2 (inclusive)] of the given vector.
      static double sum​(double[] array)
      Sums the values of the given array.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • sigmoid

        public static double sigmoid​(double z)
        Function to calculate the sigmoid for the given value z.
        Parameters:
        z - Parameter z
        Returns:
        Returns the sigmoid for the parameter z.
      • sum

        public static double sum​(double[] array)
        Sums the values of the given array.
        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 vector
        vector2 - 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 vector
        b - 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 given vector.
        Parameters:
        vector - Vector which is used for the calculation
        t1 - Interval start
        t2 - 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 given vector.
        Parameters:
        vector - Vector which is used for the calculation
        t1 - Interval start
        t2 - 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 given vector.
        Parameters:
        vector - Vector which is used for the calculation
        t1 - Interval start
        t2 - 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 given array (argmax).
        Parameters:
        array - Array to be checked. Must not be null or empty
        Returns:
        Returns the index of the maximum value