3 ms·
What's the difference between Levenshtein distance and Hamming distance?
by jorblumesea 7y ago
What's the difference between Levenshtein distance and Hamming distance?
- grzm 7y agohttps://en.wikipedia.org/wiki/Edit_distance#Formal_definition_and_properties https://en.wikipedia.org/wiki/Edit_distance#Formal_definitio... > Given two strings a and b on an alphabet Σ (e.g. the set of ASCII characters, the set of bytes [0..255], etc.), the edit distance d(a, b) is the minimum-weight series of edit operations that transforms a into b. One of the simplest sets of edit operations is that defined by Levenshtein in 1966 Insertion of a single symbol. If a = uv, then inserting the symbol x produces uxv. This can also be denoted ε→x, using ε to denote the empty string. Deletion of a single symbol changes uxv to uv (x→ε). Substitution of a single symbol x for a symbol y ≠ x changes uxv to uyv (x→y). ... > Other variants of edit distance are obtained by restricting the set of operations. Longest common subsequence (LCS) distance is edit distance with insertion and deletion as the only two edit operations, both at unit cost. Similarly, by only allowing substitutions (again at unit cost), Hamming distance is obtained; this must be restricted to equal-length strings.