# Sequence-Information Recognition Method Based on Integrated mDTW
## 3 Methodology
### Multidimensional DTW  
Similar to the conventional one-dimensional Dynamic Time Warping (DTW) approach, the method presented here encompasses two primary processes: the forward process and the backward process. In the fundamental stage, the algorithm computes the point-to-point distance matrix, a critical step in establishing the foundational structure for subsequent analyses. This matrix serves as the basis for understanding the dissimilarity between corresponding points in the sequences. Following this, the warping process comes into play, where the optimized point-matching relationships are computed. In the forward process, the algorithm systematically evaluates the distances between each point in the sequences, creating a comprehensive matrix that encapsulates the pairwise dissimilarities. This matrix lays the groundwork for subsequent alignment, forming the foundation upon which the algorithm can identify the optimal alignment path. The backward process is an equally crucial component, focusing on the derivation of the optimal warping path based on the accumulated point-to-point distances. By iteratively backtracking through the matrix, the algorithm refines the matching relationship between points, ultimately arriving at an alignment that minimizes the overall dissimilarity. Together, these dual processes, the forward and backward stages, synergistically contribute to the effectiveness of the proposed method in capturing the nuanced relationships and achieving optimal alignment between two sequences using the Dynamic Time Warping technique. Given a couple of sequences \(\{SEQ_{1}\in\mathcal{R}^{n\times d},SEQ_{2}\in\mathcal{R}^{m\times d}\}\), mDTW first computes a \(Dm\) matrix by Equation (1)  
\[Dm_{ij}=dsum(\alpha,Seq_{1i},Seq_{2j}) \tag{1}\]  
The variables in formulas are as follows: \(\alpha\) is a weight vector of different values in \(Seq\), and \(dsum\) is a user-defined formula. Data format of online Chinese handwriting sample is configured as \(seq\in\mathcal{R}^{n\times 7}\), each temporal slice \(seq_{i}=\{x_{i},y_{i},\Delta x_{i},\Delta y_{i},s_{i}\}\). Where \(n\) is the number of points in a handwriting sequence, \(x_{i},y_{i}\in\mathcal{R}\) are the location of a point, \(\Delta x_{i},\Delta y_{i}\in\mathcal{R}\) are pen tip displacement of the same point and \(s_{i}\in\{0,1\}\) is pen tip state. Here \(s_{i}=\{1,0,0\}\) indicates the pen tip will continue the writing process, \(s_{i}=\{0,1,0\}\) indicates  
Figure 1: Schematic diagram of the core framework process. stroke ends and the pen tip will be raised and moved to another location, \(s_{i}=\left\{0,0,1\right\}\) indicates the end of the character. Then \(dsum\) is defined as Equations (2)-(5). \[dsum=\alpha_{1}\cdot ld+\alpha_{2}\cdot dd+\alpha_{3}\cdot sd \tag{2}\]  
\[ld=\sqrt{\left(x_{1i}-x_{2j}\right)^{2}+\left(y_{1i}-y_{2j}\right)^{2}} \tag{3}\]  
\[dd=\sqrt{\left(\Delta x_{1i}-\Delta x_{2j}\right)^{2}+\left(\Delta y_{1i}- \Delta y_{2j}\right)^{2}} \tag{4}\]  
\[sd=\beta_{1}|s_{11}-s_{1}|+\beta_{2}|s_{i2}-s_{2}|+\beta_{3}|s_{i3}-s_{j3}| \tag{5}\]  
\(ld,dd,sd\) are location distance, displacement distance, and state distance, respectively. \(ld\) represents the Euclidean distance between two points from different sequences, which directly reflects the spatial distance relationship between the relevant points. It is the most important constraint for our mDTW point matching. \(dd\) represents the Euclidean distance between the difference vectors of two points and their previous sampling time steps, which can be understood as the similarity in direction. Its calculation formula is \(\Delta X=X_{t}-X_{t-1}\). For example, in a plane, if the difference vectors of two sequence points both indicate that the movement direction of the curve/trajectory at this time is to the left, then they should naturally obtain a certain degree of matching similarity. A higher value of \(\alpha_{i}\) means we place more attention on the similarity of the corresponding factor to match the points.