Package org.ddolib.common.util
Class DistanceUtil
java.lang.Object
org.ddolib.common.util.DistanceUtil
Utility methods for common distance metrics used by clustering and heuristics.
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublediceDistance(BitSet a, BitSet b) Computes the Dice Distance between the two given sets.static doubleeuclideanDistance(double[] a, double[] b) Computes the Euclidean Distance between the two given arrays of coordinates.static doublejaccardDistance(BitSet a, BitSet b) Computes the Jaccard Distance between the two given sets.static doubleComputes the size of the symmetric difference between a and b.static doubleweightedJaccardDistance(BitSet a, BitSet b, double[] weights) Computes the weighted Jaccard Distance between the two given sets.static doubleweightedSymmetricDifferenceDistance(BitSet a, BitSet b, double[] weights) Computes the weighted symmetric difference between a and b.
-
Method Details
-
jaccardDistance
Computes the Jaccard Distance between the two given sets.- Parameters:
a- the first setb- the second set- Returns:
- 1 - |a ∩ b| / |a ∪ b|
-
weightedJaccardDistance
Computes the weighted Jaccard Distance between the two given sets.- Parameters:
a- the first setb- the second setweights- the weight of each element in a and b- Returns:
- the weighted Jaccard Distance between a and b
-
diceDistance
Computes the Dice Distance between the two given sets.- Parameters:
a- the first setb- the second set- Returns:
- 1 - 2|a ∩ b| / (|a| + |b|)
-
euclideanDistance
public static double euclideanDistance(double[] a, double[] b) Computes the Euclidean Distance between the two given arrays of coordinates.- Parameters:
a- the first arrayb- the second array- Returns:
- the Euclidean distance between a and b
-
symmetricDifferenceDistance
Computes the size of the symmetric difference between a and b.- Parameters:
a- the first setb- the second set- Returns:
- |a XOR b|
-
weightedSymmetricDifferenceDistance
Computes the weighted symmetric difference between a and b.- Parameters:
a- the first setb- the second setweights- the weight of each element in a and b- Returns:
- the weighted symmetric difference between a and b
-