Hamming distance is usually thought of as a form of edit distance where only substitutions are permitted. However, it has a more generalized framing as the number of positions whose corresponding values differ between two multidimensional entities.
Consider two vectors
where
Obviously, this function is not well-defined when
When comparisons must be made between sequences of mismatched length, it is typically preferred to use a measure that can accommodate this mismatch, such as the Levenshtein distance. In practice, however, there may be applications where it is desirable to pad the shorter sequence with a null symbol, such that the missing positions are treated as substitutions.