Package elki.distance

## Class ArcCosineDistance

• java.lang.Object
• elki.distance.ArcCosineDistance
• All Implemented Interfaces:
Distance<NumberVector>, NumberVectorDistance<NumberVector>, PrimitiveDistance<NumberVector>, SpatialPrimitiveDistance<NumberVector>

@Priority(100)
@Alias("arccos")
public class ArcCosineDistance
extends java.lang.Object
implements SpatialPrimitiveDistance<NumberVector>, NumberVectorDistance<NumberVector>
Arcus cosine distance function for feature vectors.

The arc cosine distance is computed as the arcus from the cosine similarity value, i.e., arccos(<v1,v2>).

Cosine similarity is defined as $\tfrac{\vec{x}\cdot\vec{y}}{||a||\cdot||b||}$ Arcus cosine distance then is $\text{arccos} \tfrac{\vec{x}\cdot\vec{y}}{||a||\cdot||b||} \in [0;\pi]$

CosineDistance and SqrtCosineDistance are a bit less expensive to compute, and will yield the same ranking of neighbors.

Since:
0.2
Author:
Arthur Zimek
• ### Nested Class Summary

Nested Classes
Modifier and Type Class Description
static class  ArcCosineDistance.Par
Parameterization class.
• ### Field Summary

Fields
Modifier and Type Field Description
static ArcCosineDistance STATIC
Static instance
• ### Constructor Summary

Constructors
Constructor Description
ArcCosineDistance()
Deprecated.
Use static instance!
• ### Method Summary

All Methods
Modifier and Type Method Description
double distance​(NumberVector v1, NumberVector v2)
Computes the distance between two given DatabaseObjects according to this distance function.
boolean equals​(java.lang.Object obj)
SimpleTypeInformation<? super NumberVector> getInputTypeRestriction()
Get the input data type of the function.
int hashCode()
boolean isMetric()
Is this distance function metric (satisfy the triangle inequality)
double minDist​(SpatialComparable mbr1, SpatialComparable mbr2)
Computes the distance between the two given MBRs according to this distance function.
java.lang.String toString()
• ### Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait
• ### Methods inherited from interface elki.distance.Distance

isSquared, isSymmetric
• ### Methods inherited from interface elki.distance.SpatialPrimitiveDistance

instantiate
• ### Field Detail

• #### STATIC

public static final ArcCosineDistance STATIC
Static instance
• ### Constructor Detail

• #### ArcCosineDistance

@Deprecated
public ArcCosineDistance()
Deprecated.
Use static instance!
Constructor - use STATIC instead.
• ### Method Detail

• #### distance

public double distance​(NumberVector v1,
NumberVector v2)
Description copied from interface: PrimitiveDistance
Computes the distance between two given DatabaseObjects according to this distance function.
Specified by:
distance in interface NumberVectorDistance<NumberVector>
Specified by:
distance in interface PrimitiveDistance<NumberVector>
Parameters:
v1 - first DatabaseObject
v2 - second DatabaseObject
Returns:
the distance between two given DatabaseObjects according to this distance function
• #### minDist

public double minDist​(SpatialComparable mbr1,
SpatialComparable mbr2)
Description copied from interface: SpatialPrimitiveDistance
Computes the distance between the two given MBRs according to this distance function.
Specified by:
minDist in interface SpatialPrimitiveDistance<NumberVector>
Parameters:
mbr1 - the first MBR object
mbr2 - the second MBR object
Returns:
the distance between the two given MBRs according to this distance function
• #### isMetric

public boolean isMetric()
Description copied from interface: Distance
Is this distance function metric (satisfy the triangle inequality)
Specified by:
isMetric in interface Distance<NumberVector>
Returns:
true when metric.
• #### toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
• #### equals

public boolean equals​(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
• #### hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object
• #### getInputTypeRestriction

public SimpleTypeInformation<? super NumberVector> getInputTypeRestriction()
Description copied from interface: Distance
Get the input data type of the function.
Specified by:
getInputTypeRestriction in interface Distance<NumberVector>
Specified by:
getInputTypeRestriction in interface PrimitiveDistance<NumberVector>
Returns:
Type restriction