# Outlier Reconstruction of NDVI for Vegetation-Cover Dynamic Analyses
## 2 Materials and Methods
### Methods
#### 2.2.5 Sliding-Window-Based Tensor Stream Analysis Algorithm (SWTSA)  
To determine dynamic patterns of NDVI from optical remote-sensing image series, we propose a sliding-window-based tensor stream analysis approach. A window \(\mathbf{W}(d,w)\) consists of a subset of a tensor stream beginning \(\mathcal{X}_{d}\) with size \(w\)[45]. The window was formally denoted as  
\[\mathbf{W}(d,w)=\{\mathcal{X}_{d},\mathcal{X}_{d+1},\mathcal{X}_{d+2}\}, \tag{10}\]  
where \(d=1,2,\ldots,n\), indicates the position of the sliding window, \(\mathcal{X}_{d}\in\mathbb{R}^{I\times I\times K}\). Given a window \(\mathbf{W}(d,w)\), a tensor \(\mathcal{X}_{w}\in\mathbb{R}^{I\times I\times K}\) was extracted from tensor stream for Tucker decomposition upon the window. An approximate tensor \(\widehat{\mathcal{X}}_{w}\) could be reconstructed according to \(\mathcal{G}\) and \(\{\mathbf{U}_{i}|i=1,2,3\}\) on the new window \(\mathbf{W}(d+1,w)\). The parameter \(d\) represents the current position of the sliding window. If the outlier appears at position \(d\), the tensor will be filled with the approximate reconstruction result on the basis of window \(\mathbf{W}(d,w)\), when the window slides from position \(d\) to \((d+1)\), as illustrated in Figure 2.  
Tensor stream analysis was conducted to find the set of orthogonal factor matrices \(\mathbf{U}_{i}\) (\(i=1,2,3\)) to minimize the reconstruction error which is less than given threshold \(\varepsilon\). This optimization problem can be solved by using the gradient-based optimization method [46], where the reconstruction error is defined as  
\[e(\widehat{\mathcal{X}}_{w})=\frac{||\mathcal{X}_{w}-\widehat{\mathcal{X}}_{ w}||_{\text{F}}^{2}}{||\mathcal{X}_{w}||_{\text{F}}^{2}}, \tag{11}\]  
Thus, we assume that \(\mathcal{X}_{w}\in\mathbb{R}^{I\times I\times K}\), and the problem can be formulated as  
\[\min_{\mathcal{G},\mathbf{U}_{1},\mathbf{U}_{2},\mathbf{U}_{3}}\Big{\|} \mathcal{X}_{w}-\llbracket\mathcal{G},\mathbf{U}_{1},\mathbf{U}_{2},\mathbf{U }_{3}\rrbracket\Big{\|}, \tag{12}\]  
In order to obtain the factor matrices, we use the following Forbenius norm to define the objective function for tensor stream analysis on window \(\mathbf{W}(d,w)\in\mathbb{R}^{I\times J\times K}\). \[\mathcal{L} (\mathcal{X}_{w},\mathbf{U}_{1}\mathbf{U}_{2}\,\mathbf{U}_{3}) \tag{13}\] \[= \frac{1}{2}\Big{\|}\mathcal{X}_{w}-\mathcal{G}\times_{1}\mathbf{U }_{1}\times_{2}\mathbf{U}_{2}\times_{3}\mathbf{U}_{3}\Big{\|}_{\text{F}}^{2}\] \[+ \lambda_{w}\Big{(}||\mathcal{G}||_{\text{F}}^{2}+||\mathbf{U}_{1 }||_{\text{F}}^{2}+||\mathbf{U}_{2}||_{\text{F}}^{2}+||\mathbf{U}_{3}||_{ \text{F}}^{2}\Big{)},\]  
Parameter \(\lambda_{w}\) controlling the contribution of different dimensions can be chosen according to the Bayesian information criterion (BIC) [43; 47]. During the experiment, parameter tuning is embedded into the whole iteration, i.e., \(\lambda_{w}\) is modified after each update of \(\mathbf{U}_{i}\). An iterative meta-algorithm is presented in Algorithm 1. Given a window size \(w\) and core tensor \(\mathcal{G}\) ranks \(R_{1}\), \(R_{2}\), \(R_{3}\), SWTSA can be interpreted via the two following steps. * Step 1: Decomposition. Tensor is decomposed on the basis of a given window. This step can be implemented with the following operations: (i) Extract a tensor \(\mathcal{X}_{w}\in\mathbb{R}^{I\times J\times K}\) from tensor stream at the position \(d(d=1,2,\ldots,n)\) on the window size. (ii) Tensor \(\mathcal{X}_{w}\) is decomposed with the methods in Section 2.2.4. * Step 2: Reconstrution. An approximate tensor \(\widehat{\mathcal{X}}_{w}\) could be reconstructed on the basis of \(\mathcal{G}\) and \(\{\mathbf{U}_{i}|i=1,2,3\}\) at a new window \(\mathbf{W}(d+1,w)\). This step involves the following steps: (i) Reconstruction of \(\widehat{\mathcal{X}}_{w}\) according to \(\widehat{\mathcal{X}}_{w}\approx\llbracket\mathcal{G},\mathbf{U}_{1},\mathbf{U }_{2},\mathbf{U}_{3}\rrbracket\). (ii) Calculation of a reconstruction error \(e(\widehat{\mathcal{X}}_{w})\).