# Improved RSSI Indoor Localization in IoT Systems with Machine Learning Algorithms
## 2 Related Works
### Received Signal Strength Indicator  
The Received Signal Strength Indicators (RSSI) is a well-known location estimation approach, in which the power-intensity value is assessed from the beacons and measured in dBm. The RSSI measurements for one particular location of the target node are collected, as shown in Figure 1.  
The RSSI value defines the distance between beacons and the target node, and the value increases accordingly as the distance increases. The logarithmic distance loss model is calculated as Equation (1) [5]:  
\[RSSI_{r}(p)=RSSI_{r}(p_{0})-10\eta\log\frac{p}{p_{0}}+X_{\sigma} \tag{1}\]  
where \(RSSI_{r}(p)\) is defined as the received power [dBm] at a distance \(p\) [m] from the transmitter, \(X_{\sigma}\) is defined as a zero-mean Gaussian random variable with the variance of \(\left(\mathbb{N}(0,\sigma^{2})\right)\), \(RSSI_{r}(p_{0})\) refers to the received power [dBm] at the reference distance \(p_{0}\) from the transmitter, and \(\eta\) is the path loss exponent, which varies from 2 in free space to 4 in indoor environments. The localization algorithm is applied to estimate the location of the target node with the distances to different beacons. In this study, we proposed a weighted least-squares method for improved RSSI-based localization. The basic idea of the proposed algorithm was to find the position \((a,b)\) of the target node that decreased the sum of the squared error values. Let \(p_{n}=(a_{n},b_{n})\) be the location of beacons, such that \(n\) (\(n=1,\ 2,\ \ldots,\ N\)), where \(N\) is the total number of beacons and \(\widetilde{p}_{n}\) is the estimated location of the beacons. Therefore, the square of the distance between the target node and the beacon node \(n\) is calculated as  
\[p_{n}^{2}=\left(a_{n}-a\right)^{2}+\left(b_{n}-b\right)^{2} \tag{2}\]  
Figure 1: Arrangement of anchor node and target nodes. The starting point is used at the beacon \(n=1\), such that, \(a_{1}=b_{1}=0\). Therefore, for \(n>1\),  
\[p_{n}^{2}-p_{1}^{2}=a_{n}^{2}-2 aa_{n}+b_{n}^{2}-2 bb_{n} \tag{3}\]  
Therefore, Equation (3) can be written in Matrix as  
\[ \begin{bmatrix}2a_{2}&2b_{2}\\ \vdots&\vdots\\ 2a_{N}&2b_{N}\end{bmatrix}\begin{bmatrix}a\\ b\end{bmatrix} = \begin{bmatrix}a_{2}^{2}+b_{2}^{2}-p_{2}^{2}+p_{1}^{2}\\ \vdots\\ a_{N}^{2}+b_{N}^{2}-p_{N}^{2}+p_{1}^{2}\end{bmatrix}  \tag{4}\]  
The above, Equation (4), can be written as  
\[M\cdot\widetilde{A}=\widetilde{C} \tag{5}\]  
where \(M= \begin{bmatrix}2a_{2}&2b_{2}\\ \vdots&\vdots\\ 2a_{N}&2b_{N}\end{bmatrix} \), \(\widetilde{A}= \begin{bmatrix}a\\ b\end{bmatrix} \) and \(\widetilde{C}\) defines the random vector as  
\[\widetilde{C}= \begin{bmatrix}a_{2}^{2}+b_{2}^{2}-p_{2}^{2}+p_{1}^{2}\\ \vdots\\ a_{N}^{2}+b_{N}^{2}-p_{N}^{2}+p_{1}^{2}\end{bmatrix}  \tag{6}\]  
Thus, the location of the target node is estimated by using the linear least-square method as  
\[\widetilde{A}=\left(M^{T}M\right)^{-1}\!M^{T}\widetilde{C} \tag{7}\]  
The localization is dependent on \(\left(M^{T}M\right)^{-1}\). The expression \(M^{T}M\) is a square, non-singular, and invertible matrix if the beacons are reasonably far from the target node. We applied weighted least-squares in Equation (5) as  
\[\widetilde{A}=\left(M^{T}R^{-1}M\right)^{-1}\!M^{T}R^{-1}\widetilde{C} \tag{8}\]  
where \(R\) defines the covariance matrix of the vector \(\widetilde{C}\) and is written as  
\[R=\begin{bmatrix}Var(\widetilde{p}_{1}^{2})+Var(\widetilde{p}_{2}^{2})&Var( \widetilde{p}_{1}^{2})&\ldots&Var(  
Then, we put Equations (12) and (13) in Equation (10) as  
\[Var\ (\widetilde{p}_{n}^{2})=E\Big{[}\widetilde{p}_{n}^{4}\Big{]}-\Big{(}E\Big{[} \widetilde{p}_{n}^{2}\Big{]}\Big{)}^{2}=\exp\big{(}4\mu_{p}\big{)}\cdot\Big{(} \exp\Big{(}8\sigma_{p}^{2}\Big{)}-\exp\Big{(}4\sigma_{p}^{2}\Big{)}\Big{)} \tag{14}\]  
Here, \(\mu_{p}\) is dependent on the actual location \(p_{n}\) and estimation location \(\widetilde{p}_{n}\) of the target node and the iBeacons.