## 4 Adjustment of the Propagation Model Using Least Squares Linear Regression  
As observed in the previous section, the heat maps of the adjusted model did not show a close similarity to the heat map of the power measurements from the WiFi repeater taken in the field. Therefore, a new adjustment of the model was performed using the least squares linear regression method [25]. The general expression for calculating the reception power of the wireless repeater, based on the 560 reception level samples collected in the field with Raspberry Pi3, is determined using the linear regression method, referred to as \(fittedmodel_{linear}(d)\), as shown in Equation (10):  
\[fittedmodel_{linear}(d)=md+b, \tag{10}\]  
where \(m\) represents the rate of change in received power with respect to distance and \(b\) is the received power level when \(d=0\) (directly at the transmitter). The equations to calculate \(m\) and \(b\) are  
\[m=\frac{N\sum(d\cdot P_{r\_Sample})-\sum d\sum P_{r\_Sample}}{N\sum(d^{2})-( \sum d)^{2}}, \tag{11}\]  
\[b=\frac{\sum P_{r\_Sample}-m\sum d}{N}, \tag{12}\]  
where \(N\) is the number of data points and \(\sum(d^{2})\) is the sum of the squared distances and \(P_{r\_Sample}\) WiFi Repeater Signal Reception Levels. In MATLAB, a code was developed in which the variable \(d\) contains the distances from the transmitter to the different reception points, while the variable \(P_{r\_Sample}\) groups the measured reception signal powers at each point. The term \(N\) represents the number of evaluated data points, reaching a total of 560 samples according to the field measurements taken. To calculate the coefficients of the linear regression equation, these \(N\) pairs of experimental data (\(d\), \(P_{r\_Sample}\)) were used. Thus, the values of \(m\) and \(b\) were obtained for  
Figure 11: Heatmap of the 560 empirical samples of the received power levels by Raspberry Pi 3 and GPS from the repeater of the signal WiFi. the line adjustment. Therefore, the optimal fit was defined as the one that minimizes the distances \(d\) from the measured points to the line. Using Equations (11) and (12), the coefficients \(b\) and \(m\) were calculated to establish the linear regression based on the samples collected in the field. Once both coefficients were obtained, they were substituted in Equation (10), allowing the calculation of the power of the wireless repeater based on the distances measured at each point in the vicinity of the Wi-Fi repeater. \[fittedmodel_{lineal}(d)=-0.356488623d-61.17412641. \tag{13}\]  
Figure 12 displays the expected power as a function of the distances selected from Table 5, demonstrating that the power decreases uniformly and linearly with increasing distance. On the other hand, to compare the model fitting methods, a fitting process was performed using logarithmic regressions, similar to the approach described in Section 3.5. The Matlab Curve Fitting Toolbox was used, and through the \"fittype\" function, a fitting for curves and surfaces was applied, allowing for the generation of a probabilistic logarithmic function. From this function, the coefficients obtained with a confidence interval 95% are  
a = \(-43.79\) between the interval confidence (\(-46.62\), \(-40.96\)),  
b = \(-8.961\) between the interval confidence (\(-9.839\), \(-8.083\)). \begin{table}
\begin{tabular}{c c} \hline \hline
**L (m)** & **Prx (dBm)** \\ \hline
0 & \(-64.73901264\) \\
20 & \(-68.30389887\) \\
30 & \(-71.86878509\) \\
40 & \(-75.43367132\) \\
50 & \(-78.99355755\) \\
60 & \(-82.56344377\) \\
70 & \(-86.12833\) \\
80 & \(-89.69321623\) \\
90 & \(-93.25810245\) \\
100 & \(-96.82298868\) \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Input data for the linear model [Equation (13)]. Figure 12: Model fitting graph based on the linear regression method [Equation (13)].