# Functional Outlier Detection by Means of h-Mode Depth and Dynamic Time Warping
## 4 Analytical Test Cases
### Numerical Test Protocol  
In all the simulation experiments, there will be a total number of \(n=50\) curves, 49 of which are generated by a reference model, and one is the contaminating outlier. The functions are defined in the interval \([0,1]\), with a grid of 30 equally spaced points and \(B=10\) bootstrap groups. Using the previous notation for the DTW algorithm, \(V=W=30\) points. The description of the models for these control simulation tests is as follows:  
* Model 1. \(Z(t)=4t+G(t)\) is the function generator for the reference set of curves. In this case, the outliers follow the distribution \(Z_{o}(t)=4t+G(t)+2\mathbb{1}_{\{(t_{I}<t)\}}\). * Model 2. The reference model for the curve generation remains \(Z(t)=4t+G(t)\), whereas the outliers are now generated from the distribution \(Z_{o}(t)=4t+G(t)+2\mathbb{1}_{\{(t_{I}<t<t_{I}+3)\}}\). * Model 3. Here the reference model becomes \(Z(t)=30t(1-t)^{3/2}+G(t)\). The outliers are generated from \(Z_{o}(t)=30(1-t)t^{3/2}+G(t)\). * Model 4. For this last case, we keep the reference model as it is for Model 1 and Model 2, but the outliers simply consist of the sole deterministic part \(Z_{o}(t)=4t\) (the Gaussian component is removed). Similar models to 1 and 2 can be found in [35; 36; 37], although the multiplicative factor of the indicator function has been reduced to make the outliers less apparent. Model 3 was also considered in [25; 35]. The fourth model was developed here to test the detection capabilities of pure shape outliers. These models (see Figure 1) or similar ones have already been tested with existing methodologies, and they were therefore included here to facilitate the comparability with other detection methods. In all cases, a bivariate Gaussian mixture model is adjusted to a pair of selected features and the outlier detection procedure is applied thereafter. Four commonly used features in the functional data analysis framework will be considered:  
* The modified band depth (BD) (see Equation (3) of the Supplementary Material),
* The h-mode depth (see Equation (4) of the Supplementary Material),
* The dynamic time warping (see Equation (7) of the Supplementary Material),
* The L\({}^{2}\) norm, which is one of the most intuitive and widely used metrics that can be applied to functional data. It takes the form: \(||z(t)||_{2}=\Big{(}\int_{\mathbb{R}}|z(t)|^{2}dt\Big{)}^{1/2}\). Figure 1: Examples of the four analytical test cases. The blue curves correspond to the 49 ones that are generated from the main model, whereas the red one corresponds to the outlier. The detection procedure is applied to \(N=100\) replications of each model. We shall use two scores to evaluate the quality of the detection procedure. The first one will naturally be the estimated \(\theta\) values of the outlier in each model and replication. This parameter is directly linked to the probability of being more anomalous than the outliers if the model is correct. Therefore, the distribution of values of \(\theta_{i},\forall i\in\{1,...,n\}\) constitutes an indicator of the detected outlying nature of the function. The second score is the average ranking of the outlier with respect to the total population of data. Since the \(\theta_{i}\) score provides an ordering of the anomalous nature of each element in the set of curves, so it is possible to rank the data accordingly to said metric. In industrial applications, this ranking can be followed by the engineer to analyze particular data (e.g., numerical simulations) from the most suspicious (potentially interesting) datum to less suspicious ones. Several tests evaluating the performance of the different couples of measures can be found in the supplementary material of the paper. In particular, it can be seen that the use of the h-mode depth and the DTW seem appropriate for the detection of the considered types of outliers. The use of the h-mode depth allows the detection of magnitude outliers taking into account the areas of the \((t,f(t))\) plane where the density of curves is less significant.