 ##  [Hamming Distance](/hamming-distance-0) 

 Definition

A metric on fixed-length strings over a finite alphabet defined as the number of coordinate positions at which two strings differ.

 

 

 

 

 

 





## Principle

Principle

Count symbol-wise mismatches position-by-position; the Hamming distance satisfies nonnegativity, symmetry, and the triangle inequality on the discrete product space.

 

 

 

 

 





## Demonstration

Demonstration

In a binary block code of length n, the minimum Hamming distance d between codewords determines error capabilities: up to ⌊(d−1)/2⌋ bit flips can be corrected and up to d−1 flips detected.

 

 

 

 

## Misapplication

Misapplication

Applying Hamming distance directly to sequences of unequal length or to real-valued vectors without discretization or a threshold yields misleading or undefined comparisons.

 

 

 

 

 





## Consequence

Consequence

Provides a simple, combinatorial measure for error detection/correction design, nearest-neighbour decoding, and discrete metric-space analyses in information theory and coding.

 

 

 

 

## Reversal

Reversal

Edit (Levenshtein) distance, which counts insertions and deletions as well as substitutions, differs when sequence length can change and thus captures a different error model.

 

 

 

 

 





## Boundary

Boundary

Defined only for sequences of equal length over a discrete alphabet; weighted Hamming variants or generalized symbol metrics extend the concept but change properties like isometry classes.

 

 

 

 

 





## Semantic Tension

Semantic Tension

Often contrasted with Euclidean distance on vector spaces: Hamming counts mismatches irrespective of magnitude, while Euclidean measures numeric difference magnitudes and requires numeric alphabets.

 

 

 

 

 





## Synthesis

Synthesis

Hamming distance is the coordinatewise mismatch count between fixed-length discrete sequences; it is a fundamental combinatorial metric that underpins error-control codes and nearest-neighbour methods.