## 3 RUL Prediction Methodology
### Bayesian RUL Prediction Based on Extended Kalman Filter
#### 3.4.5 Uncertainty Estimation  
Estimating the uncertainty of the predicted RUL plays an important role in the evaluation of prediction reliability. Based on the Gaussian assumption of the state process noise and the measurement noise, the confidence level of the RUL prediction can be calculated based on the a posteriori estimate of the covariance matrix for state process error, \(\widetilde{\mathbf{r}}_{t|t}\), which is updated based on the filter gain as in (37). As the first diagonal element of \(\widetilde{\mathbf{P}}_{t|t}\) is the variance of the estimated state at each time step, the 95% credible interval of state can be determined as follows  
\[\widetilde{x}_{t,lower}=\widetilde{\mathbf{x}}_{t|t}(1)-1.96\sqrt{\widetilde{\mathbf{ P}}_{t|t}(1,1)}. \tag{39}\]  
\[\widetilde{x}_{t,upper}=\widetilde{\mathbf{x}}_{t|t}(1)+1.96\sqrt{\widetilde{\mathbf{ P}}_{t|t}(1,1)}. \tag{40}\]  
Substituting (39) and (40) to (38), the lower bound and the upper bound of the estimated RUL can be analogously extrapolated based on the end-of-life threshold. For implementation reference, the pseudo-code of the EKF-based RUL estimation algorithm is shown in Table 3.  
**Input:** The ESI observations, \(\mathbf{z}_{t_{PDT-n+1 PT}}\), EOL threshold, \(\overline{\gamma}\), RUL prediction time \(t_{PT}\), state process noise variance, \(\sigma_{\
u}^{2}\), and the measurement noise variance, \(\sigma_{\
u}^{2}\)  
**Initialization:** State vector \(\widetilde{\mathbf{x}}_{0}\), covariance of state process error,\(\widetilde{\mathbf{P}}_{0}\)  
For steps \(t=1,\ \ldots,(t_{PT}-t_{PDT-n})\), if \(x_{t}<\overline{\gamma}\), implement the following:  
1) Predict a prior estimate of state \(\widetilde{\mathbf{x}}_{t|t-1}\) by (32), measurement \(\widetilde{\mathbf{z}}_{t|t-1}\) by (33), and the covariance of state process error \(\widetilde{\mathbf{P}}_{t|t-1}\) by (34). 2) The extended Kalman filter gain \(\mathbf{K}_{t}\) is computed by (35). 3) Obtain ESI observation at time step \(t\), \(\mathbf{z}_{t}\), to calculate measurement prediction error \(\left(\mathbf{z}_{t}-\widetilde{\mathbf{z}}_{t|t-1}\right)\), and update the posterior estimations of state \(\widetilde{\mathbf{x}}_{t|t}\) by (36) and covariance matrix \(\widetilde{\mathbf{P}}_{t|t}\) by (37). 4) \(t=t+1\), repeat from 1). Extrapolate the RUL at the prediction time \(\widetilde{rul}_{t_{PT}}\) based on the state transition model via (38). Compute the 95% credible interval of the estimated RUL based on analogous extrapolation by (39) and (40). **Output:** RUL estimates at the prediction time \(\widetilde{rul}_{t_{PT}}\) with its credible interval. \begin{table}
\begin{tabular}{c} \hline
**Input:** The ESI observations, \(\mathbf{z}_{t_{PDT-n+1 PT}}\), EOL threshold, \(\overline{\gamma}\), RUL prediction time \(t_{PT}\), state process noise variance, \(\sigma_{\
u}^{2}\), and the measurement noise variance, \(\sigma_{\
u}^{2}\)  
**Initialization:** State vector \(\widetilde{\mathbf{x}}_{0}\), covariance of state process error,\(\widetilde{\mathbf{P}}_{0}\)  
For steps \(t=1,\ \ldots,(t_{PT}-t_{PDT-n})\), if \(x_{t}<\overline{\gamma}\), implement the following:  
1) Predict a prior estimate of state \(\widetilde{\mathbf{x}}_{t|t-1}\) by (32), measurement \(\widetilde{\mathbf{z}}_{t|t-1}\) by (33), and the covariance of state process error \(\widetilde{\mathbf{P}}_{t|t-1}\) by (34). 2) The extended Kalman filter gain \(\mathbf{K}_{t}\) is computed by (35). 3) Obtain ESI observation at time step \(t\), \(\mathbf{z}_{t}\), to calculate measurement prediction error \(\left(\mathbf{z}_{t}-\widetilde{\mathbf{z}}_{t|t-1}\right)\), and update the posterior estimations of state \(\widetilde{\mathbf{x}}_{t|t}\) by (36) and covariance matrix \(\widetilde{\mathbf{P}}_{t|t}\) by (37). 4) \(t=t+1\), repeat from 1). Extrapolate the RUL at the prediction time \(\widetilde{rul}_{t_{PT}}\) based on the state transition model via (38). Compute the 95% credible interval of the estimated RUL based on analogous extrapolation by (39) and (40).