# 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
### The Basic Approach  
We first consider the LOS/NLOS identification as a naive binary classification. If given a predefined threshold of STD, we can formulate the problem as a hypothesis testing described in Equation (3), where \(\theta\), \(H_{0}\) and \(H_{1}\) refer to the threshold and the case of NLOS and LOS. When the calculated STD is higher than \(\theta\), the classifier believes the current path is NLOS and vice versa.  
\[\left\{\begin{array}{ll}H_{0}:&var\leq\theta\\ H_{1}:&var>\theta\end{array}\right. \tag{3}\]  
To examine the performance of the threshold-based approach, we, respectively, collect 232 groups of data in LOS and NLOS cases while keeping the transceivers stationary. Each contains 300 packets that are continuously received. The experiments are conducted at different times to reduce the impact of potential time-varying factors (such as temperature and humidity). We collect the first 130 samples in the daytime and the last 102 at night. For each group, we perform the following process to achieve the LOS/NLOS identification:  
1. Extract CSI from the 300 packets with tool released in [40].
2. Apply 30-point iFFT and obtain the CIR.
3. Record the peak energy time index of each CIR. Calculate STD of the SIPE after removing the duplicate values.
4. Compare the calculated STD with the predefined threshold \(\theta\) and make the decision.  
The calculated STD of all 464 groups (numbered from 1 to 232 in 2 cases) are plotted in Figure 4a. It is worth noting that although there are many NLOS samples whose STD is higher than LOS ones, the others with a value around one still get mixed (especially the first 130 groups), creating a challenge for the threshold-based approach. In this case, the selection of the threshold \(\theta\) can significantly impact the identification accuracy. If a low threshold is specified, many LOS samples may be recognized as NLOS ones incorrectly. In contrast, the classifier can only identify a few NLOS samples with a higher one.  
We use varying thresholds to discriminate samples and draw the Receiver Operating Characteristic (ROC) curves in Figure 4b. Point (0, 1) represents the perfect classifier that can achieve an identification accuracy of 100%. The closer the point is to (0, 1), the better the classifier performs. Area Under ROC Curve (AUC) is a measurement of how good the classifier is. It is expected to get close to one as much as possible. However, the estimated AUC of our approach is only about 0.624. The classifier with a threshold of 1.5 is the best one. Its False Positive Rate (FPR) and True Positive Rate (TPR) are 30.6% and 63.8%, respectively. We provide the confusion matrix in Figure 4c.  
It shows that the basic approach can only achieve an accuracy of 67%. Such a result is far from the requirements of high precision. The reasons behind this can be summarized as follows: (1) STD is not the most distinguishing feature to characterize the peak energy index distribution; (2) We only explore a single time index distribution, which may not be reliable enough. To further improve the accuracy and find out the best feature, we introduce an approach based on machine learning.  
Figure 4: The performance of the basic approach: (**a**) The STD of SIPE obtained in LOS/NLOS paths; (**b**) The ROC curve of classification based on STD threshold; (**c**) The confusion matrix when \(\theta\) is 1.5.