## 3 Automatically Choosing the Number of Clusters
### Density Peaks Algorithm
Consider the quantity \(\theta_{i}\) defined as the difference between \(\delta_{i}\) and \(\tau_{i}\):  
\[\theta_{i}=\delta_{i}-\tau_{i}\quad\text{ for }T_{i}=T_{1},\dots,T_{N}. \tag{37}\]  
The comparative magnitude of \(\theta_{i}\) must be revealed to find the potential cluster centers. Moreover, the distance between a snake \(T_{i}\) and another one with a higher density is greater than to a snake with a lower density if the \(\delta_{i}\gg\tau_{i}\). It is known that the area of low density is closer than the area of high density to a snake \(T_{i}\) surrounded with a lower density. Onthe other hand, the snakes that have the higher density are relatively distant. Consequently, the quantity \(\theta_{i}\) denotes the relative magnitude of \(\delta_{i}\). We substitute \(\delta_{i}\) by \(\theta_{i}\) in the decision graph and set \(\gamma_{i}=\rho_{i}*\theta_{i}\). Thus, the center points with high \(\gamma_{i}\) values will pop-out in the decision graph. The mutual K-nearest-neighbor graph is used in order to compute the density measure for all snakes [31]. The mutual K-nearest-neighbor graph (mKNN graph) is defined as an un-directed graph where there is an edge that connects both snakes \(T_{i}\) and \(T_{j}\) only if one of them belongs to the K-nearest neighbors of the other. Regarding the original definition of the density measure, the new density measure is influenced through both the cutoff distance \(dc\) and each distance \(d(T_{i},T_{j})\) between two points \(T_{i}\) and \(T_{j}\). The new density measure is defined as follows:  
\[\rho_{i}=\sum_{T_{j}\in\mathcal{N}_{KT_{i}}}e^{-(\frac{d(T_{i},T_{j})^{2}}{d_ {i}^{2}})}, \tag{38}\]  
where \(\mathcal{N}_{KT_{i}}\) is the set of connected snakes in the mKNN graph for each snake \(T_{i}\). The mKNN graph provides a clear direction if a snake must be revealed in the calculation of \(\rho_{i}\). The minimum distance \(\delta_{i}\) from snake \(T_{i}\) to the higher-density snake is still the same as the original definition that is defined in Equation (35). In order to find the number of class centers, we can plot, for each snake, the \(\gamma_{i}=\rho_{i}*\theta_{i}\) to detect the centers and select the cluster centers using the following formula:  
\[\gamma_{i}=\rho_{i}*\theta_{i}>TH, \tag{39}\]  
such that the threshold \(TH\) is a parameter selected by the user. However, this method cannot determine the \(TH\) parameter for different data sets. In this paper, this problem is solved with a statistic-based approach to identify the cluster centers from the decision graph automatically. This approach is based on the minimum distance \(\theta_{i}\) to be much larger than among the nearest neighbors' distances only when the snake \(T_{i}\) has the maximum density. This provides an important feature that specifies the cluster center using an outlier detection that includes the probability density function in the decision graph at a particular density \(\rho_{i}\)[32]. The outliers are specified by the following threshold \(TH_{d}\):  
\[TH_{d}(\rho_{i})=\mu(\rho_{i})+3\times\sigma(\rho_{i}). \tag{40}\]  
The two parameters \(\mu(\rho_{i})\) and \(\sigma(\rho_{i})\) are defined as follows:  
\[\mu(\rho_{i})=\frac{\sum_{T_{j}=1,T_{j}\
eq T_{i}}^{N}\rho_{i}\times e^{-\frac {1}{2}\times\left(\frac{\rho_{i}-\rho_{i}}{d}\right)^{2}}}{\sum_{T_{2}=1,T_{2} \
eq T_{i}}^{N}e^{\frac{1}{2}\times\left(\frac{\rho_{i}-\rho_{i}}{d}\right)^{2 }}}, \tag{41}\]  
\[\sigma^{2}(\rho_{i})=\frac{\sum_{T_{j}=1,T_{j}\
eq T_{i}}^{N}\left[e^{2}+\left( \theta_{j}-\mu_{y}(\rho_{i})\right)^{2}\right]\times e^{\frac{1}{2}\times \left(\frac{\rho_{i}-\rho_{i}}{d}\right)^{2}}}{\sum_{T_{2}=1,T_{2}\
eq T_{i}}^ {N}e^{-\frac{1}{2}\times\left(\frac{\rho_{i}-\rho_{i}}{d}\right)^{2}}}, \tag{42}\]  
where \(a\) and \(b\) are the two-dimensional kernel widths. They are defined as follows:  
\[ \begin{array}{ll}a=\alpha_{0}\times\sigma_{\rho_{i}}&0<\alpha<1\\ b=\beta_{0}\times\sigma_{\theta_{i}}&0<\beta<1,\end{array}