## 4 Linear Regression Algorithm against Device Diversity Problem
### Linear Regression Algorithm against Device Diversity Problem  
Before using the linear regression method, the parameters \(a\) and \(b\) in Equation 6 should be computed. Since the outliers appear in the collected RSS values frequently and seriously affect the performance of the linear least squares (LLS) algorithm, the fast least trimmed squares (FAST-LTS) algorithm is used in this paper.  
When the number of measured RSS values is \(c\), the FAST-LTS solution for linear regression with intercept is given by  
\[\min\limits_{a,b}\sum\limits_{i=1}^{h}d(i)^{2} \tag{9}\]  
where \(h=int[(c+2)/2]\), \(d(i)=\|r_{\mathcal{Y}}-(ar_{\mathcal{X}}+b)\|\) and \(\|\bullet\|\) is norm 2 of a vector, \(d(i)^{2}\) are the ordered squared residuals: \(d(1)^{2}\leq d(2)^{2}\leq\cdots\leq d(i)^{2}\leq\cdots\leq d(c)^{2}\).  
Given the \(h\)-subset \(H_{old}\) of all nearest neighbors, the _C-step_ is used to compute the \(a\) and \(b\) as follows [27]:  
1. compute \(\mathbf{a}_{old}\) and \(\mathbf{b}_{old}:=\) least squares regression estimator based on \(H_{old}\)
2. compute the residuals \(d_{old}(i)\) for \(i=1,\cdots,c\)
3. sort the absolute values of these residuals, \(|d_{old}(1)|\leq|d_{old}(2)|\leq\cdots\leq|d_{old}(c)|\)
4. arrange the absolute values of the residuals in ascending order, let \(H_{new}\) be a subset consisting of the nearest neighbors corresponding to the first \(h\) the absolute values of the residuals in the sequence
5. compute \(\mathbf{a}_{new}\) and \(\mathbf{b}_{new}:=\) least squares regression estimator based on \(H_{new}\)  
Repeating _C-step_ with numerous \(H_{old}\), a lot of regression coefficients will be gotten. The approximate solution is the coefficient corresponding to the least \(\sum_{i=1}^{h}d(i)^{2}\). After getting the regression coefficient \(a\) and \(b\), \(r_{\mathcal{X}}\) is transformed as follows  
\[r^{\prime}_{\mathcal{X}}=ar_{\mathcal{X}}+b \tag{10}\]  
where \(r^{\prime}_{\mathcal{X}}\in\mathcal{Y}\). As a result, both \(r^{\prime}_{\mathcal{X}}\) and \(r_{\mathcal{Y}}\) belong to the same signal space, and a uniform radio map could be built using \(r^{\prime}_{\mathcal{X}}\) and \(r_{\mathcal{Y}}\) in the offline training phase and a higher positioning accuracy could be obtained in online phase.  
To verify the LR method, five distinct devices, namely Lenovo, Huawei, Samsung, Xiaomi and Coolpad, are used to collect RSS values at all RPs and the linear regression coefficients could be calculated based on the measured RSS values and the corresponding coordinates. When the regression coefficients are gotten, all the RSS values could be mapped into the same signal space by LR method and a uniform radio map could be built. Using the processed radio map, the user's location will be estimated with a high accuracy in online phase.  
In our localization systems, we use the Lenovo device as the standard device, and all the RSS values collected by other devices are mapped into the signal space of Lenovo device. We take the (Huawei, Lenovo) pair as an example. As shown in Figure 5, the collected data are more stable after pre-processing of RSS values, and the linear regression coefficients could be calculated by LTS method. Using the coefficients, the RSS values collected by Huawei device could be mapped into the signal space of Lenovo device. We compare the original RSS values and the transferred RSS values collected by Lenovo device with the RSS values collected by the Lenovo device, the comparison result is shown in Figure 6. From the figure, we can see that the difference of signal distribution between different devices is reduced significantly. Accordingly, a uniform radio map can be built in the offline phase and the positioning performance could be improved in the online phase.