# Learning and Mining Player Motion Profiles in Physically Interactive Robogames
## Mathematical Preliminaries
### Gramian Angular Field Images  
The results obtained in this work rely on the transformation of the time series data generated by the player motion into images that can then be processed and understood in terms of emergent patterns that can, in turn, be discovered by state-of-the-art machine learning algorithms. The type of image we have chosen is Gramian Angular Summation/Difference Field (GASF/GADF). Such images had been proposed in the field of time series classification [17], where the authors evaluated the efficacy of representing time series in a polar coordinate system instead of the typical Cartesian coordinates. For a deep understanding of the method, we suggest reading the original paper, where the authors did not only present the idea of GASF/GADF, but also reported experimental results comparing them with other time series imagery techniques. Here, we present an overview of the technique in order to familiarize the reader with such a method and to point out its role in our proposal. In general, in order to obtain a GASF/GADF representation for a time series \(\mathcal{X}=\{x_{1},x_{2},...x_{n}\}\) of size \(n\in\mathbb{N}_{>0}\), rescaling is first performed in order to put the time series in the interval \([\,-1,1]\) or \([\,0,1]\). The second step is to represent the rescaled time series \(\widetilde{\mathcal{X}}\) in polar coordinates, where each sample value is now mapped into the angular cosine and the time stamp information is represented as the radius. The formula for this step is as follows:  
\[ \begin{cases}\phi=\arccos(\widetilde{x}_{i})&-1\leq\widetilde{x}_{i}\leq 1, \widetilde{x}_{i}\in\widetilde{\mathcal{X}}\\ \boldsymbol{r}=\dfrac{t_{i}}{N}&t_{i}\in\mathbb{N}_{>0},\end{cases}  \tag{1}\]  
where \(t_{i}\) is the time stamp and \(N\) plays the role of a normalizer for the span of the polar coordinate system. Some properties of this transformation are known:  
* Property #1: The encoding map of Equation (1) is bijective as \(\cos(\phi)\) is monotonic when \(\phi\in[\,0,\pi]\). Given a time series, the proposed map produces a unique result in the polar coordinate system together with a unique inverse map. * Property #2: As opposed to Cartesian coordinates, polar coordinates preserve absolute temporal relations. * Property #3: Rescaled data in different intervals have different angular bounds. That is, \([\,0,1]\) corresponds to the cosine function in \([\,0,\frac{\pi}{2}\,]\), while cosine values in the interval \([\,-1,1]\) fall into the angular bounds \([\,0,\pi]\). These intervals are known to produce different information granularity in the Gramian angular field, especially for classification tasks [17]. The third step in completing the transformation is to exploit the angular perspective by considering the trigonometric sum/difference between each point. This allows for the identification of the temporal correlation within different time intervals. The two types of GAFs, namely GASF and GADF, are obtained as follows:  
\[ \begin{split} GASF&=[\,\cos(\phi_{i}+\phi\hat{j}] \\ &=\widetilde{\mathcal{X}}^{\prime}\cdot\widetilde{\mathcal{X}}- \sqrt{I-\widetilde{\mathcal{X}}^{2}}^{\prime}\cdot\sqrt{I-\widetilde{\mathcal{ X}}^{2}}\end{split}  \tag{2}\]\[GADF = [\sin(\phi_{i}+\phi j] \tag{3}\] \[= \sqrt{I-\widetilde{\mathcal{X}}^{2}}^{\prime}\cdot\widetilde{ \mathcal{X}}-\widetilde{\mathcal{X}}^{\prime}\cdot\sqrt{I-\widetilde{\mathcal{ X}}^{2}}\]  
\(I\) is the unit row vector. After translating the time series from the Cartesian to polar coordinate system, each time step in it is taken as a 1D metric space. By defining the inner product as \(<x,y>=x\cdot y-\sqrt{1-x^{2}}\cdot\sqrt{1-y^{2}}\) and \(<x,y>=\sqrt{1-x^{2}}\cdot y-x\cdot\sqrt{1-y^{2}}\), respectively, the GAFs become quasi-Gramian matrices, since the defined \(<x,y>\) do not satisfy the property of linearity in inner-product space. Still, according to [17], the GAFs have several advantages:  
* Advantage #1: They provide a way to preserve temporal information.