132 lines
3.4 KiB
TeX
Raw Normal View History

2023-01-12 08:31:10 -08:00
\section{Error Correction}
2023-06-19 15:42:33 -07:00
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.
2023-01-12 08:31:10 -08:00
\begin{figure}[h]
\centering
\includegraphics[width = 3cm]{qr}
\end{figure}
\definition{Repeating codes}
2023-06-19 15:42:33 -07:00
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
2023-01-12 08:31:10 -08:00
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.
2023-06-19 15:42:33 -07:00
\problem{}
How many repeated digits do you need to...
\begin{itemize}
\item[-] detect a transposition error?
\item[-] correct a transposition error?
\end{itemize}
\vfill
2023-01-12 08:31:10 -08:00
\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{}
2023-06-19 15:42:33 -07:00
What is the efficiency of a $k$-repeat code?
2023-01-12 08:31:10 -08:00
\vfill
\pagebreak
\definition{Hamming's Square Code}
2023-06-19 15:42:33 -07:00
We will now analyze a more efficient coding scheme: \par
2023-01-12 08:31:10 -08:00
2023-06-19 15:42:33 -07:00
\vspace{1mm}
2023-01-12 08:31:10 -08:00
2023-06-19 15:42:33 -07:00
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
2023-01-12 08:31:10 -08:00
Finally, compute the pairity of the entire message write it in the lower right corner.
2023-06-19 15:42:33 -07:00
This ensures that the total number of ones in the message is even.
2023-01-12 08:31:10 -08:00
2023-06-19 15:42:33 -07:00
\vspace{2mm}
2023-01-12 08:31:10 -08:00
2023-06-19 15:42:33 -07:00
Reading the result row by row to get the encoded message. \par
2023-01-12 08:31:10 -08:00
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{}
2023-06-19 15:42:33 -07:00
The following messages are encoded using the method above.
2023-01-12 08:31:10 -08:00
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{}
2023-06-19 15:42:33 -07:00
Can we correct a single-digit error in the encoded message? \par
2023-01-12 08:31:10 -08:00
Can we correct a transposition error in the encoded message?
\vfill
\problem{}
2023-06-19 15:42:33 -07:00
Let's generalize this coding scheme to a non-square table: \par
2023-01-12 08:31:10 -08:00
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