## 2 Algorithm
### The Procedure of PLGAIM
#### 2.2.1 Fault Detection  
In fault detection, the most critical step is the construction of test statistic \(T\) and the calculation of threshold \(T_{h}\). The test statistic is a value calculated from a set of sample data used to determine whether the null hypothesis should be rejected in the hypothesis test. The construction of \(T\) depends on the probability model (distribution) and the assumptions of the problem. As long as \(T\) is constructed, \(T_{h}\) can be determined from a probability model with a given confidence level. According to (2), the residual vector of the DD observations is obtained as,  
\[r_{k}=Z_{k}-H_{k}X_{k}^{(+)}=Z_{k}-H_{k}(X_{k}^{(-)}+K_{k}V_{k}) \tag{5}\]  
\[r_{k}=Z_{k}-H_{k}X_{k}^{(-)}-H_{k}K_{k}V_{k} \tag{6}\]  
\[V_{k}=Z_{k}-H_{k}X_{k}^{(-)} \tag{7}\]  
The simultaneous (6) and (7) can be written as,  
\[ \begin{array}{c}r_{k}=V_{k}-H_{k}K_{k}V_{k}\\ =(I-H_{k}K_{k})V_{k}\end{array}  \tag{8}\]  
The residual squared SSE is a scalar,  
\[SSE=r_{k}^{T}r_{k}=V_{k}^{T}(I-H_{k}K_{k})^{T}(I-H_{k}K_{k})V_{k} \tag{9}\]  
The posterior unit weight mean error and test statistic can be constructed as,  
\[T=\sqrt{{V_{k}}^{T}(I-H_{k}K_{k})^{T}(I-H_{k}K_{k})V_{k}}\hat{\sigma}=\sqrt{ SSE/(n-t)} \tag{10}\]  
where \(t\) represents the necessary number of observations. In experiments, parameters to be estimated are the horizontal coordinates \(x\), \(y\), and ambiguity, thereby \(t=3\). The innovation sequence \(V\) provides the corresponding source of information for PLRAIM. Nevertheless, when DD observations are applied, the noise is no longer independent. The dependence is a mathematical correlation rather than a physical correlation. To de-correlate the dependence, \(T\) can be constructed as [21],  
\[T=\sqrt{r_{k}^{T}W_{k}r_{k}} \tag{11}\]  
Figure 3: Conditions in FaultDetection. where residual vector \(r=[r_{L1}r_{P1}]^{T}\), thus, the statistic of each observation can be expressed as,  
\[T_{L1}=\sqrt{r_{L1}^{T}W_{L1}r_{L1}}T_{P1}=\sqrt{r_{P1}^{T}W_{P1}r_{P1}} \tag{12}\]  
In (12), \(T_{L1}\) is a test statistic based on carrier phase \(L1\) observations and \(T_{P1}\) is constructed based on pseudorange observations \(P1\). These two statistics form the core of the CRAIM and PRAIM algorithm respectively. Some faults can be detected when using PRAIM, for example, indoor multipath. However, there are also some faults that cannot be reflected from the test statistic based on pseudorange (e.g., cycle slips) and such faults cannot be ignored in high-precision indoor pseudolite positioning. Consequently, the proposed indoor PRAIM can also achieve the goal of data pre-processing such as cycle slip detection and gross error detection. Moreover, since the results of indoor pseudolite positioning are greatly affected by data quality, the PRAIM algorithm is also a guarantee for the availability and reliability of positioning. The innovation sequence in a Kalman filter is assumed to subject to Gaussian distribution ([PERSON] 1970), \(N(0,\sigma^{2})\). According to the statistical distribution theory, test statistic \(T^{2}/\sigma^{2}\) subjects the chi-square distribution with a degree of freedom of \(m\). When there is no deviation in the observations, the system is under a normal state. If an alert is performed, it would be a false alert. The following probability equation can be established from a given \(P_{fi}\),  
\[P_{r}(T^{2}/\sigma^{2}<T_{h}^{2})=\int_{0}^{T_{h}^{2}}f_{\chi^{2}(m)}(x)dx=1-P_ {fa} \tag{13}\]  
The threshold \(T_{h}\) can be determined by (13) and \(T/\sigma\) is used to compare with \(T_{h}\). If \(T/\sigma\) is greater than \(T_{h}\), it can be considered that the fault exists in observations that should be excluded. If \(T/\sigma\) is less than the threshold, the positioning result is reliable and the observations can be applied for positioning. In addition, the selection principle of reference pseudolite is also based on the elevation angle in indoor pseudolite positioning. However, elevation angles of all pseudolites are relatively close owing to the small scene indoors.