## 3 Three-step WLS Localization Algorithm for Hybrid Positioning
### Third-Step WLS  
The former two steps assume no relationship between the UE location \(\left(x,\ y\right)^{T}\) and \(r_{1}\), but in fact they are related. Chan-Ho algorithm has the same problem in its first stage minimization and use a WLS to refine the result [17]. In the third-step WLS of this proposed algorithm, the same method as the Chan-Ho algorithm is used to refine the result of former two steps. The former two steps' results location \(\left(x^{\prime\prime},y^{\prime\prime}\right)^{T}\) and distance \(r_{1}{}^{\prime\prime}\) have a relationship shown in Equation (22). Therefore, the third-step WLS is to minimize the sum of the squared errors \(\varepsilon\) in:  
\[\left\{ \begin{array}{c}\varepsilon_{1}=\left(x_{1}-x^{\prime\prime}\right)^ {2}-\left(x_{1}-x\right)^{2}\\ \varepsilon_{2}=\left(y_{1}-y^{\prime\prime}\right)^{2}-\left(y_{1}-y\right)^ {2}\\ \varepsilon_{3}={r_{1}{}^{\prime\prime}}^{2}-\left(x_{1}-x\right)^{2}+\left(y_{ 1}-y\right)^{2}\end{array} \right.\text{.} \tag{22}\]  
Equation (22) could be rewritten in matrix form as:  
\[\varepsilon=h^{\prime}-G^{\prime}\Delta u \tag{23}\]  
where:  
\[\varepsilon=\left[ \begin{array}{c}\varepsilon_{1}\\ \varepsilon_{2}\\ \varepsilon_{3}\end{array} \right]\text{, }h^{\prime}=\left[ \begin{array}{c} \left(x_{1}-x^{\prime\prime}\right)^{2}\\ \left(y_{1}-y^{\prime\prime}\right)^{2}\\ {r_{1}{}^{\prime\prime}}^{2}\end{array} \right]=\left[ \begin{array}{c} \left(x_{1}-x+e_{x}\right)^{2}\\ \left(y_{1}-y+e_{y}\right)^{2}\\ \left(r_{1}+e_{r}\right)^{2}\end{array} \right]\text{, }\Delta u=\left[ \begin{array}{c}\left(x_{1}-x\right)^{2}\\ \left(y_{1}-y\right)^{2}\end{array} \right]\text{.} \tag{24}\]  
Because elements in vector \(\varepsilon\) have different variances, we need to use WLS to estimate the solution \(\Delta u\) as:  
\[\Delta u=\left({G^{\prime}}^{T}W^{\prime\prime\prime}\,G^{\prime}\right)^{-1}{ G^{\prime}}^{T}W^{\prime\prime\prime}\,h^{\prime} \tag{25}\]  
where weighting matrix \(W^{\prime\prime\prime}\) could be obtained by calculating the covariance matrix of \(\varepsilon\). Assuming that the error of the solution \(w^{\prime\prime}\) in second-step WLS are \(e=\left(e_{x},e_{y},e_{r}\right)^{T}\), vector \(\varepsilon\) could be obtained as:  
\[\varepsilon =\left[ \begin{array}{c}\varepsilon_{1}\\ \varepsilon_{2}\\ \varepsilon_{3}\end{array} \right]=\left[ \begin{array}{c}\left(x_{1}-x^{ \prime\prime}\right)^{2}\\ \left(y_{1}-y^{\prime\prime}\right)^{2}\\ {r_{1}{}^{\prime\prime}}^{2}\end{array} \right]-\left[ \begin{array}{c} \left(x_{1}-x\right)^{2}\\ \left(y_{1}-y\right)^{2}\\ {r_{1}}^{2}\end{array} \right]=\left[ \begin{array}{c}\left(x_{1}-x+e_{x} \right)^{2}\\ \left(y_{1}-y+e_{y}\right)^{2}\\ \left(r_{1}+e_{r}\right)^{2}\end{array} \right]-\left[ \begin{array}{c}\left(x _{1}-x\right)^{2}\\ \left(y_{1}-y\right)^{2}\\ {r_{1}}^{2}\end{array} \right] \tag{26}\] \[=\left[ \begin{array}{c}2\left(x_{1}-x\right)e_{x}+{e_{x}}^{2} \\ 2{y_{1}}-y\right)e_{y}+{e_{y}}^{2}\\ 2{r_{1}}e_{r}+{e_{r}}^{2}\end{array} \right]\approx\left[ \begin{array}{c}2 \left(x_{1}-x\right)e_{x}\\ 2\left(y_{1}-y\right)e_{y}\\ 2{r_{1}}e_{r}\end{array} \right]\text{. }\]  
where the second-order error terms are ignored. \[ \begin{array}{ll}W^{{}_{\prime\prime\prime}}{}^{-1}&=Cov(\varepsilon)=E\Big{(} \varepsilon\varepsilon^{T}\Big{)}=4\left[\begin{array}{ccc}x_{1}-x&0&0\\ 0&y_{1}-y&0\\ 0&0&r_{1}\end{array}\right]Cov(e)\left[\begin{array}{ccc}x_{1}-x&0&0\\ 0&y_{1}-y&0\\ 0&0&r_{1}\end{array}\right]\\ &=4 BCov(e)B.\end{array}  \tag{27}\]  
The matrix \(B\) could be approximated by using \((x^{\prime\prime},y^{\prime\prime},r_{1}\")\) as \((x,y,r_{1})\) and \(Cov(e)\) could be approximated as \(\left(G^{T}W^{\prime}G\right)^{-1}\)[17]. Therefore, result \(\Delta u\) could be calculated by  
\[\Delta u=\Big{(}G^{T}\frac{1}{4}B^{-1}G^{T}W^{\prime}GB^{-1}G^{\prime}\Big{)}^ {-1}G^{\prime T}\frac{1}{4}B^{-1}G^{T}W^{\prime}GB^{-1}h^{\prime}. \tag{28}\]  
The \(\Delta u\) is the square of the difference between final positioning result \(u\) and ANT 1 on the x-axis and the y-axis.