# PEiD: Precise and Real-Time LOS/NLOS Path Identification Based on Peak Energy Index Distribution
## 4 PEID: LOS/NLOS Identification Based on Peak Energy Index Distribution
### A Machine Learning-Based Approach  
Before applying the machine learning algorithms, we first manually design ten candidate features based on the peak energy index distribution and CIR power distribution [44]. The intuition is to improve the classifier accuracy and study the importance of each selected feature. We use the labels F1\(\sim\)F10 to represent these ten features, whose descriptions are listed below:  
1. STD of the SIFPE (Sequence of Index corresponding to the first peak energy, We use \"the first peak\" and \"the second peak\" to represent the time index with the highest and second-highest amplitude. The term \"SIPE\" is replaced with SIFPE). 2. Mean value of the SIFPE. 3. STD of the SISPE (Sequence of Index corresponding to the second peak energy). 4. Mean value of the SISPE. 5. Posterior probability of the SIFPE. 6. Power ratio \(\frac{E_{1}}{E}\), where \(E_{1}\), \(E\) refer to the amplitude of the first peak energy and power sum across all time index in CIR, respectively. 7. Power ratio \(\frac{E_{1}+E_{2}}{E}\), where \(E_{2}\) refer to the amplitude of the second peak energy. 8. Power ratio \(\frac{E_{1}+E_{2}+E_{3}+E_{4}+E_{5}}{E}\), where \(E_{3}\), \(E_{4}\), \(E_{5}\) refer to the amplitude of the third, fourth, and fifth peak energy, respectively. 9. Difference of amplitude between \(E_{1}\) and \(E_{2}\). 10. STD of sequence difference between the SIFPE and SISPE. The selected features consist of two parts. Features F1\(\sim\)F5 and F10 focus on the statistical characteristics (including STD and mean value) of the time index sequence while F6\(\sim\)F9 focus on the CIR power distribution. To better capture the randomness of NLOS paths, we consider both the first and the second peak energy index distribution and study the change of their difference (interval between the two time bins). The posterior probability is a newly defined metric. Assuming that \(\xi\) represents the condition when an index is picked out of SIPE as the most frequent one, \(P(LOS|\xi)\) and \(P(NLOS|\xi)\) represent the posterior probability that predicts how likely the index comes from LOS and NLOS cases, respectively. Leveraging previously collected data in the NLOS and LOS cases, we can obtain \(P(\xi|LOS)\) and \(P(\xi|NLOS)\) by calculating the percentage of the SIPE that appears most frequently in the series. As the prior probabilities of NLOS and LOS cases (\(P(LOS)/P(NLOS)\)) are the same in the experiments, the posterior probability of the SIPE can be calculated according to the [PERSON] theorem:  
\[P(LOS|\xi)=\frac{P(\xi|LOS)}{(P(\xi|LOS)+P(\xi|NLOS))} \tag{4}\]  
After the process of feature calculation, we build the classifier with five machine learning algorithms provided by the Weka tool (Random Forest, J48, Bayes Net, Random Tree, and AdaBoostM1). The data used for training and testing were derived from the previous dataset of 464 samples. The ratio of the training set to the testing set is 7:3 (324 for training and 140 for testing). We list the identification accuracy of each classifier in Table 1. It shows that Random Forest achieves the best performance among other algorithms, obtaining 94% accuracy in LOS cases and 92.7% in NLOS cases. It performs a relatively low False Alarm Rate (FAR) of 6.7% (31 wrong in 464 samples). \begin{table}
\begin{tabular}{c c c c c c} \hline \multirow{2}{*}{**Classifier**} & **Random** & \multirow{2}{*}{**J48**} & \multirow{2}{*}{**Bayes Net**} & \multirow{2}{*}{**Random Tree**} & \multirow{2}{*}{**AdaBoostM1**} \\  & **Forest** & & & & \\ \hline LOS & 94\% & 89.2\% & 87.5\% & 88.4\% & 85\% \\ NLOS & 92.7\% & 90.5\% & 73.3\% & 91.4\% & 83.2\% \\ \hline \end{tabular}
\end{table} 
Table 1: The identification accuracy of different classifier (300 packets recieved). In terms of computational complexity, the Random Forest algorithm demonstrates a relatively balanced value of \(O(n\log(n)dk)\), where \(d\) represents the feature dimension and \(k\) represents the number of decision trees.