# A New Algorithm Model Based on Extended Kalman Filter for Predicting Inter-Well Connectivity
## 2 Construction of the SV-DC Model
### Procedures of the EKF Algorithm  
The Kalman Filter method is a mathematical optimization technique originally developed for signal control. It has since been adapted to various fields, including nonlinear systems. The nonlinear EKF algorithm, as an extension of the Kalman Filter, contains four stages: system prediction, establishing measurement equations, generating optimal estimates, and updating the error covariance. The workflow presented in Figure 1 is the core idea of evaluating inter-well connectivity using the EKF algorithm [36; 38; 39]. System prediction  
To further highlight the advantages of autoregressive at each step provided in the EKF algorithm, \(m\) in Equation (12) is represented by \(k-1\) and \(n\) is represented by \(k\). \[X(k|k-1)=FX(k-1|k-1)+n_{x}(k-1) \tag{21}\]  
\[P(k|k-1)=FP(k-1|k-1)F^{T}+Q \tag{22}\]  
where \(X\) is a representation of the set of state variables in Equation (15), and \(X(k|k-1)\) denotes the prediction of the current step's state variables using the state variables from the last step. \(F\) is the state transition matrix of the system. \(n_{x}(k-1)\) is the system noise. Overall, Equation (21) uses the optimal estimate \(X(k-1|k-1)\) from the last step, the system matrix \(F\), and the noise \(n_{x}\) to predict the state variables at the current step. Similarly, Equation (22) uses the optimal estimate \(P(k|k-1)\) from the last step (\(P\) is the error covariance of the optimal estimate), the system matrix \(F\), and \(Q\) (\(Q\) is the covariance matrix of noise \(n_{x}\)) to predict the error covariance of the optimal estimate at the current step \(P(k|k-1)\). The state transition matrix \(F\) is a \(3N\times 3N\) Jacobian matrix, the explicit form of which is given below for the nonlinear state equation in Equations (23) and (24):  
\[F_{x}= \begin{bmatrix}A_{1}&\underline{0}&\cdots&\underline{0}\\ \underline{0}&A_{2}&\ddots&\vdots\\ \vdots&\ddots&\ddots&\underline{0}\\ \underline{0}&\cdots&\underline{0}&A_{N}\end{bmatrix}  \tag{23}\]  
\[A_{i}= \begin{bmatrix}1&0&0\\ 0&1&0\\ 0&0&1\end{bmatrix}  \tag{24}\]  
Figure 1: Flowchart of calculating inter-well connectivity using the EKF algorithm. Establishment of the measurement equation  
The measurement equation describes the relationship between the state variables and the actual observations. For the system state variable \(X(k)\), one can observe the variable associated with \(Z(k)\), as expressed as:  
\[Z(k)=HX(k)+n_{p}(k) \tag{25}\]  
where \(Z\) is the observed value of the variables. \(H\) is the observation matrix, and \(n_{p}\) is the measurement noise. The generation of optimal estimation mainly consists of calculating the Kalman gain Equation (26) and establishing the optimal estimate equation Equation (27). \[K_{g}(k)=\frac{P(k|k-1)H^{T}}{HP(k|k-1)H^{T}+R} \tag{26}\]  
\[X(k|k)=X(k|k-1)+K_{g}(k)\big{[}Z(k)-HX(k|k-1)\big{]} \tag{27}\]  
The core idea of the EKF algorithm is to combine model predictions with actual measurements to obtain an optimal state estimate by searching for the minimum mean square of the estimation error. This process requires finding a gain \(K_{g}\) that minimizes the mean square of the estimation error, as expressed in Equation (26), after a series of mathematical derivations. Equation (27) represents a correction based on the difference (i.e., the residual) between the predicted state variable \(X\) and the actual measurement \(Z\). This perspective \(K_{g}\) determines the extent to which the predicted state variables are corrected based on the measurement residuals. It should be noted that the \(X(k|k-1)\) in the a priori estimation equation differs from the \(X(k)\) in the measurement equation. \(X(k|k-1)\) is obtained from the prediction of the system state at the step \((k-1)\); whereas, \(X(k)\) is the measurement at the step \(k\), which is independent of the values of the measurements at the last step.