Class MathOperations
java.lang.Object
de.uni_mannheim.informatik.dws.melt.matching_jena_matchers.external.services.math.MathOperations
A helper class for mathematical and statistical operations.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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.
-
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 cutthreshold
- cutting threshold- Returns:
- new double array
-
cosineSimilarity
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.
-