# Hexadecimal Aggregate Approximation Representation and Classification of Time Series Data
## 3 Hexadecimal Aggregate Approximation Representation
### HAX Distance Measures  
The HAX transformation principle has been described in detail in the above section. Based on the principle, time-series objects can be easily converted into HAX strings, and the similarity between two time series objects can be measured by the distance between two corresponding HAX strings. This process can be described using the following Formula. Given a time series \(T\) which contains \(n\) values,  
\[T=\{v_{1},v_{2},\ldots,v_{n}\} \tag{8}\]  
\(T\) is split into \(w\) segments \(S\) by PAA (paaMapper),  
\[S=\text{paaMapper}(T)=\{s_{1}s_{2},\ldots s_{w}\} \tag{9}\]  
Figure 6: TiO points on the TiO plane.  
Figure 7: A \(4\times 4\) HAX grid plane.  
where \(s_{i}\) is \(i\)th subseries. Via the TIO transformation, each subseries in \(S\) can be converted into a TIO point in a set of TIO points \(P\),  
\[P=\text{tioMapper}(S)=\{p_{1},p_{2},\ldots,p_{w}\} \tag{10}\]  
where \(p_{j}\) is a coordinate (\(s_{j}\), \(a_{j}\)) and \(a_{j}\) is a rotation angle of segment(\(j\)) corresponding to subseries(\(j\)). Each point corresponds to a HAX character and \(P\) can then be converted into a HAX string \(H\) through the transformation _haxMapper_,  
\[H=\text{haxMapper}(P)=\{h_{1},h_{2},\ldots,h_{w}\} \tag{11}\]  
Therefore, the approximate distance between two time series can be estimated by the distance between two corresponding HAX strings. Next, we discuss how to calculate the distance between two HAX characters.  
Given two time series objects \(T^{q}\) and \(T^{c}\), the similarity between these two can be estimated by many kinds of distances. The most commonly used is the Euclidean distance (ED), as follows:  
\[\text{ED}(T^{q},T^{c})=\sqrt[2]{\sum_{i=1}^{n}\left(v_{i}^{q}-v_{i}^{c}\right) ^{2}} \tag{12}\]  
However, the real time computation of ED is very inefficient for long time series. Hence the PAA splits a long time series into \(w\) short segments to reduce the dimension of the time series and adopt the segment distance (SD) to estimate the similarity as follows:  
\[\text{SD}(S^{q},S^{c})=\sqrt[2]{\sum_{j=1}^{w}\left(s_{j}^{q}-s_{j}^{c}\right) ^{2}} \tag{13}\]  
where  
\[s_{j}=\frac{w}{n}\sum_{j=(n/w)(i+1)+1}^{(n/w)i}v_{j} \tag{14}\]  
Although the SD decreases the computation of ED, it also discards the trend of a time series. Therefore, the PAX distance (PD) in this paper is expressed by TIO points and is designed to take into account the impact of the trend. The Formula is as follows:  
\[\text{PD}(P^{q},P^{c})=\sqrt[2]{\sum_{j=1}^{w}\left(p_{j}^{q}-p_{j}^{c}\right) ^{2}}=\sqrt[2]{\sum_{j=1}^{w}\left(\left(s_{j}^{q}-s_{j}^{c}\right)^{2}+f \left(a_{j}^{q}-a_{j}^{c}\right)^{2}\right)} \tag{15}\]  
where \(f\) is a real number between (0, 1), used to adjust the weight between the V axis distance and the \(A\) axis (angle) distance so that the difference between PD and ED approaches 0 as much as possible. If there is no adjustment weight, \(f=1\). We call this method Point Aggregate approximation representation (PAX).  
The PAX enhances the accuracy of the similarity measurement of time series, but there are two factors in this method, and it is not convenient for character variables. Then, we use the _haxMapper_ to map it to a hexadecimal character. The distance between the HAX (HD) strings \(H^{q}\) and \(H^{c}\) is used to measure the similarity distance between the two time series, denoted as  
\[\text{HD}(H^{q},H^{c})=\sqrt[2]{\sum_{j=1}^{w}\left(haxMapper\left(p_{j}^{q} \right)-haxMapper\left(p_{j}^{c}\right)\right)^{2}}=\sqrt[2]{\sum_{j=1}^{w} \left(h_{j}^{q}-h_{j}^{c}\right)^{2}} \tag{16}\]  
where _haxMapper_ may have different mapping ways, using either sequential grid coding mapping or other mapping methods such as the Hilbert curve filling or Z-Ordering curve filling methods. This paper focuses on the basic sequential grid coding method, shown in Figure 7.