# Similarity Measurement and Classification of Temporal Data Based on Double Mean Representation
## 3 Our Method, SAX-DM
### Similarity Measurement Based on SAX-DM Expression Method  
In this paper, the Euclidean distance is employed as the fundamental method for measuring similarity. For a sequence approximated using SAX-DM, it can be viewed as a point in a w-dimensional space. Therefore, the computation of similarity between time series data can be transformed into calculating the distance between different points in this w-dimensional space.  
Before proceeding, let us review the method for calculating Euclidean distance on the original time series data. Suppose we have two time series data, \(T=t_{1},t_{2},t_{3},\ldots,t_{n}\), \(S=s_{1},s_{2},s_{3},\ldots,s_{n}\). The Euclidean distance between them is the straight-line distance between the points represented by the two time series data objects in an n-dimensional space. It can be calculated using the following formula:  
\[ED(T,S)=\sqrt[2]{\sum_{i=1}^{n}(t_{i}-s_{i})^{2}} \tag{10}\]  
Due to the high-dimensional nature of time series data, calculating distances on the original time series data can lead to significant memory pressure and a substantial number of computations. This process is also susceptible to noise and deformations in the data. Therefore, it is common to compress and reduce the dimensionality of the original time series data and extract features. One popular method for compression and dimensionality reduction is using Piecewise Aggregate Approximation (PAA). After applying PAA, the similarity distance can be calculated using the following formula:  
\[ED\big{(}\overline{T},\overline{S}\big{)}=\sqrt[2]{\sum_{j=1}^{w}(\overline{t }_{j}-\overline{s}_{j})^{2}} \tag{11}\]  
Each time series data subsegment uses the mean as a feature information:  
\[\overline{t}_{i}=\frac{w}{n}\sum_{j=\frac{w}{n}(i-1)+1}^{\frac{w}{n}i}t_{j} \tag{12}\]  
Figure 4: Schematic diagram of SAX-DM trend distance. (**a**) represents the trend distance calculated by the SAX-DM method for sequences with an upward trend. (**b**) represents the trend distance calculated by the SAX-DM method for sequences with a downward trend.  
In this article, trend distance is used to represent temporal data fragments. Firstly, a representation based on trend distance is defined. For temporal data \(Q\) and \(C\), the following expressions are defined:  
\[\begin{array}{l}Q:\Delta q_{1}\hat{q}_{1}\Delta q_{2}\hat{q}_{2\Delta}q_{3} \hat{q}_{3}\ldots\Delta q_{n}\hat{q}_{n}\\ C:\Delta c_{1}\hat{c}_{1}\Delta c_{2}\hat{c}_{2}\Delta c_{3}\hat{c}_{3}\ldots \Delta c_{n}\hat{c}_{n}\end{array}\]  
According to the above expression, the formula for calculating the trend distance based on the left mean value is defined as follows:  
\[md(q,c)=\sqrt[2]{\left(\Delta q-\Delta c\right)^{2}} \tag{13}\]  
The distance measurement can be represented by the following equation:  
\[MDIST(\hat{Q},\hat{C})=\sqrt{\frac{n}{w}}\sqrt{\sum_{i=1}^{w}\left(\left(dist( \hat{q}_{i},\hat{c}_{i})\right)^{2}+\frac{w}{n}(2\times md(\hat{q}_{i},\hat{c }_{i}))^{2}\right)} \tag{14}\]  
In order to address the memory pressure and computational efficiency issues associated with high-dimensional time series data, it is generally necessary to compress and reduce the dimensionality of the original data and extract features. In this paper, the PAA method is employed to segment the original time series data, and the average value and change trend of subsegments are used as the key information for each subsegment. This approach aims to improve the compression ratio of the approximate representation while preserving the essential features of the original data as much as possible. Furthermore, by considering the trend of temporal data changes, the similarity measurement method based on the approximate representation proposed in this paper can calculate similarity more accurately.