It is known that the hamming distance is applied to calculate the difference between two binary strings. Is it possible to apply it to calculate the difference between non-binary structures?
Asked
Active
Viewed 1,286 times
1
-
1You can always cast non-binary into binary – Piotr Kamoda Feb 20 '17 at 13:53
-
2Also [this is hamming generalisation algorithm](https://en.wikipedia.org/wiki/Levenshtein_distance) called Levenshtein – Piotr Kamoda Feb 20 '17 at 13:55
-
It depends on a *particular* problem. If you can determine and specify how to calculate the difference between two objects then you obviously can compute a Hamming distance between them. – Yuriy Ivaskevych Feb 20 '17 at 13:58
1 Answers
0
The Hamming distance of two strings of the same length is the sum of the distance between each pair of corresponding bits (i.e., L1), where the latter distance is 0 for identical bits and 1 for nonidentical bits, (i.e., the discrete metric). If you want to apply Hamming distance to alphabets that are not binary, you can replace the discrete metric with another metric of your choice, e.g., Lee distance is the distance between two numbers on a circle. If the strings have different lengths, then you have to change to something like Levenshtein distance, but even there, you can choose whatever deletion/insertion/substitution costs you want.

David Eisenstat
- 64,237
- 7
- 60
- 120