# Adaptive Seasonality Anomaly Detection Algorithm under Intricate KPI Profiles
## 3 Materials and Methods
### eBeats Clustering Algorithm
#### 3.2.1 Lightweight Distance Measurement Algorithm
is shown in Figure 7b. Discrete cosine transform can express a finite time series sequence of KPI data in terms of a sum of cosine functions oscillating at different frequencies. The use of cosine rather than sine functions is critical for compression, since it turns out that fewer cosine functions are needed to approximate a typical signal, whereas for differential equations the cosines express a particular choice of boundary conditions. According to observations, the larger data in the updated matrix is predominantly dispersed in the upper left, while the absolute values of data scattered in other places are close to zero. As a result, the major data information in the matrix converges in the upper-left corner. After the discrete cosine transform, quantify and divide the matrix, then determine the eigenvalues. The matrix \(D\)'s quantization matrx \(Q\) is as follows. \[Q=round(\frac{D}{Z}) \tag{11}\]  
where \(round\) is rounding function and \(Z\) is the standard quantization matrix for discrete cosine transform [34]. For the matrix \(Q\), it can be divided into four small matrices. \[Q= \begin{bmatrix}q_{11}&q_{12}\\ q_{21}&q_{22}\end{bmatrix}  \tag{12}\]  
Because the matrix \(Q\) is generated by converging the principal information of the matrix \(D\) to the top-left corner, it can be seen that the matrix \(q_{11}\) keeps the main data information and the matrix \(q_{22}\) barely retains it in the figure. The highest values of the matrices \(q_{12}\) and \(q_{21}\) surpass the minimum value of the matrix \(q_{11}\), indicating that the matrices \(q_{12}\) and \(q_{21}\) maintain the secondary information of the data. As a result, the matrix \(Q\) is represented as when the matrices \(q_{12}\) and \(q_{21}\) include the secondary information of the data. \[Q\approx \begin{bmatrix}q_{11}&q_{12}\\ q_{21}&0\end{bmatrix}  \tag{13}\]  
where we calculate the eigenvalues of the matrices \(q_{11}\), \(q_{12}\) and \(q_{21}\), sort them in descending order to form an array as the principal information extracted from \(M_{i}\). The comparison charts before and after extracting principal information of KPI time series data sub-sequences are shown in Figure 8. The KPI time series data sub-sequences segmented by day are shown in Figure 8a. The five different color sub-sequences in the figure represent different working days and rest days. Each of sub-sequences contains 288 observations. According to experimental results, KPI profiles of these three sub-sequences representing the working days are more similar. Similarly, the profiles of other two sub-sequences representing rest days are more similar. The KPI time series data sub-sequences after extracting the principal information are shown in Figure 8b. Five sub  
Figure 7: Data aggregation comparison chart. (**a**) Data thermal distribution of the original matrix. (**b**) Data heat distribution of the aggregation matrix. sequences with various colors reflect distinct working days and rest days in the diagram. Each sub-sequence concludes 36 observations once the principal information has been extracted. Based on experimental observations, the analytical results are as follows. It can be seen that the data length of sub-sequences can be compressed by 87.5% without compromising profile similarity. Then, we use the classical DTW algorithm to calculate the distance between different sub-sequences because of the short length of extracted KPI time series data. As a result, we can say that our lightweight distance measurement algorithm is useful for reducing the clustering time consumption by extracting principal information from origin KPI time series data.