You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-9Lines changed: 13 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,9 @@ This package also provides optimized functions to compute column-wise and pairwi
14
14
15
15
* Euclidean distance
16
16
* Squared Euclidean distance
17
-
* Cityblock distance
17
+
* Cityblock distance
18
+
* Jaccard distance
19
+
* Rogers-Tanimoto distance
18
20
* Chebyshev distance
19
21
* Minkowski distance
20
22
* Hamming distance
@@ -47,7 +49,7 @@ Here, dist is an instance of a distance type. For example, the type for Euclidea
47
49
48
50
```julia
49
51
r =evaluate(Euclidean(), x, y)
50
-
```
52
+
```
51
53
52
54
Common distances also come with convenient functions for distance evaluation. For example, you may also compute Euclidean distance between two vectors as below
53
55
@@ -103,36 +105,38 @@ Please pay attention to the difference, the functions for inplace computation ar
103
105
104
106
## Distance type hierarchy
105
107
106
-
The distances are organized into a type hierarchy.
108
+
The distances are organized into a type hierarchy.
107
109
108
110
At the top of this hierarchy is an abstract class **PreMetric**, which is defined to be a function ``d`` that satisfies
109
111
110
112
d(x, x) == 0 for all x
111
113
d(x, y) >= 0 for all x, y
112
-
114
+
113
115
**SemiMetric** is a abstract type that refines **PreMetric**. Formally, a *semi-metric* is a *pre-metric* that is also symmetric, as
114
116
115
117
d(x, y) == d(y, x) for all x, y
116
-
118
+
117
119
**Metric** is a abstract type that further refines **SemiMetric**. Formally, a *metric* is a *semi-metric* that also satisfies triangle inequality, as
118
120
119
121
d(x, z) <= d(x, y) + d(y, z) for all x, y, z
120
-
122
+
121
123
This type system has practical significance. For example, when computing pairwise distances between a set of vectors, you may only perform computation for half of the pairs, and derive the values immediately for the remaining halve by leveraging the symmetry of *semi-metrics*.
122
124
123
125
Each distance corresponds to a distance type. The type name and the corresponding mathematical definitions of the distances are listed in the following table.
124
126
125
-
| type name | convenient syntax | math definition |
127
+
| type name | convenient syntax | math definition |
**Note:** The formulas above are using *Julia*'s functions. These formulas are mainly for conveying the math concepts in a concise way. The actual implementation may use a faster way.
0 commit comments