Distance enum

A type of vector distance

Actually, it's a measure of similarity of two vectors: the greater the distance, the less similar the vectors are and vice versa

Distance.euclidean Distance, calculated according to the formula:

[D = \sqrt{\sum_{i = 1}^{n}(A_{i} - B_{i})^{2}}]

Distance.manhattan Distance, as known as Taxicab distance. It's calculated according to the formula:

[D = \sum_{i = 1}^{n}\left |A_{i} - B_{i} \right |]

Distance.cosine Distance, based on vector orientation, or rather on cosine of the angle between two vectors: the more the angle, the less similar the vectors are. It's calculated according to the formula:

[D = 1 - cos(\theta ) = 1 - \frac{A\cdot B}{\left | A \right |\left | B \right |}]

A case, when two vectors have the greatest similarity according to this distance, is when the angle between them is equal to 0 degrees. The angle's cosine in this case is equal to 1.

This distance is good for determining similarity of 2 sparse vectors (a case, when vector norms are disparate)

Distance.hamming Distance, calculated according to the formula:

[D = \sum_{i = 1}^{n} A_{i} \neq B_{i}]

In other words, the distance is calculated based on a number of elements whose values are different: the more the number, the less similar the vectors are





euclidean → const Distance
manhattan → const Distance
cosine → const Distance
hamming → const Distance


hashCode int
The hash code for this object.
no setterinherited
index int
A numeric identifier for the enumerated value.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
toString() String
A string representation of this object.


operator ==(Object other) bool
The equality operator.


values → const List<Distance>
A constant List of the values in this enum, in order of their declaration.