## 3 Methodology
### Data Preprocessing
#### 3.3.1 Extended Kalman Filter (EKF)  
EKF is an estimation method that optimizes values by minimizing the mean square error. It is particularly effective for estimating parameters of fuzzy models that capture nonlinear relationships. Indoor signal propagation poses several challenges, including reflections from walls, furniture, and other objects, as well as multipath propagation and signal attenuation. All these factors lead to significant nonlinearity in the signal propagation model. EKF effectively addresses these issues by compensating for noise and enhancing the accuracy of the model [51].  
The EKF is applied to filter the RSSI data received from four receivers, following these steps.  
Firstly, the state and error covariance matrix are predicted:  
\[\hat{x}_{k|k-1}=A_{k}\hat{x}_{k-1} \tag{2}\]  
\[P_{k|k-1}=A_{k}P_{k-1}A_{k}^{T}+Q_{k} \tag{3}\]  
where \(\hat{x}_{k|k-1}\)--a priori state assessment, \(P_{k|k-1}\)--a priori error covariance, \(A_{k}\)--state transition matrix, and \(Q_{k}\)--process noise covariance.  
The measurement model defines the relationship between node coordinates and RSSI measurements from receivers:  
\[z_{k}=h\Big{(}\hat{x}_{k|k-1}\Big{)}+v_{k} \tag{4}\]  
\[h\Big{(}\hat{x}_{k|k-1}\Big{)}=\begin{bmatrix}P_{t1}-10n\text{log}_{10}(d_{1} )\\ P_{t2}-10n\text{log}_{10}(d_{2})\\ P_{t3}-10n\text{log}_{10}(d_{3})\\ P_{t4}-10n\text{log}_{10}(d_{4})\end{bmatrix} \tag{5}\]where \(d_{i}=\sqrt{\left(x-x_{i}\right)^{2}+\left(y-y_{i}\right)^{2}}\), \(\left(x_{i},y_{i}\right)\)--receiver coordinates, \(P_{li}\)--transmitter power, n--attenuation factor.  
To linearize the measurement function, the Jacobian is used:  
\[H_{k}=\left.\frac{\partial h}{\partial x}\right|_{\hat{x}_{ijk-1}} \tag{6}\]  
where  
\[H_{k}=\begin{bmatrix}\frac{\partial h_{1}}{\partial x}&\frac{\partial h_{1}}{ \partial y}\\ \frac{\partial h_{2}}{\partial x}&\frac{\partial h_{2}}{\partial y}\\ \frac{\partial h_{3}}{\partial x}&\frac{\partial h_{3}}{\partial y}\\ \frac{\partial h_{4}}{\partial x}&\frac{\partial h_{4}}{\partial y}\end{bmatrix} \tag{7}\]  
\[\frac{\partial h_{i}}{\partial x}=-\frac{10n\left(x-x_{i}\right)}{\left(\ln( 10)\right)d_{i}^{2}},\ \ \frac{\partial h_{i}}{\partial y}=-\frac{10n\left(y-y\right)}{\left(\ln(10) \right)d_{i}^{2}} \tag{8}\]  
The Kalman coefficient is used to adjust the predicted state based on measurements:  
\[K_{k}=P_{k|k-1}H_{k}^{T}\left(H_{k}P_{k|k-1}H_{k}^{T}+R_{k}\right)^{-1} \tag{9}\]  
where \(R_{k}\)--measurement noise covariance.  
After receiving measurements, the state is updated:  
\[\hat{x}_{k}=\hat{x}_{k|k-1}+K_{k}\left(z_{k}-h\left(\hat{x}_{k|k-1}\right)\right) \tag{10}\]  
where \(z_{k}-h\left(\hat{x}_{k|k-1}\right)\)--measurement error.  
The error covariance matrix is updated using the following method:  
\[P_{k}=(I-K_{k}H_{k})P_{k|k-1} \tag{11}\]  
where \(I\) is the identity matrix.  
During the state update, the Kalman gain is employed to determine the extent to which new measurements should be considered for adjusting the predicted state. In scenarios with high noise levels, the Kalman gain reduces the weight of the new data, thereby mitigating its impact on the estimation. This approach allows the filter to effectively minimize the influence of noise.  
Updating the error covariance matrix decreases uncertainty in the state after each update step, which enhances confidence in the estimation of the node's current position. Therefore, the EKF enables precise estimation of the mobile node's coordinates, even amidst significant noise encountered during signal propagation indoors.