Skip to content

Commit

Permalink
fix typo in weighted distances
Browse files Browse the repository at this point in the history
fixes #38
  • Loading branch information
KristofferC committed Feb 19, 2016
1 parent 1872573 commit 73e644c
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,31 +123,31 @@ This type system has practical significance. For example, when computing pairwis

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

| type name | convenient syntax | math definition |
| -------------------- | -------------------- | --------------------|
| Euclidean | euclidean(x, y) | sqrt(sum((x - y) .^ 2)) |
| SqEuclidean | sqeuclidean(x, y) | sum((x - y).^2) |
| Cityblock | cityblock(x, y) | sum(abs(x - y)) |
| Chebyshev | chebyshev(x, y) | max(abs(x - y)) |
| Minkowski | minkowski(x, y, p) | sum(abs(x - y).^p) ^ (1/p) |
| Hamming | hamming(x, y) | sum(x .!= y) |
| 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)) |
| Jaccard | jaccard(x, y) | 1 - sum(min(x, y)) / sum(max(x, y)) |
| CosineDist | cosine_dist(x, y) | 1 - dot(x, y) / (norm(x) * norm(y)) |
| CorrDist | corr_dist(x, y) | cosine_dist(x - mean(x), y - mean(y)) |
| ChiSqDist | chisq_dist(x, y) | sum((x - y).^2 / (x + y)) |
| KLDivergence | kl_divergence(x, y) | sum(p .* log(p ./ q)) |
| JSDivergence | js_divergence(x, y) | KL(x, m) / 2 + KL(y, m) / 2 with m = (x + y) / 2 |
| SpanNormDist | spannorm_dist(x, y) | max(x - y) - min(x - y ) |
| BhattacharyyaDist | bhattacharyya(x, y) | -log(sum(sqrt(x .* y) / sqrt(sum(x) * sum(y))) |
| HellingerDist | hellinger(x, y) | sqrt(1 - sum(sqrt(x .* y) / sqrt(sum(x) * sum(y)))) |
| type name | convenient syntax | math definition |
| -------------------- | ------------------------ | --------------------|
| Euclidean | euclidean(x, y) | sqrt(sum((x - y) .^ 2)) |
| SqEuclidean | sqeuclidean(x, y) | sum((x - y).^2) |
| Cityblock | cityblock(x, y) | sum(abs(x - y)) |
| Chebyshev | chebyshev(x, y) | max(abs(x - y)) |
| Minkowski | minkowski(x, y, p) | sum(abs(x - y).^p) ^ (1/p) |
| Hamming | hamming(x, y) | sum(x .!= y) |
| 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)) |
| Jaccard | jaccard(x, y) | 1 - sum(min(x, y)) / sum(max(x, y)) |
| CosineDist | cosine_dist(x, y) | 1 - dot(x, y) / (norm(x) * norm(y)) |
| CorrDist | corr_dist(x, y) | cosine_dist(x - mean(x), y - mean(y)) |
| ChiSqDist | chisq_dist(x, y) | sum((x - y).^2 / (x + y)) |
| KLDivergence | kl_divergence(x, y) | sum(p .* log(p ./ q)) |
| JSDivergence | js_divergence(x, y) | KL(x, m) / 2 + KL(y, m) / 2 with m = (x + y) / 2 |
| SpanNormDist | spannorm_dist(x, y) | max(x - y) - min(x - y ) |
| BhattacharyyaDist | bhattacharyya(x, y) | -log(sum(sqrt(x .* y) / sqrt(sum(x) * sum(y))) |
| HellingerDist | hellinger(x, y) | sqrt(1 - sum(sqrt(x .* y) / sqrt(sum(x) * sum(y)))) |
| Mahalanobis | mahalanobis(x, y, Q) | sqrt((x - y)' * Q * (x - y)) |
| SqMahalanobis | sqmahalanobis(x, y, Q) | (x - y)' * Q * (x - y) |
| WeightedEuclidean | euclidean(x, y, w) | sqrt(sum((x - y).^2 .* w)) |
| WeightedSqEuclidean | sqeuclidean(x, y, w) | sum((x - y).^2 .* w) |
| WeightedCityblock | cityblock(x, y, w) | sum(abs(x - y) .* w) |
| WeightedMinkowski | minkowski(x, y, w, p) | sum(abs(x - y).^p .* w) ^ (1/p) |
| WeightedHamming | hamming(x, y, w) | sum((x .!= y) .* w) |
| WeightedEuclidean | weuclidean(x, y, w) | sqrt(sum((x - y).^2 .* w)) |
| WeightedSqEuclidean | wsqeuclidean(x, y, w) | sum((x - y).^2 .* w) |
| WeightedCityblock | wcityblock(x, y, w) | sum(abs(x - y) .* w) |
| WeightedMinkowski | wminkowski(x, y, w, p) | sum(abs(x - y).^p .* w) ^ (1/p) |
| WeightedHamming | whamming(x, y, w) | sum((x .!= y) .* w) |

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

Expand Down

0 comments on commit 73e644c

Please sign in to comment.