Advanced handouts
Add missing file Co-authored-by: Mark <mark@betalupi.com> Co-committed-by: Mark <mark@betalupi.com>
This commit is contained in:
140
src/Advanced/Error-Correcting Codes/parts/00 detection.tex
Executable file
140
src/Advanced/Error-Correcting Codes/parts/00 detection.tex
Executable file
@ -0,0 +1,140 @@
|
||||
\section{Error Detection}
|
||||
|
||||
An ISBN\footnote{International Standard Book Number} is a unique numeric book identifier. It comes in two forms: ISBN-10 and ISBN-13. Naturally, ISBN-10s have ten digits, and ISBN-13s have thirteen. The final digit in both versions is a \textit{check digit}.
|
||||
|
||||
\vspace{3mm}
|
||||
|
||||
Say we have a sequence of nine digits, forming a partial ISBN-10: $n_1 n_2 ... n_9$. \par
|
||||
The final digit, $n_{10}$, is chosen from $\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\}$ so that:
|
||||
|
||||
$$
|
||||
\sum_{i = 1}^{10} (11 - i)n_i \equiv 0 \text{ mod } 11
|
||||
$$
|
||||
|
||||
If $n_{10}$ is equal to 10, it is written as \texttt{X}.
|
||||
|
||||
|
||||
\problem{}
|
||||
Only one of the following ISBNs is valid. Which one is it?
|
||||
|
||||
\begin{itemize}
|
||||
\item \texttt{0-134-54896-2}
|
||||
\item \texttt{0-895-77258-2}
|
||||
\end{itemize}
|
||||
|
||||
\begin{solution}
|
||||
The first has an inconsistent check digit.
|
||||
\end{solution}
|
||||
|
||||
\vfill
|
||||
\pagebreak
|
||||
|
||||
\problem{}
|
||||
Take a valid ISBN-10 and change one digit. Is it possible that you get another valid ISBN-10? \par
|
||||
Provide a proof.
|
||||
|
||||
\begin{solution}
|
||||
Let $S$ be the sum $10n_1 + 9n_2 + ... + 2n_9 + n_{10}$, before any digits are changed.
|
||||
|
||||
\vspace{3mm}
|
||||
|
||||
If you change one digit of the ISBN, $S$ changes by $km$, where $k \in \{1,2,...,10\}$ and $|m| \leq 10$. \par
|
||||
$k$ and $m$ cannot be divisible by 11, thus $km$ cannot be divisible by 11.
|
||||
|
||||
\vspace{3mm}
|
||||
|
||||
We know that $S \equiv 0 \text{ (mod 11)}$. \par
|
||||
After the change, the checksum is $S + km \equiv km \not\equiv 0 \text{ (mod 11)}$.
|
||||
\end{solution}
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
Take a valid ISBN-10 and swap two adjacent digits. When will the result be a valid ISBN-10? \par
|
||||
This is called a \textit{transposition error}.
|
||||
|
||||
|
||||
\begin{solution}
|
||||
Let $n_1n_2...n_{10}$ be a valid ISBN-10. \par
|
||||
When we swap $n_i$ and $n_{i+1}$, we subtract $n_i$ and add $n_{i+1}$ to the checksum.
|
||||
|
||||
\vspace{3mm}
|
||||
|
||||
If the new ISBN is to be valid, we must have that $n_{i+1} - n_i \equiv 0 \text{ (mod 11)}$. \par
|
||||
This is impossible unless $n_i = n_{i+1}$. Figure out why yourself.
|
||||
\end{solution}
|
||||
|
||||
\vfill
|
||||
\pagebreak
|
||||
|
||||
\problem{}
|
||||
ISBN-13 error checking is slightly different. Given a partial ISBN-13 $n_1 n_2 n_3 ... n_{12}$, the final digit is given by
|
||||
|
||||
$$
|
||||
n_{13} = \Biggr[ \sum_{i=1}^{12} n_i \times (2 + (-1)^i) \Biggl] \text{ mod } 10
|
||||
$$
|
||||
|
||||
What is the last digit of the following ISBN-13? \par
|
||||
\texttt{978-0-380-97726-?}
|
||||
|
||||
\begin{solution}
|
||||
The final digit is 0.
|
||||
\end{solution}
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
Take a valid ISBN-13 and change one digit. Is it possible that you get another valid ISBN-13? \par
|
||||
If you can, provide an example; if you can't, provide a proof.
|
||||
|
||||
\begin{solution}
|
||||
Let $n_1n_2...n_{13}$ be a valid ISBN-13. Choose some $n_i$ and change it to $m_i$. \par
|
||||
|
||||
\vspace{3mm}
|
||||
|
||||
Since $n_i$, $m_i$ $\in \{0, 1, 2, ..., 9\}$, $-9 \leq n_i - m_i \leq 9$. \par
|
||||
|
||||
\vspace{2mm}
|
||||
|
||||
Case 0: $i$ is 13 \par
|
||||
This is trivial.
|
||||
|
||||
\vspace{2mm}
|
||||
|
||||
Case 1: $i$ is odd \par
|
||||
For the new ISBN to be valid, we need $n_i - m_i \equiv 0 \text{ (mod 10)}$. \par
|
||||
This cannot happen if $n_i \neq m_i$.
|
||||
|
||||
\vspace{2mm}
|
||||
|
||||
Case 2: $i$ is even \par
|
||||
For the new ISBN to be valid, we need $3(n_i - m_i) \equiv 0 \text{ (mod 10)}$ \par
|
||||
This cannot happen, 10 and 3 are coprime.
|
||||
\end{solution}
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
Take a valid ISBN-13 and swap two adjacent digits. When will the result be a valid ISBN-13? \par
|
||||
\hint{The answer here is more interesting than it was last time.}
|
||||
|
||||
\begin{solution}
|
||||
Say we swap $n_i$ and $n_{i+1}$, where $i \in \{1, 2, ..., 11\}$. \par
|
||||
The checksum changes by $2(n_{i+1} - n_i)$, and will \par
|
||||
remain the same if this value is $\equiv 0 \text{ (mod 10)}$.
|
||||
\end{solution}
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}<isbn-nocorrect>
|
||||
\texttt{978-0-08-2066-46-6} was a valid ISBN until I changed a single digit. \par
|
||||
Can you find the digit I changed? Can you recover the original ISBN?
|
||||
|
||||
\begin{solution}
|
||||
Nope, unless you look at the meaning of each digit in the spec. \par
|
||||
If you're unlucky, maybe not even then.
|
||||
\end{solution}
|
||||
|
||||
|
||||
\vfill
|
||||
\pagebreak
|
134
src/Advanced/Error-Correcting Codes/parts/01 correction.tex
Normal file
134
src/Advanced/Error-Correcting Codes/parts/01 correction.tex
Normal file
@ -0,0 +1,134 @@
|
||||
\section{Error Correction}
|
||||
|
||||
As we saw in \ref{isbn-nocorrect}, the ISBN check-digit scheme does not allow us to correct errors. \par
|
||||
QR codes feature a system that does. \par
|
||||
|
||||
\vspace{1mm}
|
||||
|
||||
Odds are, you've seen a QR code with an image in the center. Such codes aren't \say{special}---they're simply missing their central pixels. The error-correcting algorithm in the QR specification allows us to read the code despite this damage.
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
\href{https://youtube.com/watch?v=dQw4w9WgXcQ}{\includegraphics[width = 3cm]{qr}}
|
||||
\end{figure}
|
||||
|
||||
\definition{Repeating codes}
|
||||
The simplest possible error-correcting code is a \textit{repeating code}. It works just as you'd expect: \par
|
||||
Instead of sending data once, it sends multiple copies of each bit. \par
|
||||
If a few bits are damaged, they can be both detected and repaired. \par
|
||||
|
||||
For example, consider the following three-repeat code encoding the binary string $101$:
|
||||
|
||||
$$
|
||||
111~000~111
|
||||
$$
|
||||
|
||||
If we flip any one bit, we can easily find and fix the error.
|
||||
|
||||
\problem{}<number-repeat>
|
||||
How many repeated digits do you need to...
|
||||
\begin{itemize}
|
||||
\item[-] detect a transposition error?
|
||||
\item[-] correct a transposition error?
|
||||
\end{itemize}
|
||||
|
||||
\vfill
|
||||
|
||||
|
||||
\definition{Code Efficiency}
|
||||
The efficiency of an error-correcting code is calculated as follows:
|
||||
$$
|
||||
\frac{\text{number of data bits}}{\text{total bits sent}}
|
||||
$$
|
||||
|
||||
For example, the efficiency of the three-repeat code above is $\frac{3}{9} = \frac{1}{3} \approx 0.33$
|
||||
|
||||
\problem{}<k-efficiency>
|
||||
What is the efficiency of a $k$-repeat code?
|
||||
|
||||
\vfill
|
||||
|
||||
As you just saw, repeat codes are not a good solution. You need many extra bits for even a small amount of redundancy. We need a better system.
|
||||
|
||||
\pagebreak
|
||||
|
||||
%\definition{Hamming's Square Code}
|
||||
%We will now analyze a more efficient coding scheme: \par
|
||||
%
|
||||
%\vspace{1mm}
|
||||
%
|
||||
%Take a four-bit message and arrange it in a $2 \times 2$ square. \par
|
||||
%Compute the pairity of each row and write it at the right. \par
|
||||
%Compute the pairity of each column and write it at the bottom. \par
|
||||
%Finally, compute the pairity of the entire message write it in the lower right corner.
|
||||
%This ensures that the total number of ones in the message is even.
|
||||
%
|
||||
%\vspace{2mm}
|
||||
%
|
||||
%Reading the result row by row to get the encoded message. \par
|
||||
%For example, the message 1011 generates the sequence 101110011:
|
||||
%
|
||||
%$$
|
||||
%1011
|
||||
%\longrightarrow
|
||||
%\begin{array}{cc|}
|
||||
% 1 & 0 \\
|
||||
% 1 & 1 \\
|
||||
% \hline
|
||||
%\end{array}
|
||||
%\longrightarrow
|
||||
%\begin{array}{cc|c}
|
||||
% 1 & 0 & 1 \\
|
||||
% 1 & 1 & 0 \\ \hline
|
||||
% 0 & 1 &
|
||||
%\end{array}
|
||||
%\longrightarrow
|
||||
%\begin{array}{cc|c}
|
||||
% 1 & 0 & 1 \\
|
||||
% 1 & 1 & 0 \\ \hline
|
||||
% 0 & 1 & 1
|
||||
%\end{array}
|
||||
%\longrightarrow
|
||||
%101110011
|
||||
%$$
|
||||
%
|
||||
%\problem{}
|
||||
%The following messages are encoded using the method above.
|
||||
%Find and correct any single-digit or transposition errors.
|
||||
%\begin{enumerate}
|
||||
% \item \texttt{110 110 011} %101110011
|
||||
% \item \texttt{100 101 011} %110101011
|
||||
% \item \texttt{001 010 110} %000110110
|
||||
%\end{enumerate}
|
||||
%
|
||||
%\begin{solution}
|
||||
% \begin{enumerate}
|
||||
% \item \texttt{101 110 011} or \texttt{110 101 011}
|
||||
% \item \texttt{110 101 011}
|
||||
% \item \texttt{000 110 110}
|
||||
% \end{enumerate}
|
||||
%\end{solution}
|
||||
%
|
||||
%\vfill
|
||||
%
|
||||
%\problem{}
|
||||
%What is the efficiency of this coding scheme?
|
||||
%
|
||||
%\vfill
|
||||
%
|
||||
%\problem{}
|
||||
%Can we correct a single-digit error in the encoded message? \par
|
||||
%Can we correct a transposition error in the encoded message?
|
||||
%
|
||||
%\vfill
|
||||
%
|
||||
%\problem{}
|
||||
%Let's generalize this coding scheme to a non-square table: \par
|
||||
%Given a message of length $ab$, construct a rectangle with dimensions $a \times b$ as described above.
|
||||
%\begin{itemize}
|
||||
% \item What is the efficiency of a $a \times b$ rectangle code?
|
||||
% \item Can the $a \times b$ rectangle code detect and fix single-bit errors?
|
||||
% \item Can the $a \times b$ rectangle code detect and fix two-bit errors?
|
||||
%\end{itemize}
|
||||
%
|
||||
%\vfill
|
||||
%\pagebreak
|
577
src/Advanced/Error-Correcting Codes/parts/02 hamming.tex
Normal file
577
src/Advanced/Error-Correcting Codes/parts/02 hamming.tex
Normal file
@ -0,0 +1,577 @@
|
||||
\section{Hamming Codes}
|
||||
|
||||
Say we have a 16-bit message, for example \texttt{1011 0101 1101 1001}. \par
|
||||
We will number its bits in binary, from left to right:
|
||||
|
||||
|
||||
\begin{center}
|
||||
\begin{tikzpicture}
|
||||
|
||||
\node[anchor=west] at (-1.75, 0) {Bit};
|
||||
\node[anchor=west] at (-1.75, -0.5) {Index};
|
||||
|
||||
\node at (0, 0) {\texttt{1}};
|
||||
\node at (1, 0) {\texttt{0}};
|
||||
\node at (2, 0) {\texttt{1}};
|
||||
\node at (3, 0) {\texttt{1}};
|
||||
\node at (4, 0) {\texttt{0}};
|
||||
\node at (5, 0) {\texttt{1}};
|
||||
\node at (6, 0) {\texttt{0}};
|
||||
\node at (7, 0) {\texttt{1}};
|
||||
|
||||
\draw (-1.75, 0.25) -- (6.9, 0.25);
|
||||
\draw (-1.75, -0.25) -- (6.9, -0.25);
|
||||
\draw (-1.75, -0.75) -- (6.9, -0.75);
|
||||
|
||||
\foreach \x in {-1.75,-0.5,0.5,...,6.5} {
|
||||
\draw (\x, 0.25) -- (\x, -0.75);
|
||||
}
|
||||
|
||||
\node[color=gray] at (0, -0.5) {\texttt{0000}};
|
||||
\node[color=gray] at (1, -0.5) {\texttt{0001}};
|
||||
\node[color=gray] at (2, -0.5) {\texttt{0010}};
|
||||
\node[color=gray] at (3, -0.5) {\texttt{0011}};
|
||||
\node[color=gray] at (4, -0.5) {\texttt{0100}};
|
||||
\node[color=gray] at (5, -0.5) {\texttt{0101}};
|
||||
\node[color=gray] at (6, -0.5) {\texttt{0110}};
|
||||
\node[color=gray] at (7, -0.5) {\texttt{0111}};
|
||||
|
||||
|
||||
\draw[fill = white, draw = none]
|
||||
(6.9, 0.25)
|
||||
-- (7.1, 0)
|
||||
-- (6.9, -0.25)
|
||||
-- (7.1, -0.5)
|
||||
-- (6.9, -0.75)
|
||||
-- (7.5, -0.75)
|
||||
-- (7.5, 0.25)
|
||||
;
|
||||
|
||||
\draw (6.9, 0.25)
|
||||
-- (7.1, 0)
|
||||
-- (6.9, -0.25)
|
||||
-- (7.1, -0.5)
|
||||
-- (6.9, -0.75)
|
||||
;
|
||||
|
||||
|
||||
\node[anchor=west,color=gray] at (7.2, -0.25) { and so on...};
|
||||
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
|
||||
\problem{}
|
||||
In this 16-bit message, how many message bits have an index with a one as the last digit? \par
|
||||
(i.e, an index that looks like \texttt{***1})
|
||||
|
||||
\vspace{2cm}
|
||||
|
||||
\problem{}
|
||||
Say we number the bits in a 32-bit message as above. \par
|
||||
How many message bits have an index with a one as the $n^\text{th}$ digit? \par
|
||||
|
||||
\vspace{2cm}
|
||||
|
||||
|
||||
|
||||
|
||||
We now want a way to detect errors in our 16-bit message. To do this, we'll replace a few data bits with parity bits. This will reduce the amount of information we can send, but will also improve our error-detection capabilities.
|
||||
|
||||
\vspace{1mm}
|
||||
|
||||
Let's arrange our message in a grid. We'll make the first bit (currently empty, marked \texttt{X}) a parity bit. Its value will depend on the content of the message: if our message has an even number of ones, it will be zero; if our message has an odd number of ones, it will be one. \par
|
||||
This first bit ensures that there is an even number of ones in the whole message.
|
||||
|
||||
\begin{center}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\node at (0.75, 0.5) {Bit Numbering};
|
||||
|
||||
\node at (0.0, 0) {\texttt{0}};
|
||||
\node at (0.5, 0) {\texttt{1}};
|
||||
\node at (1.0, 0) {\texttt{2}};
|
||||
\node at (1.5, 0) {\texttt{3}};
|
||||
|
||||
\node at (0.0, -0.5) {\texttt{4}};
|
||||
\node at (0.5, -0.5) {\texttt{5}};
|
||||
\node at (1.0, -0.5) {\texttt{6}};
|
||||
\node at (1.5, -0.5) {\texttt{7}};
|
||||
|
||||
\node at (0.0, -1) {\texttt{8}};
|
||||
\node at (0.5, -1) {\texttt{9}};
|
||||
\node at (1.0, -1) {\texttt{10}};
|
||||
\node at (1.5, -1) {\texttt{11}};
|
||||
|
||||
\node at (0.0, -1.5) {\texttt{12}};
|
||||
\node at (0.5, -1.5) {\texttt{13}};
|
||||
\node at (1.0, -1.5) {\texttt{14}};
|
||||
\node at (1.5, -1.5) {\texttt{15}};
|
||||
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
\end{tikzpicture}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\node at (0.75, 0.5) {Sample Message};
|
||||
|
||||
\node at (0.0, 0) {\texttt{X}};
|
||||
\node at (0.5, 0) {\texttt{0}};
|
||||
\node at (1.0, 0) {\texttt{1}};
|
||||
\node at (1.5, 0) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -0.5) {\texttt{0}};
|
||||
\node at (0.5, -0.5) {\texttt{1}};
|
||||
\node at (1.0, -0.5) {\texttt{0}};
|
||||
\node at (1.5, -0.5) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -1) {\texttt{1}};
|
||||
\node at (0.5, -1) {\texttt{1}};
|
||||
\node at (1.0, -1) {\texttt{0}};
|
||||
\node at (1.5, -1) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -1.5) {\texttt{1}};
|
||||
\node at (0.5, -1.5) {\texttt{0}};
|
||||
\node at (1.0, -1.5) {\texttt{0}};
|
||||
\node at (1.5, -1.5) {\texttt{1}};
|
||||
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.2,-0.2) -- (0.2, -0.2) -- (0.2, 0.2) -- (-0.2, 0.2) -- (-0.2,-0.2);
|
||||
\end{tikzpicture}
|
||||
\hfill~
|
||||
\end{center}
|
||||
|
||||
\problem{}
|
||||
What is the value of the parity bit in the message above?
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
Can this coding scheme detect a transposition error? \par
|
||||
Can this coding scheme detect two single-bit errors? \par
|
||||
Can this coding scheme correct a single-bit error?
|
||||
|
||||
\vfill
|
||||
\pagebreak
|
||||
|
||||
We'll now add four more parity bits, in positions \texttt{0001}, \texttt{0010}, \texttt{0100}, and \texttt{1000}:
|
||||
|
||||
\begin{center}
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\node at (0.0, 0) {\texttt{X}};
|
||||
\node at (0.5, 0) {\texttt{X}};
|
||||
\node at (1.0, 0) {\texttt{X}};
|
||||
\node at (1.5, 0) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -0.5) {\texttt{X}};
|
||||
\node at (0.5, -0.5) {\texttt{1}};
|
||||
\node at (1.0, -0.5) {\texttt{0}};
|
||||
\node at (1.5, -0.5) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -1) {\texttt{X}};
|
||||
\node at (0.5, -1) {\texttt{1}};
|
||||
\node at (1.0, -1) {\texttt{0}};
|
||||
\node at (1.5, -1) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -1.5) {\texttt{1}};
|
||||
\node at (0.5, -1.5) {\texttt{0}};
|
||||
\node at (1.0, -1.5) {\texttt{0}};
|
||||
\node at (1.5, -1.5) {\texttt{1}};
|
||||
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
\draw (0 - 0.2, 0 - 0.2)
|
||||
-- (0 + 0.2, 0 - 0.2)
|
||||
-- (0 + 0.2, 0 + 0.2)
|
||||
-- (0 - 0.2, 0 + 0.2)
|
||||
-- (0 - 0.2, 0 - 0.2);
|
||||
\draw (0.5 - 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 - 0.2);
|
||||
\draw (1 - 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 - 0.2);
|
||||
\draw (0 - 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 - 0.2);
|
||||
\draw (0 - 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 - 0.2);
|
||||
\end{tikzpicture}
|
||||
\end{center}
|
||||
|
||||
|
||||
Bit \texttt{0001} will count the parity of all bits with a one in the first digit of their index. \par
|
||||
Bit \texttt{0010} will count the parity of all bits with a one in the second digit of their index. \par
|
||||
Bits \texttt{0100} and \texttt{1000} work in the same way. \par
|
||||
\hint{In \texttt{0001}, \texttt{1} is the first digit. In \texttt{0010}, \texttt{1} is the second digit. \\
|
||||
When counting bits in binary numbers, go from right to left.}
|
||||
|
||||
\problem{}
|
||||
Which message bits does each parity bit cover? \par
|
||||
In other words, which message bits affect the value of each parity bit? \par
|
||||
|
||||
\vspace{1mm}
|
||||
|
||||
Four diagrams are shown below. In each grid, fill in the bits that affect the shaded parity bit.
|
||||
|
||||
\begin{center}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
\draw[pattern=north east lines] (0.5 - 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 - 0.2);
|
||||
\end{tikzpicture}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
|
||||
\draw[pattern=north east lines] (1 - 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 - 0.2);
|
||||
\end{tikzpicture}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
\draw[pattern=north east lines] (0 - 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 - 0.2);
|
||||
\end{tikzpicture}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
\draw[pattern=north east lines] (0 - 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 - 0.2);
|
||||
\end{tikzpicture}
|
||||
\hfill
|
||||
\end{center}
|
||||
|
||||
|
||||
|
||||
\problem{}
|
||||
Compute all parity bits in the message above.
|
||||
|
||||
\vfill
|
||||
\pagebreak
|
||||
|
||||
|
||||
\problem{}
|
||||
Analyze this coding scheme.
|
||||
\begin{itemize}
|
||||
\item Can we detect one single-bit errors?
|
||||
\item Can we detect two single-bit errors?
|
||||
\item What errors can we correct?
|
||||
\end{itemize}
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}
|
||||
Each of the following messages has either 0, 1, or two errors. \par
|
||||
Find the errors and correct them if possible. \par
|
||||
\hint{Bit \texttt{0000} should tell you how many errors you have.}
|
||||
|
||||
\begin{center}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\node at (0.0, 0) {\texttt{0}};
|
||||
\node at (0.5, 0) {\texttt{1}};
|
||||
\node at (1.0, 0) {\texttt{1}};
|
||||
\node at (1.5, 0) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -0.5) {\texttt{0}};
|
||||
\node at (0.5, -0.5) {\texttt{1}};
|
||||
\node at (1.0, -0.5) {\texttt{1}};
|
||||
\node at (1.5, -0.5) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -1) {\texttt{0}};
|
||||
\node at (0.5, -1) {\texttt{0}};
|
||||
\node at (1.0, -1) {\texttt{1}};
|
||||
\node at (1.5, -1) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -1.5) {\texttt{1}};
|
||||
\node at (0.5, -1.5) {\texttt{1}};
|
||||
\node at (1.0, -1.5) {\texttt{1}};
|
||||
\node at (1.5, -1.5) {\texttt{0}};
|
||||
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
\draw (0 - 0.2, 0 - 0.2)
|
||||
-- (0 + 0.2, 0 - 0.2)
|
||||
-- (0 + 0.2, 0 + 0.2)
|
||||
-- (0 - 0.2, 0 + 0.2)
|
||||
-- (0 - 0.2, 0 - 0.2);
|
||||
\draw (0.5 - 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 - 0.2);
|
||||
\draw (1 - 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 - 0.2);
|
||||
\draw (0 - 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 - 0.2);
|
||||
\draw (0 - 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 - 0.2);
|
||||
\end{tikzpicture}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\node at (0.0, 0) {\texttt{1}};
|
||||
\node at (0.5, 0) {\texttt{1}};
|
||||
\node at (1.0, 0) {\texttt{0}};
|
||||
\node at (1.5, 0) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -0.5) {\texttt{1}};
|
||||
\node at (0.5, -0.5) {\texttt{0}};
|
||||
\node at (1.0, -0.5) {\texttt{1}};
|
||||
\node at (1.5, -0.5) {\texttt{0}};
|
||||
|
||||
\node at (0.0, -1) {\texttt{0}};
|
||||
\node at (0.5, -1) {\texttt{1}};
|
||||
\node at (1.0, -1) {\texttt{1}};
|
||||
\node at (1.5, -1) {\texttt{0}};
|
||||
|
||||
\node at (0.0, -1.5) {\texttt{1}};
|
||||
\node at (0.5, -1.5) {\texttt{1}};
|
||||
\node at (1.0, -1.5) {\texttt{0}};
|
||||
\node at (1.5, -1.5) {\texttt{1}};
|
||||
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
\draw (0 - 0.2, 0 - 0.2)
|
||||
-- (0 + 0.2, 0 - 0.2)
|
||||
-- (0 + 0.2, 0 + 0.2)
|
||||
-- (0 - 0.2, 0 + 0.2)
|
||||
-- (0 - 0.2, 0 - 0.2);
|
||||
\draw (0.5 - 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 - 0.2);
|
||||
\draw (1 - 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 - 0.2);
|
||||
\draw (0 - 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 - 0.2);
|
||||
\draw (0 - 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 - 0.2);
|
||||
\end{tikzpicture}
|
||||
\hfill
|
||||
\begin{tikzpicture}[scale = 1.25]
|
||||
\node at (0.0, 0) {\texttt{0}};
|
||||
\node at (0.5, 0) {\texttt{1}};
|
||||
\node at (1.0, 0) {\texttt{1}};
|
||||
\node at (1.5, 0) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -0.5) {\texttt{1}};
|
||||
\node at (0.5, -0.5) {\texttt{0}};
|
||||
\node at (1.0, -0.5) {\texttt{1}};
|
||||
\node at (1.5, -0.5) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -1) {\texttt{1}};
|
||||
\node at (0.5, -1) {\texttt{0}};
|
||||
\node at (1.0, -1) {\texttt{1}};
|
||||
\node at (1.5, -1) {\texttt{1}};
|
||||
|
||||
\node at (0.0, -1.5) {\texttt{1}};
|
||||
\node at (0.5, -1.5) {\texttt{0}};
|
||||
\node at (1.0, -1.5) {\texttt{0}};
|
||||
\node at (1.5, -1.5) {\texttt{0}};
|
||||
|
||||
\draw (-0.25, 0.25) -- (1.75, 0.25);
|
||||
\draw (-0.25, -0.25) -- (1.75, -0.25);
|
||||
\draw (-0.25, -0.75) -- (1.75, -0.75);
|
||||
\draw (-0.25, -1.25) -- (1.75, -1.25);
|
||||
\draw (-0.25, -1.75) -- (1.75, -1.75);
|
||||
|
||||
\draw (-0.25, 0.25) -- (-0.25, -1.75);
|
||||
\draw (0.25, 0.25) -- (0.25, -1.75);
|
||||
\draw (0.75, 0.25) -- (0.75, -1.75);
|
||||
\draw (1.25, 0.25) -- (1.25, -1.75);
|
||||
\draw (1.75, 0.25) -- (1.75, -1.75);
|
||||
|
||||
\draw (0 - 0.2, 0 - 0.2)
|
||||
-- (0 + 0.2, 0 - 0.2)
|
||||
-- (0 + 0.2, 0 + 0.2)
|
||||
-- (0 - 0.2, 0 + 0.2)
|
||||
-- (0 - 0.2, 0 - 0.2);
|
||||
\draw (0.5 - 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 - 0.2)
|
||||
-- (0.5 + 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 + 0.2)
|
||||
-- (0.5 - 0.2, 0 - 0.2);
|
||||
\draw (1 - 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 - 0.2)
|
||||
-- (1 + 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 + 0.2)
|
||||
-- (1 - 0.2, 0 - 0.2);
|
||||
\draw (0 - 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 - 0.2)
|
||||
-- (0 + 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 + 0.2)
|
||||
-- (0 - 0.2, -0.5 - 0.2);
|
||||
\draw (0 - 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 - 0.2)
|
||||
-- (0 + 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 + 0.2)
|
||||
-- (0 - 0.2, -1 - 0.2);
|
||||
\end{tikzpicture}
|
||||
\hfill
|
||||
\end{center}
|
||||
|
||||
\begin{solution}
|
||||
\textbf{1:} Single error at position \texttt{1010} \par
|
||||
\textbf{2:} Double error \par
|
||||
\textbf{3:} No error \par
|
||||
\end{solution}
|
||||
|
||||
|
||||
\vfill
|
||||
\pagebreak
|
||||
|
||||
|
||||
\problem{}
|
||||
How many parity bits does each message bit affect? \par
|
||||
Does this correlate with that message bit's index?
|
||||
\vfill
|
||||
|
||||
|
||||
\problem{}
|
||||
Say we have a message with exactly one single-bit error. \par
|
||||
If we know which parity bits are inconsistent, how can we find where the error is?
|
||||
|
||||
\vfill
|
||||
|
||||
\problem{}<generalize-hamming>
|
||||
Can you generalize this system for messages of 4, 64, or 256 bits?
|
||||
|
||||
\vfill
|
||||
|
||||
\pagebreak
|
Reference in New Issue
Block a user