Package chemaxon.descriptors
Class Metrics
java.lang.Object
chemaxon.descriptors.Metrics
The
Metrics
class implements dissimilarity metrics for
MolecularDescriptors
. For the sake of general availability
of this dissimilarity calculations by any MolecularDescriptor
derivatives, methods take float and int arrays as input parameters, thus
they do not need to access to the internal representation of descriptors.
This, however, may introduce some overhead in dissimilarity calculations,
since MolecularDescriptor
objects may need to transform their
internal representation into an int or a float array. If this overhead
is significant, then the required dissimilarity function has to be
implemented as part of the descriptor class.- Since:
- JChem 2.3
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic float
asymmetricEuclidean
(float[] v1, float[] v2, double asymmetryFactor) Calculates the asymmetric Euclidean distance.static float
asymmetricEuclidean
(int[] v1, int[] v2, double asymmetryFactor) Calculates the asymmetric Euclidean distance.static float
asymmetricNormalizedEuclidean
(float[] v1, float[] v2, double asymmetryFactor) Calculates the asymmetric normalized Euclidean distance.static float
asymmetricNormalizedEuclidean
(int[] v1, int[] v2, double asymmetryFactor) Calculates the asymmetric normalized Euclidean distance.static float
asymmetricTanimoto
(float[] v1, float[] v2, float asymmetryFactor) Calculates the asymmetric Tanimoto dissimilarity for floating point values.static float
asymmetricTanimoto
(int[] v1, int[] v2, float asymmetryFactor) Calculates the asymmetric Tanimoto dissimilarity for floating point values.static float
binaryAsymmetricEuclidean
(int[] v1, int[] v2, float asymmetryFactor) Calculates the asymmetric Euclidean distance of binary descriptors.static float
binaryAsymmetricNormalizedEuclidean
(int[] v1, int[] v2, float asymmetryFactor) Calculates the asymmetric normalized Euclidean distance of binary descriptors.static float
binaryAsymmetricNormalizedEuclidean
(int[] v1, int oneCount1, int[] v2, int oneCount2, float asymmetryFactor) Calculates the asymmetric normalized Euclidean distance of binary descriptors.static float
binaryAsymmetricTanimoto
(int[] v1, int[] v2, float asymmetryFactor) Calculates asymmetric Tanimoto dissimilarity for binary descriptors.static float
binaryAsymmetricTanimoto
(int[] v1, int oneCount1, int[] v2, int oneCount2, float asymmetryFactor) Calculates asymmetricTanimoto dissimilarity for binary descriptors.static float
binaryEuclidean
(int[] v1, int[] v2) Calculates the Euclidean distance of two binary descriptors.static float
binaryNormalizedEuclidean
(int[] v1, int[] v2) Calculates the normalized Euclidean distance of two binary descriptors.static float
binaryNormalizedEuclidean
(int[] v1, int oneCount1, int[] v2, int oneCount2) Calculates the normalized Euclidean distance of two binary descriptors.static float
binaryTanimoto
(int[] v1, int[] v2) Calculates Tanimoto dissimilarity for binary descriptors.static float
binaryTanimoto
(int[] v1, int oneCount1, int[] v2, int oneCount2) Calculates Tanimoto dissimilarity for binary descriptors.static float
binaryTversky
(int[] v1, float wv1, int[] v2, float wv2) Calculates Tversky dissimilarity for binary descriptors.static float
binaryWeightedAsymmetricEuclidean
(int[] v1, int[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric Euclidean distance of binary descriptors.static float
binaryWeightedAsymmetricNormalizedEuclidean
(int[] v1, int[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric normalized Euclidean distance of binary descriptors.static float
binaryWeightedAsymmetricNormalizedEuclidean
(int[] v1, int oneCount1, int[] v2, int oneCount2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric normalized Euclidean distance of binary descriptors.static float
binaryWeightedEuclidean
(int[] v1, int[] v2, float[] weights) Calculates the weighted Euclidean distance of binary descriptors.static float
binaryWeightedNormalizedEuclidean
(int[] v1, int[] v2, float[] weights) Calculates the weighted normalized Euclidean distance of binary descriptors.static float
binaryWeightedNormalizedEuclidean
(int[] v1, int oneCount1, int[] v2, int oneCount2, int[] weights) Calculates the weighted normalized Euclidean distance of binary descriptors.static int
calcBitCount
(int i) Counts the number of bits set (1) in the integer parameter.static int
calcBitCount
(int[] v) Counts the number of bits set (1) in a bit vector.static float
euclidean
(float[] v1, float[] v2) Calculates the Euclidean distance.static float
euclidean
(int[] v1, int[] v2) Calculates the Euclidean distance.static float
normalizedEuclidean
(float[] v1, float[] v2) Calculates the normalized Euclidean distance.static float
normalizedEuclidean
(int[] v1, int[] v2) Calculates the normalized Euclidean distance.static float
scaledAsymmetricTanimoto
(float[] v1, float[] v2, float[] hypothesis, float scaleFactor, float asymmetryFactor) Calculates the scaled asymmetric Tanimoto dissimilarity for floating point values.static float
scaledAsymmetricTanimoto
(int[] v1, int[] v2, float[] hypothesis, float scaleFactor, float asymmetryFactor) Calculates the scaled asymmetric Tanimoto dissimilarity for floating point values.static float
scaledTanimoto
(float[] v1, float[] v2, float[] hypothesis, float scaleFactor) Calculates the scaled Tanimoto dissimilarity for floating point values.static float
scaledTanimoto
(int[] v1, int[] v2, float[] hypothesis, float scaleFactor) Calculates the scaled Tanimoto dissimilarity for floating point values.static float
tanimoto
(float[] v1, float[] v2) Calculates Tanimoto dissimilarity for floating point values.static float
tanimoto
(int[] v1, int[] v2) Calculates Tanimoto dissimilarity for floating point values.static float
tversky
(float[] v1, float wv1, float[] v2, float wv2) Calculates Tversky dissimilarity for floating point values.static float
tversky
(int[] v1, float wv1, int[] v2, float wv2) Calculates Tversky dissimilarity index for integer values.static float
weightedAsymmetricEuclidean
(float[] v1, float[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric Euclidean distance.static float
weightedAsymmetricEuclidean
(int[] v1, int[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric Euclidean distance.static float
weightedAsymmetricNormalizedEuclidean
(float[] v1, float[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric normalized Euclidean distance.static float
weightedAsymmetricNormalizedEuclidean
(int[] v1, int[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric normalized Euclidean distance.static float
weightedEuclidean
(float[] v1, float[] v2, float[] weights) Calculates the weighted Euclidean distance.static float
weightedEuclidean
(int[] v1, int[] v2, float[] weights) Calculates the weighted Euclidean distance.static float
weightedNormalizedEuclidean
(float[] v1, float[] v2, float[] weights) Calculates the weighted normalized Euclidean distance.static float
weightedNormalizedEuclidean
(int[] v1, int[] v2, float[] weights) Calculates the weighted normalized Euclidean distance.
-
Constructor Details
-
Metrics
public Metrics()
-
-
Method Details
-
euclidean
public static float euclidean(float[] v1, float[] v2) Calculates the Euclidean distance. The dissimilarity coefficient returned ranges from 0 to MAX_FLOAT, this coefficient is not normalized.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- dissimilarity coefficient
-
normalizedEuclidean
public static float normalizedEuclidean(float[] v1, float[] v2) Calculates the normalized Euclidean distance. The dissimilarity coefficient returned ranges from 0 to 1.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- dissimilarity coefficient
-
asymmetricEuclidean
public static float asymmetricEuclidean(float[] v1, float[] v2, double asymmetryFactor) Calculates the asymmetric Euclidean distance. The dissimilarity coefficient returned ranges from 0 to MAX_FLOAT. This metric is also known as directed Euclidean.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
asymmetricNormalizedEuclidean
public static float asymmetricNormalizedEuclidean(float[] v1, float[] v2, double asymmetryFactor) Calculates the asymmetric normalized Euclidean distance. The dissimilarity coefficient returned ranges from 0 to 1.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
weightedEuclidean
public static float weightedEuclidean(float[] v1, float[] v2, float[] weights) Calculates the weighted Euclidean distance.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinate- Returns:
- dissimilarity coefficient
-
weightedNormalizedEuclidean
public static float weightedNormalizedEuclidean(float[] v1, float[] v2, float[] weights) Calculates the weighted normalized Euclidean distance.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinate- Returns:
- dissimilarity coefficient
-
weightedAsymmetricEuclidean
public static float weightedAsymmetricEuclidean(float[] v1, float[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric Euclidean distance.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinateasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
weightedAsymmetricNormalizedEuclidean
public static float weightedAsymmetricNormalizedEuclidean(float[] v1, float[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric normalized Euclidean distance.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinateasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
tanimoto
public static float tanimoto(float[] v1, float[] v2) Calculates Tanimoto dissimilarity for floating point values.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- Tanimoto dissimilarity
-
tversky
public static float tversky(float[] v1, float wv1, float[] v2, float wv2) Calculates Tversky dissimilarity for floating point values.- Parameters:
v1
- first vectorwv1
- weight for the first vectorv2
- second vectorwv2
- weight for the second vector- Returns:
- Tversky index
-
asymmetricTanimoto
public static float asymmetricTanimoto(float[] v1, float[] v2, float asymmetryFactor) Calculates the asymmetric Tanimoto dissimilarity for floating point values.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- Tanimoto dissimilarity
-
scaledTanimoto
public static float scaledTanimoto(float[] v1, float[] v2, float[] hypothesis, float scaleFactor) Calculates the scaled Tanimoto dissimilarity for floating point values.- Parameters:
v1
- first vectorv2
- second vectorhypothesis
- scaling (consensus) hypothesisscaleFactor
- scale factor- Returns:
- Tanimoto dissimilarity
-
scaledAsymmetricTanimoto
public static float scaledAsymmetricTanimoto(float[] v1, float[] v2, float[] hypothesis, float scaleFactor, float asymmetryFactor) Calculates the scaled asymmetric Tanimoto dissimilarity for floating point values.- Parameters:
v1
- first vectorv2
- second vectorhypothesis
- scaling (consensus) hypothesisscaleFactor
- scale factorasymmetryFactor
- asymmetry ratio- Returns:
- Tanimoto dissimilarity
-
euclidean
public static float euclidean(int[] v1, int[] v2) Calculates the Euclidean distance. The dissimilarity coefficient returned ranges from 0 to MAX_FLOAT, this coefficient is not normalized.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- dissimilarity coefficient
-
normalizedEuclidean
public static float normalizedEuclidean(int[] v1, int[] v2) Calculates the normalized Euclidean distance. The dissimilarity coefficient returned ranges from 0 to 1.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- dissimilarity coefficient
-
asymmetricEuclidean
public static float asymmetricEuclidean(int[] v1, int[] v2, double asymmetryFactor) Calculates the asymmetric Euclidean distance. The dissimilarity coefficient returned ranges from 0 to MAX_FLOAT. This metric is also known as directed Euclidean.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
asymmetricNormalizedEuclidean
public static float asymmetricNormalizedEuclidean(int[] v1, int[] v2, double asymmetryFactor) Calculates the asymmetric normalized Euclidean distance. The dissimilarity coefficient returned ranges from 0 to 1.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
weightedEuclidean
public static float weightedEuclidean(int[] v1, int[] v2, float[] weights) Calculates the weighted Euclidean distance.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinate- Returns:
- dissimilarity coefficient
-
weightedNormalizedEuclidean
public static float weightedNormalizedEuclidean(int[] v1, int[] v2, float[] weights) Calculates the weighted normalized Euclidean distance.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinate- Returns:
- dissimilarity coefficient
-
weightedAsymmetricEuclidean
public static float weightedAsymmetricEuclidean(int[] v1, int[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric Euclidean distance.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinateasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
weightedAsymmetricNormalizedEuclidean
public static float weightedAsymmetricNormalizedEuclidean(int[] v1, int[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric normalized Euclidean distance.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinateasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
tanimoto
public static float tanimoto(int[] v1, int[] v2) Calculates Tanimoto dissimilarity for floating point values.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- Tanimoto dissimilarity
-
tversky
public static float tversky(int[] v1, float wv1, int[] v2, float wv2) Calculates Tversky dissimilarity index for integer values.- Parameters:
v1
- first vectorwv1
- weight for the first vectorv2
- second vectorwv2
- weight for the second vector- Returns:
- Tversky dissimilarity index
-
asymmetricTanimoto
public static float asymmetricTanimoto(int[] v1, int[] v2, float asymmetryFactor) Calculates the asymmetric Tanimoto dissimilarity for floating point values.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- Tanimoto dissimilarity
-
scaledTanimoto
public static float scaledTanimoto(int[] v1, int[] v2, float[] hypothesis, float scaleFactor) Calculates the scaled Tanimoto dissimilarity for floating point values.- Parameters:
v1
- first vectorv2
- second vectorhypothesis
- scaling (consensus) hypothesisscaleFactor
- scale factor- Returns:
- Tanimoto dissimilarity
-
scaledAsymmetricTanimoto
public static float scaledAsymmetricTanimoto(int[] v1, int[] v2, float[] hypothesis, float scaleFactor, float asymmetryFactor) Calculates the scaled asymmetric Tanimoto dissimilarity for floating point values.- Parameters:
v1
- first vectorv2
- second vectorhypothesis
- scaling (consensus) hypothesisscaleFactor
- scale factorasymmetryFactor
- asymmetry ratio- Returns:
- Tanimoto dissimilarity
-
calcBitCount
public static int calcBitCount(int i) Counts the number of bits set (1) in the integer parameter.- Parameters:
i
- an integer value- Returns:
- number of 1 bits in the parameter passed
-
calcBitCount
public static int calcBitCount(int[] v) Counts the number of bits set (1) in a bit vector.- Parameters:
v
- bit vector, represented by an integer vector, each element stores 32 bits- Returns:
- number of 1 bits in the bit vector
-
binaryEuclidean
public static float binaryEuclidean(int[] v1, int[] v2) Calculates the Euclidean distance of two binary descriptors.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- dissimilarity coefficient
-
binaryNormalizedEuclidean
public static float binaryNormalizedEuclidean(int[] v1, int[] v2) Calculates the normalized Euclidean distance of two binary descriptors.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- dissimilarity coefficient
-
binaryNormalizedEuclidean
public static float binaryNormalizedEuclidean(int[] v1, int oneCount1, int[] v2, int oneCount2) Calculates the normalized Euclidean distance of two binary descriptors. This method should be called in place ofbinaryNormalizedEuclidean( final int[] v1, final int[] v2 )
when the number of bits set (1) is known in both input vectors, as this method does not recalculate these values which results in faster operation.- Parameters:
v1
- first vectoroneCount1
- number of 1 bits in v1v2
- second vectoroneCount2
- number of 1 bits in v1- Returns:
- dissimilarity coefficient
-
binaryWeightedEuclidean
public static float binaryWeightedEuclidean(int[] v1, int[] v2, float[] weights) Calculates the weighted Euclidean distance of binary descriptors.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinate- Returns:
- dissimilarity coefficient
-
binaryWeightedNormalizedEuclidean
public static float binaryWeightedNormalizedEuclidean(int[] v1, int[] v2, float[] weights) Calculates the weighted normalized Euclidean distance of binary descriptors.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinate- Returns:
- dissimilarity coefficient
-
binaryWeightedNormalizedEuclidean
public static float binaryWeightedNormalizedEuclidean(int[] v1, int oneCount1, int[] v2, int oneCount2, int[] weights) Calculates the weighted normalized Euclidean distance of binary descriptors.- Parameters:
v1
- first vectoroneCount1
- number of 1 bits in v1v2
- second vectoroneCount2
- number of 1 bits in v2weights
- weight factors for every coordinate- Returns:
- dissimilarity coefficient
-
binaryAsymmetricEuclidean
public static float binaryAsymmetricEuclidean(int[] v1, int[] v2, float asymmetryFactor) Calculates the asymmetric Euclidean distance of binary descriptors.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
binaryAsymmetricNormalizedEuclidean
public static float binaryAsymmetricNormalizedEuclidean(int[] v1, int[] v2, float asymmetryFactor) Calculates the asymmetric normalized Euclidean distance of binary descriptors.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
binaryAsymmetricNormalizedEuclidean
public static float binaryAsymmetricNormalizedEuclidean(int[] v1, int oneCount1, int[] v2, int oneCount2, float asymmetryFactor) Calculates the asymmetric normalized Euclidean distance of binary descriptors. This method should be called in place ofbinaryAsymmetricNormalizedEuclidean( final int[] v1, final int[] v2 )
when the number of bits set (1) is known in both input vectors, as this method does not recalculate these values which results in faster operation.- Parameters:
v1
- first vectoroneCount1
- number of 1 bits in v1v2
- second vectoroneCount2
- number of 1 bits in v2asymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
binaryWeightedAsymmetricEuclidean
public static float binaryWeightedAsymmetricEuclidean(int[] v1, int[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric Euclidean distance of binary descriptors.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinateasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
binaryWeightedAsymmetricNormalizedEuclidean
public static float binaryWeightedAsymmetricNormalizedEuclidean(int[] v1, int[] v2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric normalized Euclidean distance of binary descriptors.- Parameters:
v1
- first vectorv2
- second vectorweights
- weight factors for every coordinateasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
binaryWeightedAsymmetricNormalizedEuclidean
public static float binaryWeightedAsymmetricNormalizedEuclidean(int[] v1, int oneCount1, int[] v2, int oneCount2, float[] weights, float asymmetryFactor) Calculates the weighted asymmetric normalized Euclidean distance of binary descriptors. This method should be called in place ofbinaryWeightedAsymmetricNormalizedEuclidean( final int[] v1, final int[] v2, final float[] weights, float asymmetryFactor )
when the number of bits set (1) is known in both input vectors, as this method does not recalculate these values which results in faster operation.- Parameters:
v1
- first vectoroneCount1
- number of 1 bits in v1v2
- second vectoroneCount2
- number of 1 bits in v2weights
- weight factors for every coordinateasymmetryFactor
- asymmetry ratio- Returns:
- dissimilarity coefficient
-
binaryTanimoto
public static float binaryTanimoto(int[] v1, int[] v2) Calculates Tanimoto dissimilarity for binary descriptors.- Parameters:
v1
- first vectorv2
- second vector- Returns:
- Tanimoto dissimilarity
-
binaryTversky
public static float binaryTversky(int[] v1, float wv1, int[] v2, float wv2) Calculates Tversky dissimilarity for binary descriptors.- Parameters:
v1
- first vectorwv1
- weight for the first vectorv2
- second vectorwv2
- weight for the second vector- Returns:
- Tversky dissimilarity
-
binaryAsymmetricTanimoto
public static float binaryAsymmetricTanimoto(int[] v1, int[] v2, float asymmetryFactor) Calculates asymmetric Tanimoto dissimilarity for binary descriptors.- Parameters:
v1
- first vectorv2
- second vectorasymmetryFactor
- asymmetry ratio- Returns:
- Tanimoto dissimilarity
-
binaryTanimoto
public static float binaryTanimoto(int[] v1, int oneCount1, int[] v2, int oneCount2) Calculates Tanimoto dissimilarity for binary descriptors. This method should be called in place ofbinaryTanimoto( final int[] v1, final int[] v2 )
when the number of bits set (1) is known in both input vectors, as this method does not recalculate these values which results in faster operation.- Parameters:
v1
- first vectoroneCount1
- number of 1 bits in v1v2
- second vectoroneCount2
- number of 1 bits in v2- Returns:
- Tanimoto dissimilarity
-
binaryAsymmetricTanimoto
public static float binaryAsymmetricTanimoto(int[] v1, int oneCount1, int[] v2, int oneCount2, float asymmetryFactor) Calculates asymmetricTanimoto dissimilarity for binary descriptors. This method should be called in place ofbinaryTanimoto( final int[] v1, final int[] v2, float asymmetryFactor )
when the number of bits set (1) is known in both input vectors, as this method does not recalculate these values which results in faster operation.- Parameters:
v1
- first vectoroneCount1
- number of 1 bits in v1v2
- second vectoroneCount2
- number of 1 bits in v2asymmetryFactor
- asymmetry ratio- Returns:
- Tanimoto dissimilarity
-