Hamming distance Hamming distance

Source: Internet
Author: User

Carefully read the code of the Orb, found that there are a lot of details are not very clear, in which the use of violence to test the distance of keypoints, with the Hamminglut, the Internet to find out only know, Hamming distance is the difference between the number of digits. That's a good idea.

I understand the hamminglut lut;

Result=lut ((a), (b), size_t size): Hamming distance+size of Result=a and B;

[CPP]View PlainCopyprint?
  1. unsigned int hamdist (unsigned int x, unsigned int y)
  2. {
  3. unsigned int dist = 0, val = x ^ y;
  4. //Count The number of the set bits
  5. While (Val)
  6. {
  7. ++dist;
  8. Val &= val-1;
  9. }
  10. return dist;
  11. }
  12. unsigned int hamdist2 (unsigned char* A, unsigned char* B, size_t size)
  13. {
  14. Hamminglut Lut;
  15. unsigned int result;
  16. result = Lut ((a), (b), size);
  17. return result;
  18. }


In information theory, the Hamming distance, named after Richard Hamming, was the number of positions in both strings of equ Al length for which the corresponding elements is different. Put Another, it measures the number of substitutions required to change one into the other.
Hamming distance is named after the name of Richard Wesley Hamming. In information theory, the Hamming distance between two equal-length strings is the number of different characters in the corresponding position of two strings. In other words, it is the number of characters that need to be replaced to transform a string into another string.
For example:
For example:
The Hamming distance between 1011101 and 1001001 is 2.
The Hamming distance between 2143896 and 2233796 is 3.
The Hamming distance between "toned" and "Roses" is 3.
The Hamming distance between 1011101 and 1001001 is 2.
The Hamming distance between 2143896 and 2233796 is 3.
The Hamming distance between "toned" and "Roses" is 3.
The Hamming weight of a string is it Hamming distance from the zero string (string consisting of all zeros) of the same L Ength. That's, it's the number of elements in the string which was not zero:for a binary string This is just the number of 1 ' s , so for instance the Hamming weight of 11101 is 4.
Hamming weight is the Hamming distance of a string of 0 strings relative to the same length, that is, it is the number of elements that are nonzero in the string: for a binary string, it is the number of 1, so 11101 of the Hamming weight is 4.
The Hamming distance between, words A and B, viewed as elements of a vector space, can then be seen as the Hamming Weig HT of a-B. If A and B are binary strings this is equivalent to a+b and to a XOR B. The Hamming distance is also equivalent to the Manhattan distance between both vertices in an n-dimensional hypercube, wher e n is the length of the words.
If A and b two words are considered to be elements in the vector space, the Hamming distance between them is equal to the difference of their hamming weights. If binary strings A and B, the Hamming distance equals their hamming weight and a+b or A and b hamming weight xor B. The Hamming distance is also equal to the Manhattan distance between two vertices on an n-dimensional hypercube, and n refers to the length of the word.
The Hamming distance is used in telecommunication to count the number of flipped bits in a fixed-length binary word, an ES Timate of error, and so is sometimes called the signal distance. Hamming weight analysis of bits was used in several disciplines including information theory, coding theory, and Cryptograp Hy. For comparing strings of different lengths, or strings where insertions or deletions is expected, not just substitutions, A more sophisticated metric like the Levenshtein distance are more appropriate.
Hamming distance can be accumulated in the communication of the fixed-length binary word in the inverted error data bits, so it is also known as the signal distance. Hamming weight analysis has been applied in the fields including information theory, coding theory and cryptography. However, if you want to compare two strings of different lengths, not only to replace them, but also to insert and delete operations, in this case, more complex editing distances and other algorithms are often used.

from:http://blog.csdn.net/yangtrees/article/details/7543553

Hamming distance Hamming distance

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.