# Bounded-Error-Pruned Sensor Data Compression for Energy-Efficient IoT of Environmental Intelligence
## 3 Bounded-Error Sensor Data Compression (BESDC)
### Basic Processing Flow  
The flow chart of our proposed BESDC scheme is illustrated in Figure 2. It can be simply divided into two phases: offline phase and online phase. The offline phase is processed only while a sensor node is newly deployed and needs to generate its initial codebook. In two-tier BEA, a bounded error for the fog-tier sink is obtained from the application-specific bounded error of the user-required QoS2 or QoD. We assigned the fog-tier bounded error \(\tau_{total}\) to the sink by proportionally dividing the BEA, as shown in Figure 3. The sink will calculate the sensor-tier bounded errors \(\tau_{1}\) to \(\tau_{9}\) by Equation (1) with the proportional weight \(w_{i}\) according to the status, capability, etc., of sensor \(i\). This value \(w_{i}\) can be intelligently assigned from the fog-tier server (i.e., bounded error regulator, BER) or just equally assigned \(w_{i}=1/n\) via the fog-tier sink. After the bounded error \(\tau_{i}\) is assigned to the sensor node \(i\), we try to evaluate the data correlation of sensed data for constructing the initial codebook. Usually, the servers can spend a time period evaluating the data correlation of sensed data for constructingthe initial codebook. In order to reduce the offline phase latency for constructing the initial codebook, different sensors can be assigned the same initial codebook by default or a fog-tier server like BER. \[\tau_{i}=\tau_{total}w_{i} \tag{1}\]  
\[\sum_{i=1}^{n}w_{i}=1 \tag{2}\]  
\[S_{ED}\equiv\langle s_{1},s_{2},\cdots,s_{n}\rangle \tag{3}\]  
\[\overline{S}_{ED}^{\tau_{i}}\equiv\left\langle\overline{s}_{1}^{\tau_{i}}, \overline{s}_{2}^{\tau_{i}},\cdots,\overline{s}_{n}^{\tau_{i}}\right\rangle \tag{4}\]  
\[\left|\overline{S}_{ED}^{\tau_{i}}\right|\leq|S_{ED}|\leq n \tag{5}\]  
\[\max_{1\leq j\leq n}\left|\overline{s}_{j}^{\tau_{i}}-s_{j}\right|\leq\tau_{i} \tag{6}\]  
\[QoS^{2}\left(\overline{S}_{ED}^{\tau_{i}}\right)\cong QoS^{2}(S_{ED}) \tag{7}\]  
\[QoD\left(\overline{S}_{ED}^{\tau_{i}}\right)\cong QoD(S_{ED}) \tag{8}\]  
In the online phase, the new sensed data of ED, which are represented as in Equation (3), should be compressed or not by comparing with former sensed data (i.e., temporal correlation between sensor value \(s_{j+1}\) and \(s_{j}\)) and be encoded through the codebook (i.e., data correlation in sensor data similarity, as shown in Equation (5)) within the bounded error constraint \(\tau_{i}\) (as shown in the given criteria in Equation (6)). In Equation (3), \(S_{ED}\) is defined as a sequence of ED's sensor values of length \(n\). \(\overline{S}_{ED}^{\tau_{i}}\) is defined as a sequence of bounded-error-pruned sensor values from the sequence \(S_{ED}\), as the bounded error \(\tau_{i}\) given in Equation (4). \(\left|\overline{S}_{ED}^{\tau_{i}}\right|\) and \(|S_{ED}|\) are the numbers of different values represented in sequences \(\overline{S}_{ED}^{\tau_{i}}\) and \(S_{ED}\) in Equation (5), respectively. Figure 3.0 The processing flow of our proposed BESDC scheme. As shown in Figure 2, BESDC consists of EB-HC (error-bounded HC) for data correlation compression and EB-RLE (error-bounded RLE) for temporal correlation compression [38]. Thus, EB-HC and EB-RLE will have the advantages of more same values and longer run-length values, respectively, to reduce the number of \(|S_{ED}|\) to for bounded-error-pruned sensor data compression, as indicated in the bounded error criteria required between the pruned and original data (i.e., \(\overline{s}_{j}^{i}\) and \(s_{j}\)) in Equation (6). Then, the pruned sensor data sequence \(\overline{S}_{ED}^{i}\) will have similar QoS2 and QoD with the original sensor data sequence \(S_{ED}\), as shown in Equations (7) and (8). In an SN, the new received data from ED should be compressed again or not by comparing it with the neighboring sensed data (i.e., spatial correlation) and be encoded through the codebook (i.e., data correlation) within the given bounded error.