# Evaluation of 5G Positioning Performance Based on UTDoA, AoA and Base-Station Selective Exclusion
## 3 Position Solution and Measurement Exclusion
### NLoS BS Exclusion Mechanism
#### 3.3.2 The Selection of Threshold Parameter  
The selection of the threshold is done experimentally based on the requirements for false alarm [22]. For a Cumulative Distribution Function (CDF) of test statistic values, the quantile \(\alpha\) defines the probability of detecting bias-free BSs subsets. Denoting the threshold \(\gamma\) as that providing a specific probability of false alarm (\(\text{P}_{\text{fa}}\)), the following relationship holds:  
\[\text{P}_{\text{fa}}(\gamma)=1-\alpha(\gamma)=1-\int_{0}^{\gamma}f_{\chi^{2}} (T)dT. \tag{37}\]The pseudo-range measurements should be uncorrelated and have a unit variance to follow a desirable normalized \(\chi^{2}\) distribution.  
```
Input:\(\mathbf{x}_{BS,n}\), \(\mathbf{\hat{x}}\), Cov, \(\gamma\), \(\mathbf{W}_{TDoA}\), \(\mathbf{\hat{\rho}}\), where \(n=1,2,\ldots,M_{BS_{TDoA}}\) Output:\(\mathbf{\hat{x}}_{l}\)
1: Set \(\mathrm{NrIter}=10\) to perform GN solution
2:\(\mathbf{\hat{x}}_{l}=\mathbf{\hat{x}}\)
3: Set \(l=0\)
4:while\(l\leq\mathrm{NrIter}\)do
5:\(l=l+1\)
6: Compute \(\mathbf{G}_{\mathrm{TDoA},(n,1:3)}=\left[\frac{\mathbf{x}_{BS,1}-\mathbf{ \hat{x}}_{l}}{\|\mathbf{x}_{BS,1}-\mathbf{\hat{x}}_{l}\|}-\frac{\mathbf{x}_{ BS,(n+1)}-\mathbf{\hat{x}}_{l}}{\|\mathbf{x}_{BS,(n+1)}-\mathbf{\hat{x}}_{l}\|}\right]\)
7: Compute the pseudo-range error \(\mathbf{\rho}(\mathbf{\hat{x}}_{l-1})\).
8: Compute the UE estimated location \(\mathbf{\hat{x}}_{l}\):
9:\(\mathbf{\hat{x}}_{l}=\mathbf{\hat{x}}_{l-1}+(\mathbf{G}_{\mathrm{TDoA},l-1}^{T }\mathbf{W}_{\mathrm{TDoA},l-1}^{-1}\mathbf{G}_{\mathrm{TDoA},l-1}^{T})^{-1} \mathbf{G}_{\mathrm{TDoA},l-1}^{T}\mathbf{W}_{\mathrm{TDoA},l-1}^{-1}(\mathbf{ \rho}(\mathbf{\hat{x}}_{l-1})-\mathbf{\hat{\rho}})\)
10:endwhile
11: Compute \(\mathbf{G}_{\mathrm{TDoA}}\) as in 6, where \(\mathbf{\hat{x}}_{l}\) is from 9
12: Decompose \(\mathbf{G}_{\mathrm{TDoA}}\) into \(\mathbf{U}_{S}\) and \(\mathbf{U}_{N}\) through QR factorization
13: Compute the residuals \(\varepsilon=\mathbf{U}_{N}^{T}\)\(\Delta\mathbf{\rho}\), where \(\Delta\mathbf{\rho}=(\mathbf{\rho}(\mathbf{\hat{x}}_{l-1})-\mathbf{\hat{\rho}})\) from 9
14: Compute the covariance matrix of the range residual vector \(\mathbf{Cov}_{res}=\mathbf{U}_{N}\)Cov\(\mathbf{U}_{N}^{T}\)
15: Perform eigen decomposition of \(\mathbf{Cov}_{res}=\mathbf{V}\)D\(\mathbf{V}^{T}\)
16: Whiten the range residual vector as \(\hat{\varepsilon}=(\mathbf{V}\sqrt{\mathbf{D}})^{-1}\varepsilon\)
17: Compute the sum of squared residuals: \(\mathrm{SSR}=\hat{\varepsilon}^{T}\hat{\varepsilon}\)
18: Compute \(T=\sqrt{\mathrm{SSR}/(M_{BS_{TDoA}}-4)}\)
19:if\(T\leq\gamma\)then
20: Use the solution \(\mathbf{\hat{x}}_{l}\) in 9
21:else
22: A bias might be present
23: Create subsets of BS by setting the 1 st BS as serving and remove one BS from the rest of BS at a time, \(\{\mathbf{x}_{BS,n^{\prime}}\}_{i}\), where \(i\in\{1,2,\ldots,M_{BS_{TDoA}}-1\}\) and \(n^{\prime}\in n-\{i+1\}\)
24: For each of the subsets compute \(T_{i}\) following the procedure from 1 to 18
25: Choose \(\{\mathbf{x}_{BS,n^{\prime}}\}_{i}\) with minimum \(T_{i}\) that does not exceeds \(\gamma\)
26:if\(T_{i}\) found then
27: Use solution \(\mathbf{\hat{x}}_{l}\) computed by the corresponding \(\{\mathbf{x}_{BS,n^{\prime}}\}_{i}\)
28:else
29: Choose the minimum \(T_{i}\) among test statistics computed in 18 and 24
30: Use solution \(\mathbf{\hat{x}}_{l}\) computed by the corresponding group of BSs
31:endif
32:endif
```  
**Algorithm 1** NLoS BS detection and exclusion. Procedure from 1 to 20 performs the algorithm with all the available BS, while procedure from 22 to 27 performs the algorithm excluding one BS at a time when the computed test statistic with all the available BS exceeds the given threshold