de.lmu.ifi.dbs.elki.distance.distancefunction.probabilistic

## Class TriangularDistanceFunction

• All Implemented Interfaces:
DistanceFunction<NumberVector>, NumberVectorDistanceFunction<NumberVector>, PrimitiveDistanceFunction<NumberVector>, SpatialPrimitiveDistanceFunction<NumberVector>

@Reference(authors="R. Connor, F. A. Cardillo, L. Vadicamo, F. Rabitti",
title="Hilbert Exclusion: Improved Metric Search through Finite Isometric Embeddings",
booktitle="arXiv preprint arXiv:1604.08640",
url="http://arxiv.org/abs/1604.08640",
bibkey="DBLP:journals/corr/ConnorCVR16")
public class TriangularDistanceFunction
extends TriangularDiscriminationDistanceFunction
Triangular Distance has relatively tight upper and lower bounds to the (square root of the) Jensen-Shannon divergence, but is much less expensive.

$\text{Triangular-Distance}(\vec{x},\vec{y}):=\sqrt{ \sum\nolimits_i \tfrac{|x_i-y_i|^2}{x_i+y_i}}$

This distance function is meant for distribution vectors that sum to 1, and does not work on negative values.

This differs from TriangularDistanceFunction simply by the square root, which makes it a proper metric and a good approximation for the much more expensive SqrtJensenShannonDivergenceDistanceFunction.

Reference:

R. Connor, F. A. Cardillo, L. Vadicamo, F. Rabitti
Hilbert Exclusion: Improved Metric Search through Finite Isometric Embeddings
arXiv preprint arXiv:1604.08640

TODO: support sparse vectors, varying length

Since:
0.7.5
Author:
Erich Schubert
• ### Nested Class Summary

Nested Classes
Modifier and Type Class and Description
static class  TriangularDistanceFunction.Parameterizer
Parameterization class, using the static instance.
• ### Field Summary

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

Constructors
Modifier Constructor and Description
private  TriangularDistanceFunction()
Deprecated.
• ### Method Summary

All Methods
Modifier and Type Method and 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)
int hashCode()
boolean isMetric()
Is this distance function metric (satisfy the triangle inequality)
boolean isSquared()
Squared distances, that would become metric after square root.
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 de.lmu.ifi.dbs.elki.distance.distancefunction.AbstractNumberVectorDistanceFunction

dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, dimensionality, getInputTypeRestriction
• ### Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait
• ### Methods inherited from interface de.lmu.ifi.dbs.elki.distance.distancefunction.SpatialPrimitiveDistanceFunction

instantiate
• ### Methods inherited from interface de.lmu.ifi.dbs.elki.distance.distancefunction.PrimitiveDistanceFunction

getInputTypeRestriction
• ### Methods inherited from interface de.lmu.ifi.dbs.elki.distance.distancefunction.DistanceFunction

isSymmetric
• ### Field Detail

• #### STATIC

public static final TriangularDistanceFunction STATIC
Static instance. Use this!
• ### Constructor Detail

• #### TriangularDistanceFunction

@Deprecated
private TriangularDistanceFunction()
Deprecated.
Deprecated constructor: use the static instance STATIC instead.
• ### Method Detail

• #### distance

public double distance(NumberVector v1,
NumberVector v2)
Description copied from interface: PrimitiveDistanceFunction
Computes the distance between two given DatabaseObjects according to this distance function.
Specified by:
distance in interface NumberVectorDistanceFunction<NumberVector>
Specified by:
distance in interface PrimitiveDistanceFunction<NumberVector>
Overrides:
distance in class TriangularDiscriminationDistanceFunction
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: SpatialPrimitiveDistanceFunction
Computes the distance between the two given MBRs according to this distance function.
Specified by:
minDist in interface SpatialPrimitiveDistanceFunction<NumberVector>
Overrides:
minDist in class TriangularDiscriminationDistanceFunction
Parameters:
mbr1 - the first MBR object
mbr2 - the second MBR object
Returns:
the distance between the two given MBRs according to this distance function
• #### isSquared

public boolean isSquared()
Description copied from interface: DistanceFunction
Squared distances, that would become metric after square root. E.g. squared Euclidean.
Specified by:
isSquared in interface DistanceFunction<NumberVector>
Overrides:
isSquared in class TriangularDiscriminationDistanceFunction
Returns:
true when squared.
• #### isMetric

public boolean isMetric()
Description copied from interface: DistanceFunction
Is this distance function metric (satisfy the triangle inequality)
Returns:
true when metric.
• #### toString

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

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

public int hashCode()
Overrides:
hashCode in class TriangularDiscriminationDistanceFunction