## 2 Algorithm Introduction  
### Coding Algorithm Introduction  
As shown in Figure 2, it is assumed that a sequence \(\{s(k)\}\) (\(k=1,\,2,\,\ldots,\,n\)) is given. Each symbol \(s(k)\) belong to a finite digital sequence \(e(k)\) is the output of the coding process. In the periodic signal, there is a great correlation between the different periods of the signal; therefore, the multivariate digital group of the periodic signal, such as the ternary group \((s(k-2),s(k-1),s(k))\), will have great repeatability. When a periodic signal is predicted, the history information of the signal is important. We built a dictionary to store the history information of the signal. Because the history information of the signal is rich. According to the characteristics of the periodic signal, the adaptive dictionary is only used to store the information of the above ternary groups. In this way, not only can the periodic signal can be accurately predicted, but the size of the dictionary is not very large and it is easy to implement it in the project. In order to reduce the complexity of querying the dictionary, for a ternary digit group \((s(k-2),s(k-1),s(k))\), the first two digits \(s(k-2)\) and \(s(k-1)\) are used to store the two-dimensional address of \(s(k)\). Although this is not unique mapping and will cause memory conflicts, the complexity of the dictionary lookup algorithm is low, just \(O(1)\). When a memory conflict is encountered, the current ternary group directly overwrites the previous ternary group. In this way, the dictionary created by us will be dynamic, which is adaptive. Furthermore, the larger the dimension of the adaptive dictionary, the lower the probability of the memory conflicts. However, as the dictionary dimension increases, the storage size of the dictionary will increase dramatically. The storage size of the high-dimensional dictionary will be unacceptable to us. Therefore, the two-dimensional dictionary will be our best choice. Before introducing the algorithm, we introduce a definition:  
Figure 2: Principle block diagram of the coding algorithm. (1) We define \(s(k-2)\), \(s(k-1)\) as the first two adjacent digitals of \(s(k)\). First, the two-dimensional dictionary \(D\) is created, whose size is \(n\times n\). The coded digitals are then stored in the adaptive dictionary. The position of the digital in the dictionary is the two-dimensional coordinate formed by the first two adjacent digitals \(s(k-2)\) and \(s(k-1)\). Then the current digital \(s(k)\), whose first two adjacent digitals make up the address (\(s(k-2)\), \(s(k-1)\)), is coded, and the predicted value \(s^{\prime}(k)\) of the current digital to be coded is read in the dictionary \(D\) (\(s(k-2)\), \(s(k-1)\)). Then the current coded digital \(s(k)\) is subtracted from the predicted value \(s^{\prime}(k)\) to obtain an error signal \(e(k)=s(k)-s^{\prime}(k)\). The error signal \(e(k)\) is the coding output signal. Although a dictionary is generated during the coding process, the dictionary does not need to be transmitted with the output signal of the coding after the coding process is completed. The adaptive dictionary is discarded as soon as the coding process ends. For the coding process, there are two special cases, as follows:  
1. The first two digitals \(s(1)\), \(s(2)\) in the input array \(\{s(k)\}\) to be coded do not have the first two adjacent digitals. Therefore, the first two digitals cannot be coded, and they need to be directly output as they are. 2. In the early stage of the coding process, because the dictionary \(D\) is not complete, there may not be predicted values in the dictionary. According to the first two adjacent digitals, Equation (1) can be used as the predicted value of the current digital to be coded.