# Functional Outlier Detection by Means of h-Mode Depth and Dynamic Time Warping
### Proposed Detection Algorithm  
The practical implementation of the detection algorithm is presented below, and several clarifications will be made. First, the approach does not include a projection of the considered functional data onto a functional expansion to homogenize the dataset. This preliminary step may be important in applications with heterogeneous time grids, if the data are observed with noise etc. Here, it will be supposed that the domain of the data is already uniform. Furthermore, this kind of projections are not necessary most times when estimating non-parametric features, such as \(L^{2}\) norms. Secondly, it is important to note that in the ideal case, the estimation of the GMM should be made based on a non-contaminated dataset, i.e., without outliers. These existent outliers should be separated before the estimation if the objective is to model the joint distribution of the desired features to avoid the introduction of a non-controlled bias. However, this knowledge is not available _a priori_, which justifies the trimming procedure of Algorithm 1. It is worth mentioning the iterative step. Even though it is not explicitly noted, the \(K\) components that are retained depend on the chosen sample for each bootstrap group. The task of reestimating the parameters for each GMM to optimize the number of components is not computationally expensive for small values of \(K\), which is appropriate for datasets that do not present a high degree of multimodality and to avoid overfitting the data. In our simulations, \(K_{max}=10\). Another important remark on the algorithm is the _extraction_ step, where the most outlying functions on the set according to the \(\hat{\theta}_{i}\) are separated from the original dataset, and the procedure is re-applied to the remaining functions until a desired homogeneity level is reached. Naturally, in the case where many samples are available, some extreme data realizations are bound to appear. Therefore, regardless of the chosen value for \(\alpha\), these significant data might be separated from the set even though they do not actually contaminate the set since, although unlikely, these data appear due to the nature of the underlying generative process. Separating (trimming) all these data may introduce a bias in the estimation of the successive GMM. This is a known problem in the outlier detection domain. An example for the functional data case can be found in [9]. ```
Result: Set of outlyingness scores \(\{\theta_{i}\}_{i=1}^{n}\), and set of outliers \(o\subset\{z_{i}\}_{i=1}^{n}\) 1. Check if the sample of functional data is uniformly sampled. Otherwise, Project the data onto a basis of \(\mathcal{F}\) until a desired level of error \(||\hat{z}_{i}-z_{i}||\) (with \(\hat{z}_{i}\) being the projected samples on the basis) is reached. Uniformly resample in this grid; 2. Choose a family of \(R\) feature functions and project \(\{z_{i}\}_{i=1}^{n}\) onto the feature space \(\mathcal{S}\subset\mathbb{R}^{R}\); 3.for\(K\in\{1,...,K_{max}\}\)do 1. Choose (mainly or randomly) a starting set of parameters \(\
u^{\text{old}}=\{\mathbf{\mu}_{k}^{\text{old}},\mathbf{\Sigma}_{k}^{\text{old}},\bm {w}_{k}^{\text{old}}\}_{k=1}^{K}\); 2. E-step. Evaluate the corresponding responsibilities \(\gamma(g_{k})\) for each given point \(\mathbf{u}_{i}\in\{\mathbf{u}_{i}\}_{i=1}^{n}\); 3. M-step. Re-estimate the parameters through: \[\mathbf{\mu}_{k}^{\text{new}}=\frac{1}{n_{k}}\sum_{i=1}^{n}\gamma(g_{k})\mathbf{u}_{i}\] \[\mathbf{\Sigma}_{k}^{\text{new}}=\frac{1}{n_{k}}\sum_{i=1}^{n}\gamma(g_{k})(\mathbf{u}_ {i}-\mathbf{\mu}_{k}^{\text{new}})(\mathbf{u}_{i}-\mathbf{\mu}_{k}^{\text{new}})\] \[\mathbf{w}_{k}^{\text{new}}=\frac{n_{k}}{n}\] where \(n_{k}\) represents the number of observations assigned to the \(k\)th Gaussian in the mixture, i.e., \(n_{k}=\sum_{k=1}^{K}\gamma(g_{k})\); 4. Check \(||\mathbf{u}_{i}-\mathbf{\mu}_{k}||_{L^{2}}<\epsilon,\epsilon=\inf\limits_{S}\lVert \mathbf{u}_{i}-\mathbf{\mu}_{k}\rVert_{L^{2}},\forall i,j\in\{1,...,n\}\times\{1,...,n\}\); 5.