2.1.1. Traditional w-Test

Due to the non-linear relationship between the GNSS pseudorange observation and state variables [29], the linearized pseudorange observation equation can be written as (1).

$$Y = HX + \varepsilon \tag{1}$$

Here, *Y* is the difference between the observed pseudorange and computed pseudorange from the initial state, *H* is the measurement matrix, *X* is the user's state vector, and *ε* is the observation error vector. The weighted least squares solution for the state vector *X* is (2).

$$X\_{\rm WLS} = \left(H^T \mathcal{W} H\right)^{-1} H^T \mathcal{W} Y \tag{2}$$

where, *W* is the weighting matrix. With *W* = (*cov*(*ε*))−<sup>1</sup> , based on Equation (2), the residual vector *r* is derived as:

$$\tau = Y - HX\_{WLS} = \left(I - H\left(H^T W H\right)^{-1} H^T W\right)\varepsilon = S\varepsilon \tag{3}$$

After obtaining the residual vector *r*, the sum of the squares of the residual or error (SSE) vector is used as the statistics for GNSS fault detection, which is defined as (4)

$$SSE = r^T \mathcal{W}r \tag{4}$$

Based on weighted least squares residuals, GNSS pseudorange measurements with significant errors are detected and eliminated by overall and local inspection methods. The overall test assumes that when observations do not contain gross errors, the observation errors follow the Gaussian distribution. Hence, the statistic *SSE* follows the chi-square distribution with degrees of freedom (*n* − *m*), where *n* is the total number of satellites observed, and *m* is the dimension of the state. When the test statistic exceeds the global threshold, there is at least one faulty satellite. The global test threshold *TG* is:

$$T\_{\mathbb{G}} = \chi^2\_{1 - P\_{FA}(m - n)}\tag{5}$$

where *PFA* is the probability of false alarm, which is selected according to specific application scenarios, and *χ*<sup>2</sup> denotes the probability density of the chi-square distribution. When the statistic exceeds the global threshold, it is necessary to find the failing measurement or gross error in observations, using the traditional w-test. The test normalizes the residual as a new statistic. The specific expression is (6):

$$w\_i = \frac{\varepsilon\_i^T r}{\sqrt{\varepsilon\_i^T S \varepsilon\_i}}, i = 1:m \tag{6}$$

where *ei* is the unit vector whose *i*-th element is 1. When the *i*-th observation has no error, the variance of the corresponding observation noise *ε<sup>i</sup>* is *σ*2, with *wi* following the normal distribution *<sup>N</sup>*(0, *<sup>σ</sup>*2). <sup>|</sup>*wi*|max is then compared with the w-test threshold *TL*. If <sup>|</sup>*wi*|max exceeds the threshold, it is considered that the corresponding observation contains gross error. Then, the traditional w-test eliminates the corresponding satellite. The expression of the w-test threshold is:

$$T\_L = N\_{1-P\mathbb{A}/2} \left( 0, \sigma^2 \right) \tag{7}$$

The traditional w-test only identifies one faulty satellite at a time, and the |*wi*|max corresponding satellite is eliminated. At the same time, in order to confirm whether there are any faulty satellites in the remaining satellites, all the remaining satellites after w-test are regarded as a new corpus again, and a new round of fault detection is performed. Therefore, the w-test method is suitable for the case of highly redundant observation data, and it is assumed that only one failure occurs at a time. In urban environments, however, this condition may not be met. Therefore, this paper adopts 3 − *σ* and 1−*σ* w-test double w-test, as shown in the following subsection.
