# Wi-Fi Fingerprint-Based Indoor Localization Method via Standard Particle Swarm Optimization
## 3 System Overview
### SPSO Algorithm for Localization
Moreover, it still performs well in the presence of mild outliers. \begin{table}
\begin{tabular}{l c c c c c} \hline \hline
**Performance Metrics** & **SPSO** & **KNN** & **SVM** & **LR** & **RF** \\ \hline MSE (m) & 6.0433 & 7.6718 & 8.6224 & 13.6885 & 15.1111 \\ MAE (m) & 2.6288 & 3.1389 & 3.0370 & 3.8667 & 4.1630 \\ RMSE (m) & 2.4583 & 2.7698 & 2.9364 & 3.6998 & 3.8873 \\ STD (m) & 1.3076 & 1.2758 & 1.5789 & 2.0518 & 2.0777 \\ Accuracy (m) & 2.0817 & 2.4585 & 2.4757 & 3.0788 & 3.2855 \\
25\% Error (m) & 1.0122 & 1.5104 & 1.0000 & 1.4142 & 1.4142 \\
50\% Error (m) & 1.8329 & 2.2451 & 2.2361 & 2.2361 & 3.1623 \\
75\% Error (m) & 2.7831 & 3.2639 & 3.1623 & 4.1231 & 4.2426 \\ Improvement in RMSE & / & 11.25\% & 16.28\% & 33.56\% & 36.76\% \\ Improvement in Accuracy & / & 15.32\% & 15.91\% & 32.38\% & 36.64\% \\ Time Consumption (s) & \textless{}0.05 & \textless{}0.01 & \textless{}0.001 & \textless{}0.001 & \textless{}0.01 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: The performance metrics of different localization models. For the accuracy, the method proposed in this study achieved 2.0817 m, which is the best out of the five localization models. Compared with the four conventional methods, the accuracy improved by 15.32%, 15.91%, 32.38%, and 36.64%, respectively. Considering the stochasticity of the SPSO algorithm, the proposed method was run 50 times with 100 particles and 10,000 iterations each time, and the above results are their average performance. The standard deviation of the accuracy over 50 runs was 0.0431 m. On the other hand, the SPSO algorithm inevitably increases the complexity of the system, conforming to the no-free-lunch theorem. A time-consumption comparison experiment was performed. For completing a single localization, all four conventional methods took less than 0.1 s, while SPSO took less than 0.05 s, which is also a real-time and acceptable result. #### 4.3.2 Model Analysis

It should be noted that there are three factors that determine the performance of the model in the proposed method. In this section, comparison of one panel and two-panel, impact of different distance metrics, and impact of different weight assignations are discussed and analyzed. For the one panel, the fitness function Equation (18) was replaced by Equation (23). For the distance metrics, Euclidean metric (Euc, Equation (14)) and Mahalanobis distance (Mahal, Equation (24); the covariance matrix \(\Sigma\) was calculated by the training fingerprints) are common for Wi-Fi fingerprint similarity characterization. The correlation metric (Cor, Equation (25)) and cosine distance (Cos, Equation (15)) were adopted in [19]. For the weight assignments, reciprocal distance (weight 1 in Table 3) and Softmax function (weight 2 in Table 3) are commonly used. Considering that, in the log-distance path-loss model, the relationship between the \(RSS\) and the distance is related

Figure 4: The MSE, MAE, RMSE and STD with different localization models. Figure 5: Distribution of the localization error. (**a**) CDF curve of the different models. (**b**) Box plot of the localization errors. to the logarithmic function of base 10 [35], \(\omega_{3}\) in Equation (26) (weight 3 in Table 3) was used in this study. The details are shown in Table 3.

\[f(x,y,K)=\sqrt{\left(x-\sum_{k=1}^{K}\frac{\omega_{k}}{\sum_{k=1}^{K}\omega_{k}} \omega_{k}^{simk}\right)^{2}+\left(y-\sum_{k=1}^{K}\frac{\omega_{k}}{\sum_{k=1} ^{K}\omega_{k}}y_{train}^{simk}\right)^{2}} \tag{23}\]

\[dis_{\text{Mahal}}(Fit_{test},Fit_{train})=\sqrt{\left(Fit_{test}-Fit_{train }\right)\Sigma^{-1}(Fit_{test}-Fit_{train})^{\top}} \tag{24}\]

\[dis_{\text{Cor}}(Fit_{test},Fit_{train})=1-\frac{1}{M-1}\sum_{j=1}^{M}\frac{ \left(RSS_{test}^{AP\,j}-\overline{Fit_{test}}\right)\cdot\left(RSS_{train}^ {AP\,j}-\overline{Fit_{train}}\right)}{\sigma_{Fit_{train}}\cdot\sigma_{Fit_ {train}}} \tag{25}\]

in which \(\overline{\bullet}\) and \(\sigma\) are, respectively, the mean and standard deviation of the fingerprint.