From a87e4417ced5656af22d6b5368ef45203d7f1256 Mon Sep 17 00:00:00 2001 From: Mark Date: Sun, 25 Jun 2023 18:28:08 -0700 Subject: [PATCH] Fixed errors --- .../parts/00 detection.tex | 34 +-- .../parts/02 hamming.tex | 286 ++++++++++-------- 2 files changed, 165 insertions(+), 155 deletions(-) diff --git a/Advanced/Error-Correcting Codes/parts/00 detection.tex b/Advanced/Error-Correcting Codes/parts/00 detection.tex index 10b64da..e356b83 100755 --- a/Advanced/Error-Correcting Codes/parts/00 detection.tex +++ b/Advanced/Error-Correcting Codes/parts/00 detection.tex @@ -5,26 +5,25 @@ An ISBN\footnote{International Standard Book Number} is a unique numeric book id \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 calculated as follows: +The final digit, $n_{10}$, is chosen from $\{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10\}$ so that: $$ - \Biggr( \sum_{i = 1}^{9} (11 - i) \times n_i \Biggl) \text{ mod } 11 + \sum_{i = 1}^{10} (11 - i)n_i $$ If $n_{10}$ is equal to 10, it is written as \texttt{X}. \problem{} -Which of the following could be valid ISBNs? +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} - \item \texttt{0-316-00395-6} \end{itemize} \begin{solution} - Only the first has an inconsistent check digit. + The first has an inconsistent check digit. \end{solution} \vfill @@ -66,31 +65,6 @@ This is called a \textit{transposition error}. \end{solution} \vfill - - - -\problem{} -Show that the following sum is divisible by 11 iff $n_1n_2...n_{10}$ is a valid ISBN-10. -$$ - \sum_{i = 1}^{10} (11 - i)n_i -$$ - -\begin{solution} - Proof that valid $\implies$ divisible, working in mod 11: - - \vspace{2mm} - - $10n_1 + 9n_2 + ... + 2n_9 + n_{10} \equiv$ \par - $(-n_1) + (-2n_2) + ... + (-9n_9) + n_{10} =$ \par - $-n_{10} + n_{10} \equiv 0$ - - \vspace{2mm} - - Having done this, the rest is easy. Work in reverse, or note that each step above is an iff. - -\end{solution} - -\vfill \pagebreak \problem{} diff --git a/Advanced/Error-Correcting Codes/parts/02 hamming.tex b/Advanced/Error-Correcting Codes/parts/02 hamming.tex index 501b56c..89b29b7 100644 --- a/Advanced/Error-Correcting Codes/parts/02 hamming.tex +++ b/Advanced/Error-Correcting Codes/parts/02 hamming.tex @@ -76,14 +76,54 @@ How many message bits have an index with a one as the $n^\text{th}$ digit? \par -We now want a way to detect errors in our 16-bit message. To do this, we'll replace a few data bits with pairity bits. This will reduce the amount of information we can send, but will also improve our error-detection capabilities. +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 pairity 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. +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}}; @@ -118,10 +158,11 @@ Let's arrange our message in a grid. We'll make the first bit (currently empty, \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 pairity bit in the message above? +What is the value of the parity bit in the message above? \vfill @@ -133,7 +174,7 @@ Can this coding scheme correct a single-bit error? \vfill \pagebreak -We'll now add four more pairity bits, in positions \texttt{0001}, \texttt{0010}, \texttt{0100}, and \texttt{1000}: +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] @@ -198,18 +239,128 @@ We'll now add four more pairity bits, in positions \texttt{0001}, \texttt{0010}, \end{center} -Bit \texttt{0001} will count the pairity of all bits with a one in the first digit of their index. \par -Bit \texttt{0010} will count the pairity 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. +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{} -Compute all pairity bits in the message above. +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. +Find the errors and correct them if possible. \par +\hint{Bit \texttt{0000} should tell you how many errors you have.} \begin{center} \hfill @@ -405,112 +556,9 @@ Find the errors and correct them if possible. \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{} -Which message bits does each pairity bit cover? \par -In other words, which message bits affect the value of each pairity bit? \par - -\vspace{1mm} - -Four diagrams are shown below. In each grid, fill in the bits that affect the shaded pairity 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{} -How many pairity bits does each message bit affect? \par +How many parity bits does each message bit affect? \par Does this correlate with that message bit's index? \vfill @@ -519,12 +567,6 @@ Does this correlate with that message bit's index? 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 -\pagebreak - -\problem{} -How efficient is the 16-bit hamming code? - \vfill \problem{} @@ -532,10 +574,4 @@ Can you generalize this system for messages of 4, 64, or 256 bits? \vfill -\problem{} -How efficient is each code in \ref{generalize-hamming}? \par -What do we sacrifice for this efficiency gain? - -\vfill - \pagebreak \ No newline at end of file