# Univariate Outlier Detection: Precision-Driven Algorithm for Single-Cluster Scenarios
## 3 Methodology  
In this study, we propose a novel algorithm designed for anomaly detection in univariate datasets, particularly when a singular cluster is expected. We assume that the data consist of positive real values. **The Algorithm Steps:**  
Step 1: Normalization  
The initial step involves addressing the filtration of zero values from the dataset, considering their potential status as outliers contingent upon contextual considerations. Subsequently, the data are normalized to the range \([0,1]\) This is typically achieved using techniques such as Min-Max scaling. The formula for Min-Max scaling can be expressed as shown below:  
\[X_{\text{scaled}}=\frac{X-X_{\text{min}}}{X_{\text{max}}-X_{\text{min}}} \tag{1}\]  
where: \(X\) is the original data point, \(X_{\text{scaled}}\) is the scaled data point, \(X_{\text{min}}\) is the minimum value in the dataset, and \(X_{\text{max}}\) is the maximum value in the dataset. Step 2: Lower Value Filtration  
To establish a decisive boundary for anomaly identification, we filter out higher normalized values. The filtration threshold is set as the greater of either the median or the mean of the normalized values. This choice takes into account the positioning of the median and mean in positively or negatively skewed distributions. Values greater than the threshold are set to 0, while values below the threshold are replaced by the difference between the value and the reference value. Figure 1 illustrates four distinct probability distributions: a normal distribution characterized by a symmetrical bell curve; a negatively skewed distribution, where the mean  
is typically less than the median and the tail extends toward lower values; a positively skewed distribution, where the mean is typically greater than the median and the tail extends toward higher values; and a uniform distribution, featuring constant probability density across the range of values. The same principle applies to other distributions, such as exponential, bimodal, and multimodal distributions, where the relationship between the mean and median may vary. **The filter used is as follows:**  
\[\sigma\left(s^{*},m,a\right)= \begin{cases}(s^{*}-\max(m,a))^{2}&\text{if }s^{*}<\max(m,a)\\ 0&\text{if }s^{*}\geq\max(m,a)\end{cases}  \tag{2}\]  
where \(s^{*}\) is the normalized value, \(m\) is the median of the normalized values, and \(a\) is the average of the normalized values. Since the data are scaled between 0 and 1, values below the threshold are replaced by the squared distance from the threshold. This distance also falls between 0 and 1 with values closer to 0 indicating greater proximity to the threshold. The squared function is used to emphasize the difference between values near 0 and those near 1. Squaring heavily compresses values closer to 0, bunching them together. Conversely, the effect on values closer to 1 is less pronounced. However, for high-sensitivity anomaly detection, Euclidean distance might be preferable because it avoids compressing small distances. Step 3: Hyperbolic Transformation  
For a detailed exploration of our non-linear transformation strategy, Figure 2 presents the standard hyperbolic tangent transformation (tanh) curve, providing a benchmark for understanding subsequent modifications. **The formula for the modified hyperbolic tangent transformation is:**  
\[f(\sigma\left(s^{*},m,a\right))=\tanh\ \left(\alpha\cdot\sigma\left(s^{*},m,a \right)-\beta\right)\cdot\lambda+\eta \tag{3}\]  
**Parameters:**  
* \(\alpha\): Controls the slope of the transformation. * \(\beta\): Shifts the center of the tanh curve. * \(\lambda\): Scales the output to fit the desired range. * \(\eta\): Shifts the entire graph vertically. Step 4: Detection of Outliers  
Figure 1: Illustrating random normal, negatively skewed, positively skewed, and uniform distributions. The final result of the transformation splits outliers from the data with outliers having the highest transformed values.