org.openimaj.feature

## Enum LongFVComparison

• ### Enum Constant Summary

Enum Constants
Enum Constant and Description
`ARCCOS`
The arccosine of the cosine similarity
`BHATTACHARYYA`
Bhattacharyya distance d(H1,H2) = sqrt( 1 - (1 / sqrt(sumI(H1(I)) * sumI(H2(I))) ) * sumI( sqrt(H1(I) * H2(I)) ) )
`CHI_SQUARE`
Chi-squared distance d(H1,H2) = 0.5 * sumI[(H1(I)-H2(I))^2 / (H1(I)+H2(I))]
`CITY_BLOCK`
City-block (L1) distance d(H1,H2) = sumI( abs(H1(I)-H2(I)) )
`CORRELATION`
Correlation s(H1,H2) = sumI( H'1(I) * H'2(I) ) / sqrt( sumI[H'1(I)2]^2 * sumI[H'2(I)^2] ) where H'k(I) = Hk(I) - (1/N) * sumJ( Hk(J) ); N=number of FeatureVector bins
`COSINE_DIST`
Cosine distance (-COSINE_SIM)
`COSINE_SIM`
Cosine similarity (sim of 1 means identical) s(H1,H2)=sumI(H1(I) * H2(I))) / (sumI(H1(I)^2) sumI(H2(I)^2))
`EUCLIDEAN`
Euclidean distance d(H1,H2) = Math.sqrt( sumI( (H1(I)-H2(I))^2 ) )
`HAMMING`
Hamming Distance d(H1,H2) = sumI(H1(I) == H2(I) ? 1 : 0)
`INNER_PRODUCT`
Inner product s(H1,H2)=sumI(H1(I) * H2(I))
`INTERSECTION`
Histogram intersection s(H1,H2) = sumI( min(H1(I), H2(I)) )
`JACCARD_DISTANCE`
Jaccard distance.
`PACKED_HAMMING`
Hamming Distance for packed bit strings d(H1,H2) = sumI(H1(I) == H2(I) ? 1 : 0)
`SUM_SQUARE`
Sum-square distance d(H1,H2) = sumI( (H1(I)-H2(I))^2 )
`SYMMETRIC_KL_DIVERGENCE`
The symmetric Kullback-Leibler divergence.
• ### Method Summary

All Methods
Modifier and Type Method and Description
`abstract double` ```compare(long[] h1, long[] h2)```
Compare two feature vectors in the form of native arrays, returning a score or distance.
`double` ```compare(LongFV h1, LongFV h2)```
Compare two objects, returning a score or distance.
`boolean` `isDistance()`
`static LongFVComparison` `valueOf(String name)`
Returns the enum constant of this type with the specified name.
`static LongFVComparison[]` `values()`
Returns an array containing the constants of this enum type, in the order they are declared.
• ### Methods inherited from class java.lang.Enum

`clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf`
• ### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, wait, wait, wait`
• ### Enum Constant Detail

• #### EUCLIDEAN

`public static final LongFVComparison EUCLIDEAN`
Euclidean distance d(H1,H2) = Math.sqrt( sumI( (H1(I)-H2(I))^2 ) )
• #### SUM_SQUARE

`public static final LongFVComparison SUM_SQUARE`
Sum-square distance d(H1,H2) = sumI( (H1(I)-H2(I))^2 )
• #### CORRELATION

`public static final LongFVComparison CORRELATION`
Correlation s(H1,H2) = sumI( H'1(I) * H'2(I) ) / sqrt( sumI[H'1(I)2]^2 * sumI[H'2(I)^2] ) where H'k(I) = Hk(I) - (1/N) * sumJ( Hk(J) ); N=number of FeatureVector bins
• #### CHI_SQUARE

`public static final LongFVComparison CHI_SQUARE`
Chi-squared distance d(H1,H2) = 0.5 * sumI[(H1(I)-H2(I))^2 / (H1(I)+H2(I))]
• #### INTERSECTION

`public static final LongFVComparison INTERSECTION`
Histogram intersection s(H1,H2) = sumI( min(H1(I), H2(I)) )
• #### BHATTACHARYYA

`public static final LongFVComparison BHATTACHARYYA`
Bhattacharyya distance d(H1,H2) = sqrt( 1 - (1 / sqrt(sumI(H1(I)) * sumI(H2(I))) ) * sumI( sqrt(H1(I) * H2(I)) ) )
• #### HAMMING

`public static final LongFVComparison HAMMING`
Hamming Distance d(H1,H2) = sumI(H1(I) == H2(I) ? 1 : 0)
• #### PACKED_HAMMING

`public static final LongFVComparison PACKED_HAMMING`
Hamming Distance for packed bit strings d(H1,H2) = sumI(H1(I) == H2(I) ? 1 : 0)
• #### CITY_BLOCK

`public static final LongFVComparison CITY_BLOCK`
City-block (L1) distance d(H1,H2) = sumI( abs(H1(I)-H2(I)) )
• #### COSINE_SIM

`public static final LongFVComparison COSINE_SIM`
Cosine similarity (sim of 1 means identical) s(H1,H2)=sumI(H1(I) * H2(I))) / (sumI(H1(I)^2) sumI(H2(I)^2))
• #### COSINE_DIST

`public static final LongFVComparison COSINE_DIST`
Cosine distance (-COSINE_SIM)
• #### ARCCOS

`public static final LongFVComparison ARCCOS`
The arccosine of the cosine similarity
• #### SYMMETRIC_KL_DIVERGENCE

`public static final LongFVComparison SYMMETRIC_KL_DIVERGENCE`
The symmetric Kullback-Leibler divergence. Vectors must only contain positive values; internally they will be converted to double arrays and normalised to sum to unit length.
• #### JACCARD_DISTANCE

`public static final LongFVComparison JACCARD_DISTANCE`
Jaccard distance. Converts each vector to a set for comparison.
• #### INNER_PRODUCT

`public static final LongFVComparison INNER_PRODUCT`
Inner product s(H1,H2)=sumI(H1(I) * H2(I))
• ### Method Detail

• #### values

`public static LongFVComparison[] values()`
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
```for (LongFVComparison c : LongFVComparison.values())
System.out.println(c);
```
Returns:
an array containing the constants of this enum type, in the order they are declared
• #### valueOf

`public static LongFVComparison valueOf(String name)`
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
Parameters:
`name` - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
`IllegalArgumentException` - if this enum type has no constant with the specified name
`NullPointerException` - if the argument is null
• #### isDistance

`public boolean isDistance()`
Specified by:
`isDistance` in interface `DistanceComparator<LongFV>`
Returns:
true if the comparison is a distance; false if similarity.
• #### compare

```public double compare(LongFV h1,
LongFV h2)```
Description copied from interface: `DistanceComparator`
Compare two objects, returning a score or distance.
Specified by:
`compare` in interface `DistanceComparator<LongFV>`
Parameters:
`h1` - the first object
`h2` - the second object
Returns:
a score or distance
• #### compare

```public abstract double compare(long[] h1,
long[] h2)```
Compare two feature vectors in the form of native arrays, returning a score or distance.
Specified by:
`compare` in interface `LongFVComparator`
Parameters:
`h1` - the first feature array
`h2` - the second feature array
Returns:
a score or distance