## 4 Edge Prediction Algorithm Based on ARMA
### EP-ARMA Implementation
The value of accuracy\({}_{\mathrm{high}}\) is initially given by the application, but is limited to Formula (7) and the prediction result, and will change dynamically according to the amount of correction data allowed to be transmitted. The value of accuracy\({}_{\mathrm{high}}\) remains constant or decreases in the whole communication process. \(\{n_{\min},\cdots,\ n_{\max}\}\) will change dynamically with \(\left\{\text{accuracy}_{\text{high}},\cdots,\text{ accuracy}_{\text{low}}\right\}\), where \(n_{\min}\) represents the lowest threshold allowed by the service accuracy, and \(n_{\max}\) represents the highest threshold that the edge prediction algorithm can provide. \(\{n_{\min},\cdots,\ n_{\max}\}\) and \(\left\{\text{accuracy}_{\text{high}},\cdots,\text{ accuracy}_{\text{low}}\right\}\) play a consistent role in EP-ARMA. EP-ARMA, as shown in Algorithm 1, are generally deployed in sensor agents and sink agents. They must find the \(\{\text{p},\text{d},\text{q}\}\) parameters with the lowest AIC or BIC value according to the automatic traversal algorithm. Additionally, it generates the prediction data set \(\{\text{forecast}_{\text{i}}\}\). Then, it generates the correction data set \(\{\text{n},\text{i},\text{ correct}_{\text{i}}\}\) and the threshold value. The edge prediction on the sink agent recovers the corrected prediction data set \(\left\{\text{forecast}_{\text{i}}^{\text{f}}\right\}\), according to \(\{\text{p},\text{d},\text{q}\}\), \(\{\text{n},\text{i},\text{ correct}_{\text{i}}\}\), the threshold value, and the historical data. ```
Initialize p, d, q range, \(\left\{\text{accuracy}_{\text{high}},\cdots,\text{ accuracy}_{\text{low}}\right\}\), forecast step, T Complete the monitoring task in period T, and obtain the data of \(\{\text{collect}_{\text{i}}\}\)  While (true) If (node.type is sensor) According to the forecast step, obtain the datahistory from'service data' database  Obtain the ARIMA(\(\text{p}_{\text{best}}\), \(\text{d}_{\text{best}}\), \(\text{q}_{\text{best}}\)) by AIC or BIC in p, d, q range  Obtain the \(\{\text{forecast}_{\text{i}}\}\) by ARIMA(\(\text{p}_{\text{best}}\), \(\text{d}_{\text{best}}\), \(\text{q}_{\text{best}}\)), datahistory and T  Obtain the \(\{n_{\min},\cdots,\ n_{\max}\}\), \(\{n,\text{i},\text{ correct}_{\text{i}}\}\), and threshold by \(\{\text{collect}_{\text{i}}\}\), \(\{\text{forecast}_{\text{i}}\}\), \(\left\{\text{accuracy}_{\text{high}},\cdots,\text{accuracy}_{\text{low}}\right\}\) and Formula (7) Save the (\(\text{p}_{\text{best}}\), \(\text{d}_{\text{best}}\), \(\text{q}_{\text{best}}\)) and \(\{n,\text{i},\text{ correct}_{\text{i}}\}\) in'service data' database  Save the 'threshold' in 'transport policy' database  Wait for the next period T End if If (node.type is sink && the new data has been received) According to the forecast step, get the datahistory from'service data' database  Obtain the (p, d, q), \(\{\text{n},\text{i},\text{ correct}_{\text{i}}\}\) and threshold from the received data  Obtain the \(\{\text{forecast}_{\text{i}}^{\text{f}}\}\) by ARIMA (p, d, q) and \(\{n,\text{i},\text{ correct}_{\text{i}}\}\)  Save the \(\{\text{forecast}_{\text{i}}^{\text{f}}\}\) in'service data' database  End if end while
```  
**Algorithm 1** Edge Prediction Based on ARMA (EP-ARMA)