java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.services.math.MathOperations

public class MathOperations extends Object
A helper class for mathematical and statistical operations.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    calculateEuclideanDistance(double[] v1, double[] v2)
    Calculates the euclidean distance between two vectors.
    static double
    cosineSimilarity(double[] vector1, double[] vector2)
    Calculate The cosine similarity between two vectors.
    static double
    cosineSimilarity(Double[] vector1, Double[] vector2)
    Calculate The cosine similarity between two vectors.
    static double[]
    cutAtThreshold(double[] input, double threshold)
    This method will set values below the threshold to 0.0 and those equal or above to 1.0.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

      private static org.slf4j.Logger LOG
  • Constructor Details

    • MathOperations

      public MathOperations()
  • Method Details

    • calculateEuclideanDistance

      public static double calculateEuclideanDistance(double[] v1, double[] v2)
      Calculates the euclidean distance between two vectors.
      Parameters:
      v1 - Vector 1.
      v2 - Vector 2.
      Returns:
      Euclidean distance.
    • cutAtThreshold

      public static double[] cutAtThreshold(double[] input, double threshold)
      This method will set values below the threshold to 0.0 and those equal or above to 1.0.
      Parameters:
      input - double array that shall be cut
      threshold - cutting threshold
      Returns:
      new double array
    • cosineSimilarity

      public static double cosineSimilarity(Double[] vector1, Double[] vector2)
      Calculate The cosine similarity between two vectors.
      Parameters:
      vector1 - First vector.
      vector2 - Second vector.
      Returns:
      Cosine similarity as double.
    • cosineSimilarity

      public static double cosineSimilarity(double[] vector1, double[] vector2)
      Calculate The cosine similarity between two vectors.
      Parameters:
      vector1 - First vector.
      vector2 - Second vector.
      Returns:
      Cosine similarity as double.