## 2 Methodology
### K-Means Clustering Algorithm and Its Evaluation Indicator  
It is considered that GNSS signals in complex environments are generally divided into two main types: direct signals and indirect signals (including multipath and NLOS signals), and each type of signal has a certain internal relationship with the above four feature parameters.  
In accordance with this characteristic, the K-means algorithm is used for signal clustering. When the sample is closest to one of the cluster centers, it is classified into this class.  
For a given sample set \(S=\{x_{1},x_{2},\cdots x_{m}\}\), where \(x_{m}\)= \(\{e_{m},CNO_{m},v_{m},\cdots\text{con}_{m}\}\) represents the standardized feature vector of satellite elevation angle, carrier-to-noise ratio, pseudorange residual, and pseudorange rate consistency. This paper assigns corresponding weights to the feature parameters based on experience [22], which are set as \(\left[\sqrt{0.2},\sqrt{0.3},\sqrt{0.2},\sqrt{0.3}\right],\) respectively. The K-means algorithm divides them into \(k\) clusters \(\hat{C}=\{C_{1},C_{2},\cdots C_{k}\}\) so that the sum of squared Euclidean distances from each data point to its nearest cluster center is minimized, namely:  
\[\text{argmin}_{\hat{C}}\sum_{i=1}^{k}\sum_{x\in C_{i}}\|x-\mu_{i}\|^{2} \tag{3}\]  
where \(\mu_{i}\) is the mean vector of the cluster \(C_{i}\), and can be expressed as:  
\[\mu_{i}=\frac{1}{|\hat{C_{i}}|}\sum_{x\in C_{i}}x \tag{4}\]The basic process of the K-means algorithm is as follows [41]:  
(1) This algorithm randomly selects \(k\) samples as the initial cluster center;  
(2) For the remaining samples, according to the distance of their cluster centers, they are classified into the nearest cluster;  
(3) For each cluster, the mean of all samples is calculated as the new cluster center;  
(4) Repeat steps (2) and (3) until the cluster centers no longer change.  
Based on the above calculations, all GNSS signals are classified into different clusters. The K-means algorithm needs to specify the value of \(k\) in advance, which is usually defaulted to 2 or 3. However, due to the complexity of the scenario and the correlation between GNSS signals, 2 and 3 are often not the optimal \(k\) values. Additionally, the difference between the clustering results corresponding to different \(k\) values is not obvious. Therefore, this paper chooses the Davies-Bouldin Indicator (DBI) as the internal evaluation index of the clustering effect [42].  
DBI is defined as the average similarity between each cluster \(C_{i}\), \(i=1,2,\cdots,k\) and its the most similar one \(C_{j}\), where the similarity is expressed by the ratio of the intra-cluster distance to the inter-cluster distance. The minimum value of DBI is 0, and the smaller the value, the better the clustering effect. The specific calculation formula is:  
\[I_{\text{DBI}}=\frac{1}{k}\sum_{i=1}^{k}\underset{i\
eq j}{\max}R_{ij} \tag{5}\]  
where \(k\) is the number of clusters; \(R_{ij}\) denotes similarity that can be constructed by a simple choice as follows so that it can keep nonnegative and symmetric:  
\[R_{ij}=\frac{d(s_{i})+d(s_{j})}{d_{ij}} \tag{6}\]  
where \(d(s_{i})\) and \(d(s_{j})\) mean the average distance between each point of cluster data to the centroid of that cluster also known as cluster diameter, individually; \(d_{ij}\) is the distance between cluster centroids \(i\) and \(j\), which represents the dispersion degree of data point for cluster centroids \(i\) and \(j\).