## 3 The Proposed Localization Algorithm
### Localization Algorithm
If we include more anchor nodes, we will fit the training data more accurately, which means that our model is capable of minimizing the training errors more effectively. However, the minimization of training errors is not our goal. We hope that the model can accurately estimate the locations of sensor nodes, that is, the model should have a generalization capability. With many anchors, fitting the full model without penalization will result in large prediction intervals, and an LLS regression estimator may not uniquely exist. In order to avoid over-fitting, it is necessary to add a regularization item or a penalty term to the model [21]. In addition, because the LLS estimates depend upon \(\left(\mathbf{H}_{1}^{\mathsf{T}}\mathbf{H}\right)^{-1}\), there can be problems in computing \(\mathbf{W}\) if \(\mathbf{H}_{1}^{\mathsf{T}}\mathbf{H}\) were singular or nearly singular. In this paper, a term \(k\mathbf{I}\) (\(k>0\)) is added to the matrix \(\mathbf{H}_{1}^{\mathsf{T}}\mathbf{H}\) for remedying this problem. The method is also called Tikhonov regularization, which is the most commonly used method of regularization of ill-posed problems. Then, the estimated \(\mathbf{W}\) can be described as  
\[\hat{\mathbf{W}}=\left(\widetilde{\mathbf{H}}_{1}^{\mathsf{T}}\widetilde{ \mathbf{H}}_{1}+k\mathbf{I}\right)^{-1}\widetilde{\mathbf{H}}_{1}^{\mathsf{T }}\widetilde{\mathbf{D}}_{1}. \tag{12}\]  
Here, the matrix \(\mathbf{I}\) is an identity matrix. With the regularization term, the model can effectively avoid over-fitting. The \(k\) in the formula is called the hyper-parameters, which is used to balance the training errors and the regularization items [22]. Considering that \(\widetilde{\mathbf{H}}_{1}^{\mathsf{T}}\widetilde{\mathbf{H}}_{1}\) will be an ill-conditioned matrix if \(\|\widetilde{\mathbf{H}}_{1}^{\mathsf{T}}\widetilde{\mathbf{H}}_{1}\|<0.01\), we simply set the value of parameter \(k\) to be 0.01 in the later simulation part. **Part C (Localization)**: Now, the normalized hop-count matrix \(\widetilde{\mathbf{H}}_{3}\) and the coefficient matrix \(\hat{\mathbf{W}}\) are used to estimate the normalized matrix \(\widetilde{\mathbf{D}}_{3}\),  
\[\widetilde{\mathbf{D}}_{3}=\widetilde{\mathbf{H}}_{3}\hat{\mathbf{W}}. \tag{13}\]  
After obtaining the result of Equation (13), we can derive \(\mathbf{D}_{3}\) by using a reverse operation of \(\widetilde{\mathbf{D}}_{3}\), and then the trilateration method or the maximum likelihood method is used to estimate the coordinates of unknown nodes [23]. The pseudo-code of LSRR-LA is illustrated in Algorithm 1. ```
input: H: hop matrix of the anchors and sensors; \(\mathbf{D}_{1}\): distance matrix for the anchors versus themselves; \(k\): hyper-parameters. output:\(\{\hat{\kappa}\}_{j=m+1}^{m+n}\): estimated locations of the sensors. 1 Normalize matrix \(\mathbf{H}_{1}\) and \(\mathbf{D}_{1}\), output \(\widetilde{\mathbf{H}}_{1}\) and \(\widetilde{\mathbf{D}}_{1}\);
2 Calculate the mapping matrix \(\hat{\mathbf{W}}\) by Equation (12);
3 Normalize matrix \(\mathbf{H}_{3}\), output \(\widetilde{\mathbf{H}}_{3}\);
4 Calculate matrix \(\widetilde{\mathbf{D}}_{3}\) by Equation (13);
5 Derive \(\mathbf{D}_{3}\) by using a reverse operation of \(\widetilde{\mathbf{D}}_{3}\);
6 Estimate coordinates \(\{\hat{\kappa}\}_{j=m+1}^{m+n}\) by using maximum likelihood method. ```  
**Algorithm 1** LSRR-LA  
With respect to step 6 in Algorithm 1, for specific details the reader can refer to [23].