Hamming Distance
Updated 2026-07-28
Summary
In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. In other words, it measures the minimum number of substitutions required to change one string into the other. The Hamming weight is the Hamming distance between a string and the zero string of the same length, that is, the number of non-zero elements in the string: for binary strings, it is the number of 1s, so the Hamming weight of 11101 is 4.
Definition
In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. In other words, it measures the minimum number of substitutions required to change one string into the other. The Hamming weight is the Hamming distance between a string and the zero string of the same length, that is, the number of non-zero elements in the string: for binary strings, it is the number of 1s, so the Hamming weight of 11101 is 4.
Introduction
How to use
In information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. In other words, it measures the minimum number of substitutions required to change one string into the other. The Hamming weight is the Hamming distance between a string and the zero string of the same length, that is, the number of non-zero elements in the string: for binary strings, it is the number of 1s, so the Hamming weight of 11101 is 4.
Mechanism
For two strings of equal length, count the number of positions where they differ; this count is the distance. A code with minimum distance d can detect up to d-1 errors and correct up to floor((d-1)/2) errors. It quantifies "difference" as the minimum number of flips required, forming the geometric basis for error-correcting code design.
Practice
In progress 0/1Practice this model in one real situation:
Cases
- "1011101" and "1001001" have a distance of 2; in communication, choose codewords with large distances to resist interference; when comparing two theories, count the number of fundamental propositions that contradict each other.
Common pitfalls
- Only applicable to strings of equal length; direct comparison of unequal lengths or without alignment can be misleading; or confusing it with "edit distance" (which allows insertions and deletions).
Sources
Source support: Explicit
References currently contain only Wikipedia links; primary sources still need review.
- zh.wikipedia.orghttps://zh.wikipedia.org/wiki/%E6%B1%89%E6%98%8E%E8%B7%9D%E7%A6%BBverified
account_treeGenealogyexpand_more
PRIVATE NOTES · Only visible to you
SAVED Q&A
ENTRY Q&A · Private saving available
Ask with a clear boundary
thinkingmodels answers from published entry context only.
Your question is sent to thinkingmodels. The answer uses public entry context only.
RELATED MODELS