## 2 RSS Localization Algorithm Description
\begin{array}{cccc}2p_{2}^{\frac{2}{2}}x_{2}-2p_{1}^{\frac{2}{2}}x_{1} &2p_{2}^{\frac{2}{2}}y_{2}-2p_{1}^{\frac{2}{2}}y_{1}&p_{1}^{\frac{2}{2}}-p_{2}^ {\frac{2}{2}}\\ 2p_{3}^{\frac{2}{2}}x_{3}-2p_{1}^{\frac{2}{2}}x_{1}&2p_{3}^{\frac{2}{2}}y_{3}- 2p_{1}^{\frac{2}{2}}y_{1}&p_{1}^{\frac{2}{2}}-p_{3}^{\frac{2}{2}}\\ \vdots&\vdots&\vdots&\vdots\\ 2p_{m}^{\frac{2}{2}}x_{m}-2p_{1}^{\frac{2}{2}}x_{1}&2p_{m}^{\frac{2}{2}}y_{m}- 2p_{1}^{\frac{2}{2}}y_{1}&p_{1}^{\frac{2}{2}}-p_{m}^{\frac{2}{2}}\end{array} \right] \tag{13}\]  
\[X=\left[ \begin{array}{c}x\\ y\\ z\end{array} \right] \tag{14}\]  
In Equation (14) \(x\) and \(y\) are the estimated coordinates of the source in meters:  
\[b=\left[ \begin{array}{c}p_{2}^{\frac{2}{2}}-p_{1}^{\frac{2}{2}}\\ p_{3}^{\frac{2}{2}}-p_{1}^{\frac{2}{2}}\\ \vdots\\ p_{m}^{\frac{2}{2}}-p_{1}^{\frac{2}{2}}\end{array} \right] \tag{15}\]  
The above system of equations represents matrix form of \(AX=b\). The system of equations shown in the above matrix for is over determined, i.e., the number of unknowns are less than the number of equations. To solve the above system, linear least squares approach has been used, based on Equation (16) [29]:  
\[X=\left(A^{T}A\right)^{-1}A^{T}b \tag{16}\]  
Secondly, the above expression cannot be solved yet. Although the source transmitted power is eliminated by taking the ratio of distances, however, the path loss exponent (\(\alpha\)) is still unknown. A positive aspect about the path loss exponent is that it is constrained i.e., it has a practical minimum and maximum. Theoretically and experimentally, it has been proven that for an ideal free space propagation, \(\alpha\) is approximately 2. However, considering the factors such as multipath propagation and shadowing, it ranges from \(1\leq\alpha\leq 5\)[30; 31; 32]. For this reason, the initially chosen value of PLE is 2 because the measurements are performed in an approximately free space environment in a large sports hall. The process is then repeated for multiple values of PLE by taking a reasonable step size, e.g., 0.01, keeping in view the runtime. A measure of the spread between the mean spatial location and the estimated location is calculated by using Equation (17) below:  
\[d_{RMS}=\sqrt{\frac{1}{N}\sum_{n=1}^{N}d_{n}^{2}} \tag{17}\]  
where, \(d_{n}\) is the spatial location distance from the mean estimated location in meters, and \(d_{RMS}\) is the RMS spread of the spatial location distance in meters. The location that will have the minimum value of RMS spread will be the estimated location of the source, and the value of the path loss exponent will be an optimized value closest to an average PLE of the environment.The whole algorithm is summarised in the following steps:  
* Assume a universal value of path loss exponent (\(\alpha\)) from the given range \(1\leq\alpha\leq 5\). * Select a reference node and use ratios of power received by a pair of sensors to calculate an estimated PD location. * Repeat for all other nodes set as reference nodes one by one. * Calculate mean spatial location from all the above estimated locations. * Calculate the RMS error of spatial location distance from mean location. * Repeat for multiple values of \(\alpha\) and select the final estimated location that has a minimum RMS error. The overall flowchart of the algorithm is shown in Figure 2.