\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{} 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{} 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