How To Calculate Hamming Distance

Today, almost every aspect of modern life involves the transfer of digital information, either between individual people or between individual servers or systems. When you manage your bank accounts online, update your social media pages or even play a DVD with a DVD player connected to your television, information moves from one place to another digitally, either through a cord or over a wireless signal. For this information to pass from one location to another, it has to be transferred through computer code. In this "language," information moves via a combination of 1's and 0's, known as binary code. An error in the binary code moving from one system to another can mean that information is not conveyed properly, which could cause lots of issues for the computer user. Hamming distance is a way of understanding how codes differ. This can then be used to correct errors.

Advertisement

TL;DR (Too Long; Didn't Read)

Hamming distance refers to the number of points at which two lines of binary code differ, determined by simply adding up the number of spots where two lines of code differ. For example, the distance between the two codewords 10101010 and 01011010 is four: while this may not mean much without context, this could mean that at four points, errors in code have resulted in an audio file failing to play properly, the visuals on a television displaying incorrectly, or a critical computer function being misinterpreted.

What Is Hamming Distance?

The Hamming distance of two given lines of code is the number of points at which the lines' binary code values are different (assuming that the two lines of code are the same length). This can be a bit confusing to understand at first pass, so consider this simple example: A one-word text message is sent from phone A to phone B. When translated to binary code, the line of code representing the text message on phone A reads "101" and on phone B the line of code reads "010." Comparing these lines, you can see that there are different symbols in each of the three spots. This may be a sign that the message was not sent properly.

Advertisement

How To Calculate Hamming Distance

In simple scenarios, calculating Hamming distance is easy, though it's important to remember that Hamming distance can only be calculated for lines that are the same length. You simply add up the number of spots where the lines have different values. In the example above, the Hamming distance would be three, since the lines have different values in three spots. Making this comparison becomes more time-consuming the longer the line of binary code is, however. Consider a slightly longer example, with two lines of code: 100110 and 110011. These lines of code both contain six information points. The values are different in three of those points, so the Hamming distance between these two lines is also three. Calculating Hamming distance with a larger set of data becomes more complicated and involves using intricate equations and functions like d=min {d(x,y):x,y∈C,x≠y}.

Advertisement

Why Is Hamming Distance Useful?

Out of context, Hamming distance can seem arbitrary. However, it's an important measurement for coders. Hamming distance can help coders write code that detects errors and even corrects those errors on its own. It can also help people understand how error-prone a code is. Hamming distance is named after Richard Wesley Hamming, who developed the measurement in the late 1940s when he was working at Bell Telephone Laboratories. Although Hamming downplayed the celebration of the innovation, the technology industry took notice and used it to great effect when troubleshooting code. Nearly 50 years after Hamming discovered the measurement, he was given the Eduard Rheim Award for Achievement in Technology by the Eduard Rheim Foundation of Germany in 1996. In addition, the I.E.E.E., a large professional organization in the technology sector, gives out the annual Richard W. Hamming Medal in his honor.

Advertisement

Cite This Article

MLA

Burch, Kelly. "How To Calculate Hamming Distance" sciencing.com, https://www.sciencing.com/how-to-calculate-hamming-distance-12751770/. 24 October 2018.

APA

Burch, Kelly. (2018, October 24). How To Calculate Hamming Distance. sciencing.com. Retrieved from https://www.sciencing.com/how-to-calculate-hamming-distance-12751770/

Chicago

Burch, Kelly. How To Calculate Hamming Distance last modified March 24, 2022. https://www.sciencing.com/how-to-calculate-hamming-distance-12751770/

Recommended

Advertisement