1

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?

Nasser
  • 2,118
  • 6
  • 33
  • 56

1 Answers1

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