# A High Efficiency Multistage Coder for Lossless Audio Compression using OLS+ and CDCCR Method
## 6 Removing Context-Dependent Cumulate Prediction Error
```
Initial value: \(S_{(j)}^{(Ch)}\)\(\colon=\)\(C_{(j)}^{(Ch)}\)\(\colon=\)\(0\), for every \(j\); \(N_{(j)}^{(Ch)}\)\(\colon=\)\(4\), for every \(j\); if\(\mid\!e_{K}^{(Ch)}(n)\!\mid<\)\(4\cdot\sqrt[4]{Var(X)}\) then \(S_{(j)}^{(Ch)}\)\(\colon=\)\(S_{(j)}^{(Ch)}\)\(\colon=\)\(S_{(j)}^{(Ch)}\)\(\colon=\)\(S_{(j)}^{(Ch)}\)\(\colon=\)\(N_{(j)}^{(Ch)}\)\(\colon=\)\(1\); \(\downarrow\)\(C_{(j)}^{(Ch)}\)\(\colon=\)\(S_{(j)}^{(Ch)}/N_{(j)}^{(Ch)}\);
```  
**Algorithm 2** Our authorial algorithm of adaptation \(C_{(j)}^{(Ch)}\) value based on the CALIC method. The periodic forgetting technique is also useful, which additionally allows adjustment of the values of the constants \(C_{(j)}^{(Ch)}\) to the local properties of the \(j\)-th context, if \(N_{(j)}^{(Ch)}\) is greater than 127 then \(N_{(j)}^{(Ch)}\) is set on 64 and \(S_{(j)}^{(Ch)}\) is set as \(S_{(j)}^{(Ch)}/2\). To remove a context-dependent constant component, instead of the arithmetic mean used in CALIC, it is possible to use the median of a set of prediction errors previously appearing in a given context. Also, in this case, it is worthwhile to additionally use the technique of forgetting periodic after the occurrence counter of \(N_{(j)}^{(Ch)}\)\(j\)-th context has reached the value of 128. This improves the overall efficiency of compression while also reducing the size of the vector to 64 elements, which store the prediction errors that appear earlier in the given context. Forgetting periodic consists in reducing the vector by half of 128 elements by removing the first 32 and last 32 elements sorted ascending vector which stores the prediction errors that appear earlier in the given context. In presented codec this solution was proposed to encode an audio signal with equally good effect as the last block CDCCR in the cascade as an improvement of the value of the predicted coded samples. Due to this work a bit average can be shortened by up to 1% (depending on the input data and the efficiency of previous prediction blocks). The idea is based on the determination of 4 types of contexts, and each of them is used twice (using the arithmetic mean and medians marked with the AVE and MED symbols, respectively). In this way, eight constant components are created, and, on the basis of which, the final weighted \(C_{\text{mix}}^{(Ch)}\) is determined by  
\[C_{\text{mix}}^{(Ch)}=\frac{1}{36}\Bigg{(}4\cdot\sum_{i=1}^{4}C_{(j(i))}^{(Ch) \text{AVE}}+5\cdot\sum_{i=1}^{4}C_{(j(i))}^{(Ch)\text{MED}}\Bigg{)}. \tag{24}\]  
The high efficiency of the mixed method of constant component correction results from the principles of mixing correction values that are burdened by some of level of uncertainty, which may individually deteriorate in some situations the final level of prediction error (incorrect prediction of correction values). This is prevented by mixing (weighted average) that causes the correlation of these uncertain correction values to a large extent. At the same time, this method reduces the chances of occurrence of the asymmetry effect of the distribution, which can be manifested by the occurrence in the given \(j\)-th context of differences between the position in the histogram, indicated as the arithmetic mean \(C_{(j)}^{(Ch)}\) of prediction errors, and the actual position indicating in the histogram the maximum probability (histogram of the Laplace distribution has one maximum), indicated in [35]. In Table 2 is a set of decision rules based on which the numbers of contexts are determined. Decisions are two-state (binary) quantizer that returns the value of bit 0 or 1 (individual bits are defined here as \(\alpha_{i}\)), which corresponds to the fulfilment or non-fulfilment of a given condition (YES/NOanswer). As they are partially repeated in subsequent ways of building the context number, they will be listed Table 2, and the construction rules for the four types of context number are described in the following Sections 6.1-6.4.