# Similarity Measurement and Classification of Temporal Data Based on Double Mean Representation
## 2 Related Work
### Two Improvements of SAX Distance Measure for Time Series  
#### 2.2.1 SAX-TD  
In order to enhance the accuracy of the SAX representation, it is important to preserve the trend information of the time series data during the dimensionality reduction process. For instance, the authors of reference [16] propose storing a value and a symbol in SAX to improve the distance calculation. They introduce an improvement method called SAX-TD, which utilizes the start and end points of segments to calculate the trend distance. There are several scenarios for the trend variation of time series data segments, as illustrated in Figure 2. In this figure, t represents the left endpoint, which is the starting endpoint, and t represents the right endpoint, which is the end endpoint.  
The trend is indeed an important feature of time series data and plays a crucial role in their classification and analysis. For instance, if the endpoint value is greater than the starting point value, it indicates an upward trend, while the opposite suggests a downward trend. To describe this trend more accurately, it is necessary to use the actual values instead of the symbolized mapping when calculating the trend distance.  
For the given time series data \(q\) and \(c\), their trend distance is calculated as follows:  
\[td(q,c)=\sqrt{\left(\Delta q(t_{s})-\Delta c(t_{s})\right)^{2}+\left(\Delta q( t_{e})-\Delta c(t_{e})\right)^{2}} \tag{2}\]  
Figure 2: Some examples of SAX-TD. (**a**–**f**) represent the trend distances calculated by the SAX-TD method for representing sequences of various common shapes.  
where \(t_{s}\) and \(t_{e}\) represents the left and right endpoint values of the time series segment, \(\Delta q(t)\) represents the distance from the endpoint value to the average value of the line segment in the sequence, and \(q(\Delta c(t)\) represents the corresponding distance of another sequence), calculated using Formula (3):  
\[\Delta q(t)=q(t)-\overline{q} \tag{3}\]  
Although each segment has a starting point and an endpoint, in practice, the starting point of the next segment is actually the endpoint of the previous segment. Therefore, it is possible to embed the trend distance into the SAX symbolized sequence. As a result, the time series data \(Q\) and \(C\) can be expressed using the following representation:  
\[\begin{array}{l}Q:\Delta q(1)\hat{q_{1}}\Delta q(2)\hat{q_{2}}\ldots\Delta q (w)\hat{q_{w}}\Delta q(w+1)\\ C:\Delta c(1)\hat{c_{1}}\Delta c(2)\hat{c_{2}}\ldots\Delta c(w)\hat{c_{w}} \Delta c(w+1)\end{array}\]  
\(\hat{q_{1}},\hat{q_{2}}\ldots\hat{q_{w}}\) represents a sequence symbolized by SAX, and \(\Delta q(1)\), \(\Delta q(2)\), \(\ldots\), \(\Delta q(x)\) represents the trend of the time series data represented by the distance between the endpoint values and the mean values. \(\Delta q(x+1)\) represents the change in the last point.  
The distance measure formula for the time series data \(Q\) and \(C\) can be expressed as follows:  
\[TDIST(\hat{Q},\hat{C})=\sqrt{\frac{n}{w}}\sqrt{\sum_{i=1}^{w}\left(dist(\hat{ q_{i}},\hat{c_{i}})\right)^{2}+\frac{w}{n}\left(td(q_{i},\hat{c_{i}})\right)^{2}} \tag{4}\]  
where \(dist(\hat{q_{i}},\hat{c_{i}})\) represents the distance calculated using the SAX distance measure algorithm, \(td(q_{i},\hat{c_{i}})\) represents the distance calculated using Equation (2), n represents the length of q and c, and w represents the number of time segments.