# An Application of the Associate Hopfield Network for Pattern Matching in Chart Analysis
## 2 Related Work  
Several current similarity-based pattern matching approaches are reviewed in this section. The TD approach in template-based pattern matching measures the point-to-point similarity between the predefined template and the segmented subsequences. The similarity can be described as a weighted combination of the amplitude distance (AD) and temporal distance (TD). The amplitude distance can capture vertical distortion and the temporal distance reflects the horizontal disparity. AD is defined as follows:  
\[AD(SP,Q)= \sqrt{\frac{1}{n}\sum_{k=1}^{n}(sp_{k}-q_{k})^{2}} \tag{1}\]  
Here, \(SP\) and \(sp_{k}\) denote the extracted points with the PIP segmentation method. \(q_{k}\) is the point of the predefined template. TD is defined as follows:  
\[TD(SP,Q)= \sqrt{\frac{1}{n-1}\sum_{k=2}^{n}(sp_{k}^{t}-q_{k}^{t})^{2}} \tag{2}\]  
where \(sp_{k}^{t}\) and \(q_{k}^{t}\) denotes the coordinate of the point in time dimension. The similarity measure is in the following form:  
\[D(SP,Q)=w_{1}\times AD(SP,Q)+(1-w_{1})\times TD(SP,Q) \tag{3}\]  
usually, \(w_{1}\) is set to be 0.5 in the experiment of [2; 3; 5], we follow this setting in our experiment. Furthermore, we set a threshold for the similarity measure: Once \(D(SP,Q)\) is lower than the preset threshold, the stored pattern with the minimum \(D\) would be accepted as the matching pattern. The ED approach calculates the point-to-point distance between the query template and the sequences without segmentation. Let the predefined pattern be denoted as \(Y(y_{1},\cdots,y_{n})\) and the time series sequences be denoted as \(X(x_{1},\cdots,x_{n})\). We can easily get the similarity by the following:  
\[ED(X,Y)= \sqrt{\sum_{i=1}^{n}(x_{i}-y_{i})^{2}} \tag{4}\]  
same as above, we set a threshold, once the sequence got a minimum \(ED(X,Y)\) that was lower than the threshold, it accepts the corresponding pattern. DTW has been applied in time series pattern detection by [PERSON] et al. [15] in 1994. It has been widely used in speech recognition, gesture recognition and time series clustering since it was prevented. In time-series data processing, the length of the two sequences that need to be compared for similarity may not be equal. In such a case, the ED approach can not measure the similarity of two different size sequences of time series data efficiently. Figure 1A is the point-to-point computation of the ED method, Figure 1B is the demonstration of DTW, for each data point in the time series \(T\), it considers the distance between the point and the other all points in the sequence \(S\). DTW is based on the dynamic programming approach, given two sequences \(S(s_{1},\cdots,s_{n})\) and \(T(t_{1},\cdots,t_{m})\) we can form an \(n\)-by-\(m\) matrix \(\gamma\), the matrix elements \(d(s_{i},t_{j})\) represent the Euclidean distance of the points\(s_{i}\) and \(t_{i}\). The warping path \(W(w_{1},\cdots,w_{k})\) shown in Figure 2 maps the elements in \(S\) and \(T\). The dynamic time warping problem can be solved by minimizing the warping path. \[DTW(S,T)=\min\sqrt{\sum_{k=1}^{k}w_{k}} \tag{5}\]  
The dynamic programming formulation is based on the following recursive equation:  
\[\gamma(i,j)=d(s_{i},t_{j})+\min\left\{\gamma(i-1,j-1),\gamma(i-1,j),\gamma(i,j- 1)\right\} \tag{6}\]  
where \(\gamma(i,j)\) denotes the cumulative distance of \((i,j)\). In the work of [PERSON] et al. [27], the DTW algorithm is utilized for intraday price pattern matching. They constructed two sets of fixed patterns and used them as the matching templates. However, the computational complexity of DTW is \(O(m\times n)\), which is not efficient for large scale financial time series pattern recognition. In [28], [PERSON] et al. proposed a scaling up DTW for massive data processing. Their main idea is to reduce the data points by the piecewise linear representation (PLR) segmentation approach. Figure 1: (**A**) Euclidean distance approach, (**B**) Dynamic time warping approach. Figure 2: The warping path in DTW.