MAT 1000 Mathematics in Today's World Winter 2015
Last Time Identification numbers often include check digits: extra digits that allow us to catch errors. There are several different methods for finding check digits used in practice. We looked at sytems which are used for UPC codes, credit card numbers, and ISBNs as well as bar codes.
Today Binary codes are strings consisting of either 0s or 1s. We will look at a specific way to encode binary messages using Venn diagrams Then we consider a more general method, called “parity check sums”
Binary codes Binary codes are messages which are represented using only the digits 0 and 1. Some examples of binary codes of length three are 101, or 110, or 000 Computers use binary codes internally.
Binary codes We can append extra digits to binary codes to help catch errors. In fact, we can either identify where the error occurs, or we can fix the error. This requires appending more than a single digit.
Binary codes One advantage to binary codes: each position is either a 1 or a 0, so there are only two possible errors: 0 can be received as 1 1 can be received as 0
Venn diagram encoding If our binary codes have length 4, there is an encoding/decoding system which uses Venn diagrams. Use three circles in the following configuration:
Venn diagram encoding Note that we have four sections of overlap: Our four digit binary message will be placed in these 4 spaces, in this order. Then we append three digits, based on the other 3 spaces.
Venn diagram encoding Example Let’s encode the message 1011 First, fill in the numbered spaces in the Venn diagram using the digits of the message, in order: 1 st digit in the 1 st space, 2 nd digit in the second space, and so on.
Venn diagram encoding Example We have three more spaces to fill: We will put either a 1 or a 0 in each of these.
Venn diagram encoding Example To decide whether to put in a 0 or a 1, we choose whichever makes the total number of 1s in each circle even: Adding these three extra digits (in order) gives
Venn diagram encoding Example Now we will see how to correct errors using this method. Suppose our message is mistakenly received as When we fill in the Venn diagram, we can see there is a mistake because some of the circles have an odd number of 1s in them.
Venn diagram encoding Example The upper left circle has an even number of 1s:
Venn diagram encoding Example But the other two circles both have an odd number of 1s:
Venn diagram encoding Example But the other two circles both have an odd number of 1s:
Venn diagram encoding Example Which digit is incorrect? The incorrect digit must appear in both of the circles with an odd number of 1s, but it is not in the circle with the correct number of 1s. This tells us exactly where the error must be:
Venn diagram encoding Example Moreover, once we know the location of the error, we can fix it. After all, this is a binary code: if 0 is not the correct digit, then 1 must be. Fixing the mistake recovers our original message:
Venn diagram encoding Some disadvantages of this method: Only works on messages of length four If there are two or more errors, they may go undetected, or they may be fixed incorrectly Let’s see an example that shows how two errors can be fixed incorrectly.
Venn diagram encoding Example The original message is Encode this message. So the encoded message is:
Venn diagram encoding Example Suppose the message is received with two errors as What happens when we decode this message?
Venn diagram encoding Example The two upper circles have an odd number of 1s in them, but the lower circle has an even number of 1s. So the method tells us there is an error in this place:
Venn diagram encoding Example This gives the “corrected” message Of course this is not actually the correct message. That was So this method may fail when there are two or more errors in the message.
Parity Check Sums Here are some possible improvements on the Venn diagram method: 1.Longer messages 2.Correct more errors To describe these improved methods, we need to look at the Venn diagram method in a different way, using “parity check sums”
Parity Check Sums
If you compare this method with the Venn diagram method we used earlier, you will see that they are identical (for any four digit message they give the same code) The advantage of parity check sums over Venn diagrams is that we have more flexibility: we can now work with longer messages we can add more digits (which can catch more errors)
Parity Check Sums
If we encode a message with parity check sums, how should we decode it? The method used is called “nearest neighbor” decoding. To use this, we have to discuss the “distance” between binary strings.
Parity Check Sums The distance between two binary strings is the number of places in which they differ. Example: and have a distance of 1 Example: and have a distance of 3 Example: and have a distance of 0 Note if two strings have different lengths, it doesn’t make sense to talk about their distance. The distance between and doesn’t make sense
Parity Check Sums Nearest neighbor decoding: Receive an encoded message, which may have some errors. Find the nearest correct message (meaning the one which is the smallest distance from the received message). Do not decode if there is a tie.
Parity Check Sums In order to use nearest neighbor decoding, we need to make a list of every possible correct message. In the next example, we will take a parity check sum method, list every possible correct message, and then use that list to decode a message.
Parity Check Sums Messages Coded Messages
Parity Check Sums Example Decode the message We will find the distance from this message to each valid message: The message is decoded to be Distance Coded Messages
Parity Check Sums We have lots of choice for different parity check sums. How many should we use? Which ones should we use? We will see next time how to analyze different choices of parity check sums.