Skip to content

Commit 73e644c

Browse files
committed
fix typo in weighted distances
fixes #38
1 parent 1872573 commit 73e644c

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

README.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -123,31 +123,31 @@ This type system has practical significance. For example, when computing pairwis
123123

124124
Each distance corresponds to a distance type. The type name and the corresponding mathematical definitions of the distances are listed in the following table.
125125

126-
| type name | convenient syntax | math definition |
127-
| -------------------- | -------------------- | --------------------|
128-
| Euclidean | euclidean(x, y) | sqrt(sum((x - y) .^ 2)) |
129-
| SqEuclidean | sqeuclidean(x, y) | sum((x - y).^2) |
130-
| Cityblock | cityblock(x, y) | sum(abs(x - y)) |
131-
| Chebyshev | chebyshev(x, y) | max(abs(x - y)) |
132-
| Minkowski | minkowski(x, y, p) | sum(abs(x - y).^p) ^ (1/p) |
133-
| Hamming | hamming(x, y) | sum(x .!= y) |
134-
| Rogers-Tanimoto | rogerstanimoto(x, y)| 2(sum(x&!y) + sum(!x&y)) / (2(sum(x&!y) + sum(!x&y)) + sum(x&y) + sum(!x&!y)) |
135-
| Jaccard | jaccard(x, y) | 1 - sum(min(x, y)) / sum(max(x, y)) |
136-
| CosineDist | cosine_dist(x, y) | 1 - dot(x, y) / (norm(x) * norm(y)) |
137-
| CorrDist | corr_dist(x, y) | cosine_dist(x - mean(x), y - mean(y)) |
138-
| ChiSqDist | chisq_dist(x, y) | sum((x - y).^2 / (x + y)) |
139-
| KLDivergence | kl_divergence(x, y) | sum(p .* log(p ./ q)) |
140-
| JSDivergence | js_divergence(x, y) | KL(x, m) / 2 + KL(y, m) / 2 with m = (x + y) / 2 |
141-
| SpanNormDist | spannorm_dist(x, y) | max(x - y) - min(x - y ) |
142-
| BhattacharyyaDist | bhattacharyya(x, y) | -log(sum(sqrt(x .* y) / sqrt(sum(x) * sum(y))) |
143-
| HellingerDist | hellinger(x, y) | sqrt(1 - sum(sqrt(x .* y) / sqrt(sum(x) * sum(y)))) |
126+
| type name | convenient syntax | math definition |
127+
| -------------------- | ------------------------ | --------------------|
128+
| Euclidean | euclidean(x, y) | sqrt(sum((x - y) .^ 2)) |
129+
| SqEuclidean | sqeuclidean(x, y) | sum((x - y).^2) |
130+
| Cityblock | cityblock(x, y) | sum(abs(x - y)) |
131+
| Chebyshev | chebyshev(x, y) | max(abs(x - y)) |
132+
| Minkowski | minkowski(x, y, p) | sum(abs(x - y).^p) ^ (1/p) |
133+
| Hamming | hamming(x, y) | sum(x .!= y) |
134+
| Rogers-Tanimoto | rogerstanimoto(x, y) | 2(sum(x&!y) + sum(!x&y)) / (2(sum(x&!y) + sum(!x&y)) + sum(x&y) + sum(!x&!y)) |
135+
| Jaccard | jaccard(x, y) | 1 - sum(min(x, y)) / sum(max(x, y)) |
136+
| CosineDist | cosine_dist(x, y) | 1 - dot(x, y) / (norm(x) * norm(y)) |
137+
| CorrDist | corr_dist(x, y) | cosine_dist(x - mean(x), y - mean(y)) |
138+
| ChiSqDist | chisq_dist(x, y) | sum((x - y).^2 / (x + y)) |
139+
| KLDivergence | kl_divergence(x, y) | sum(p .* log(p ./ q)) |
140+
| JSDivergence | js_divergence(x, y) | KL(x, m) / 2 + KL(y, m) / 2 with m = (x + y) / 2 |
141+
| SpanNormDist | spannorm_dist(x, y) | max(x - y) - min(x - y ) |
142+
| BhattacharyyaDist | bhattacharyya(x, y) | -log(sum(sqrt(x .* y) / sqrt(sum(x) * sum(y))) |
143+
| HellingerDist | hellinger(x, y) | sqrt(1 - sum(sqrt(x .* y) / sqrt(sum(x) * sum(y)))) |
144144
| Mahalanobis | mahalanobis(x, y, Q) | sqrt((x - y)' * Q * (x - y)) |
145145
| SqMahalanobis | sqmahalanobis(x, y, Q) | (x - y)' * Q * (x - y) |
146-
| WeightedEuclidean | euclidean(x, y, w) | sqrt(sum((x - y).^2 .* w)) |
147-
| WeightedSqEuclidean | sqeuclidean(x, y, w) | sum((x - y).^2 .* w) |
148-
| WeightedCityblock | cityblock(x, y, w) | sum(abs(x - y) .* w) |
149-
| WeightedMinkowski | minkowski(x, y, w, p) | sum(abs(x - y).^p .* w) ^ (1/p) |
150-
| WeightedHamming | hamming(x, y, w) | sum((x .!= y) .* w) |
146+
| WeightedEuclidean | weuclidean(x, y, w) | sqrt(sum((x - y).^2 .* w)) |
147+
| WeightedSqEuclidean | wsqeuclidean(x, y, w) | sum((x - y).^2 .* w) |
148+
| WeightedCityblock | wcityblock(x, y, w) | sum(abs(x - y) .* w) |
149+
| WeightedMinkowski | wminkowski(x, y, w, p) | sum(abs(x - y).^p .* w) ^ (1/p) |
150+
| WeightedHamming | whamming(x, y, w) | sum((x .!= y) .* w) |
151151

152152
**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.
153153

0 commit comments

Comments
 (0)