#### 2.1. Adaptive Pendular Truncation Algorithm

Let ${\overrightarrow{x}}_{N}=\left\{{x}_{1},\dots {x}_{N}\right\}$ be a sample of size N of independent, identically-distributed random variables with unknown distribution F(x), where $F(x)=(1-\epsilon )G(x)+\epsilon H(x)$ is Tukey’s model of outliers, $G(x)$ is the reference aprioristic distribution, $H(x)$ is the outlier distribution, $\epsilon $ is the outlier fraction, and $k=[N\cdot \epsilon ]$ is the number of outliers in the sample. We assume that $F(x),\text{}G(x)$, and $H(x)$ are absolutely continuous unimodal distributions with densities $f(x),\text{}g(x)$, and $h(x)$, respectively.

The standard problem of detection and selection of

$k$ outliers remote from the center of the distribution

$F(x)$ reduces to the problem of testing of hypotheses:

Let us consider an anomaly measure based on the functional

where

$\mathsf{\phi}(x)$ is the known function, and introduce a sample

${\overrightarrow{x}}_{n}=\left\{{x}_{1},\dots {x}_{n}\right\}$,

$n=N,N-1,\dots ,[\raisebox{1ex}{$N$}\!\left/ \!\raisebox{-1ex}{$2$}\right.]$ with variable size. According to the anomaly measure, we transform the sample observations to the form

Let us sort the variables ${t}_{i}(n)=\left|{T}_{i}({x}_{i})\right|$, ${t}_{(1)}(n)<{t}_{(2)}(n)<\dots <{t}_{(n)}(n)$, and consider the consecutive procedure of detection of applicants for outliers. The outliers according to the anomaly measure T are represented by extreme ordinal statistics ${t}_{(N)}(n),\dots ,{t}_{(N-k+1)}(n)$. The observation ${x}_{{i}_{0}}$ $({x}_{{i}_{0}}=\mathrm{arg}\mathrm{max}\left|{T}_{i}({x}_{i})\right|)$ corresponding to ${t}_{(n)}(n)$ is an applicant for outlier status; therefore, we remove it from the sample ${\overrightarrow{x}}_{n}=\left\{{x}_{1},\dots {x}_{n}\right\}$. As a result, we obtain the sample ${\overrightarrow{x}}_{n-1}$ of size (n − 1). This procedure of detection of applicants for outlier status is repeated for $n=N,N-1,\dots ,[\raisebox{1ex}{$N$}\!\left/ \!\raisebox{-1ex}{$2$}\right.]$. The sample observations thus removed are not outliers; they are only applicants for outliers. To determine which of them are outliers, an additional decision making procedure is required.

Let us introduce the statistic

where

Since ${S}_{n}={S}_{n-1}+{({t}_{(n)}(n))}^{2}$ and ${S}_{N}=const(N)$, it follows that ${S}_{n-1}<{S}_{n}$ and, hence, the statistic 0 < L_{n} ≤ 1 is a monotonically decreasing function of n.

Let us find average values of the statistics

$E{S}_{N},\text{}E{S}_{n}$,

$E{({t}_{(n)}(n))}^{2}$, and

$E{L}_{n}=\frac{E{S}_{n}}{E{S}_{N}}+0({N}^{-1})$:

where

${\mathsf{\sigma}}_{1}^{2}={\displaystyle \int {(t-Et)}^{2}dG(t)}\text{}\mathrm{and}\text{}{\mathsf{\sigma}}_{2}^{2}={\displaystyle \int {(t-Et)}^{2}dH(t)}$. Let us consider the first-order differences of

${L}_{n}$:

and find the average value of the difference

$E{\Delta}_{n}^{1}(n)$:

As follows from Equation (10), the first-order differences $E{\Delta}_{n}^{1}(n)$ in the presence of k outliers $\left(n=N,N-1,\dots ,N-k+1\right)$ are, on average, constant at the level $B\cdot ({\mathsf{\sigma}}_{1}^{2}+{\mathsf{\sigma}}_{2}^{2})$, and in the absence of outliers ($n=(N-k),(N-k-1),\dots ,[\raisebox{1ex}{$N$}\!\left/ \!\raisebox{-1ex}{$2$}\right.]$), they are, on average, constant at the level $B\cdot {\mathsf{\sigma}}_{1}^{2}$, where $B=const(N)$. At the point $n=N-k$, the function $E{\Delta}_{n}^{1}(n)$ jumps on average by $\delta ={\mathsf{\sigma}}_{2}^{2}$.

Let us consider the second-order differences ${\Delta}_{n}^{2}(n)={\Delta}_{n}^{1}(n)-{\Delta}_{n-1}^{1}(n)$. They are on average equal to zero, and at the point $n=N-k$, a delta-shaped spike of the function $E{\Delta}_{n}^{2}(n)$ is observed.

The special features in the behavior of the statistics

${L}_{n}$,

${\Delta}_{n}^{1}$, and

${\Delta}_{n}^{2}$ indicated above allow us to construct a consecutive procedure of adaptive pendular truncation (APT) for outlier detection and selection based on the empirical influence and sensitivity functions [

7,

8] that generalizes the adaptive pendular truncation algorithm (APTA) [

20].

#### 2.2. Adaptive Pendular Truncation Algorithm

For the sample ${\overrightarrow{x}}_{N}=\left\{{x}_{1},\dots {x}_{N}\right\}$, $n=N,N-1,\dots ,[\raisebox{1ex}{$N$}\!\left/ \!\raisebox{-1ex}{$2$}\right.]$, we perform the following procedures:

Calculate ${\overline{T}}_{n}({\overrightarrow{x}}_{n})=\frac{1}{n}{\displaystyle \sum _{i=1}^{n}\mathsf{\phi}({x}_{i})}$,

Calculate ${T}_{i}({x}_{i})=(\mathsf{\phi}({x}_{i})-{\overline{T}}_{n}({\overrightarrow{x}}_{n}))$,

Sort the variables ${t}_{i}(n)=\left|{T}_{i}({x}_{i})\right|$, ${t}_{(1)}(n)<{t}_{(2)}(n)<\dots <{t}_{(n)}(n)$,

Calculate ${S}_{n}=\frac{1}{n-1}{\displaystyle \sum _{j=1}^{n}{({T}_{i}({x}_{i}))}^{2}}$,

Calculate ${L}_{n}=\frac{{S}_{n}}{{S}_{N}}$,

Find the first-order differences ${\Delta}_{n}^{1}={L}_{n}-{L}_{n-1}$,

Find the second-order differences ${\Delta}_{n}^{2}(n)={\Delta}_{n}^{1}(n)-{\Delta}_{n-1}^{1}(n)$,

Remove the observation ${x}_{{i}_{0}}$ corresponding to ${t}_{(n)}(n)$ from the sample,

Execute the above cycle from item 1 to item 9 for $n=N,N-1,\dots ,[\raisebox{1ex}{$N$}\!\left/ \!\raisebox{-1ex}{$2$}\right.]$.

We note that the APTA is nonparametric, that is, the result of its execution is independent of the form of the distribution and automatically finds on which side of the center ${\overline{T}}_{n}({\overrightarrow{x}}_{n})=\frac{1}{n}{\displaystyle \sum _{i=1}^{n}\mathsf{\phi}({x}_{i})}$ the applicant for the outlier status is located.

#### Generalization of the Algorithm

As the anomaly measure and the transformation ${T}_{i}({x}_{i})$ described by Equation (1), the functionals $T={\displaystyle \int \mathsf{\phi}(x,\mathsf{\theta})}dF(x)$, ${T}_{i}({x}_{i})=\mathsf{\phi}({x}_{i},{\mathsf{\theta}}_{N})-{\overline{T}}_{n}({\overrightarrow{x}}_{n},{\mathsf{\theta}}_{N})$, and ${\overline{T}}_{n}({\overrightarrow{x}}_{n})=\frac{1}{n}{\displaystyle \sum _{i=1}^{n}\mathsf{\phi}({x}_{i},{\mathsf{\theta}}_{N})}$ can be used, where $\mathsf{\phi}(x,\mathsf{\theta})$ is a continuous function with bounded variation, $\mathsf{\theta}$ is a parameter, and ${\mathsf{\theta}}_{N}$ is an estimate of the parameter $\mathsf{\theta}$.