## 4 SOC Estimation Based on EKF and UKF
### Unscented Kalman Filtering  
Kalman filter is an optimum state recursive observer, and the frameworks of both EKF and UKF have a similar prediction-update structure. Alternatively, UKF linearized the system by unscented \begin{table}
\begin{tabular}{c} \hline \hline
**Initialization** \\ \hline \(1\). Initialize with: \\ \(\hat{x}_{0|0}=E(x_{0})\), \(P_{0|0}=E\Bigl{[}\Bigl{(}x_{0}-\hat{x}_{0|0}\Bigr{)}\Bigl{(}x_{0}-\hat{x}_{0|0} \Bigr{)}^{T}\Bigr{]}\) \\ \hline \multicolumn{2}{c}{**State prediction**} \\ \hline \(1\). Update the step state vector: \\ \(\hat{x}_{k|k-1}=A_{k-1}\hat{x}_{k-1|k-1}+B_{k-1}u_{k-1}\) \\ \(2\). Update the step error covariance: \\ \(P_{k|k-1}=A_{k-1}P_{k-1|k-1}A_{k-1}^{T}+\Gamma_{k-1}Q_{k-1}\Gamma_{k-1}^{T}\) \\ \hline \multicolumn{2}{c}{**Measurement update**} \\ \hline \(1\). Calculate the Kalman gain: \\ \(K_{k}=P_{k|k-1}C_{k}^{T}\Bigl{(}C_{k}P_{k|k-1}C_{k}^{T}+R_{k}\Bigr{)}^{-1}\) \\ \(2\). Update the measurement vector: \\ \(\hat{x}_{k|k}=\hat{x}_{k|k-1}+K_{k}(y_{k}-g(x_{k},u_{k}))\) \\ \(3\). Update the error covariance: \\ \(P_{k|k}=(1-K_{k}C_{k})P_{k|k-1}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Summary of the extended Kalman filter (EKF) approach for SOC estimation. transform (UT) rather than the Taylor expansion adopted by EKF. UKF not only achieves a higher-order approximation expansion but also avoids the need to compute the Jacobian matrix. Based on the same discretized state-space Equations (13) and (14), the UKF algorithm steps are as follows:  
Let \(\chi\) be a n-dimension vector which obeys \(X=\) N(\(\chi\), P) distribution. Initialization:  
\[\overline{x}_{0}=E(x_{0}),\ P_{0}=\left[(x_{0}-\overline{x}_{0})(x_{0}- \overline{x}_{0})^{T}\right] \tag{23}\]  
Generate the sigma points via:  
\[\chi_{i,k-1}=\left\{ \begin{array}{cc}\overline{x}_{k-1},&i=0\\ \overline{x}_{k-1}+\left(\sqrt{(n+\lambda)P_{k-1}}\right),&i=1,\ 2,\ \ldots,\ n\\ \overline{x}_{k-1}-\left(\sqrt{(n+\lambda)P_{k-1}}\right),&i=n+1,\ \ldots,\ 2n \end{array} \right. \tag{24}\]  
And their weights are computed via:  
\[\left\{ \begin{array}{cc}W_{0}^{m}=\frac{\lambda}{(n+\lambda)}\\ W_{i}^{m}=\frac{1}{2(n+\lambda)}&i=1,\ \ldots,\ 2n\end{array} \right. \tag{25}\]  
\[\left\{ \begin{array}{cc}W_{0}^{c}=\frac{\lambda}{(n+\lambda)}+\left(1- \alpha^{2}+\beta\right)\\ W_{i}^{c}=\frac{1}{2(n+\lambda)}&i=1,\ \ldots,\ 2n\end{array} \right. \tag{26}\]  
where \(\lambda\) is the scaling parameter, which satisfies:  
\[\lambda=\alpha^{2}(n+\kappa)-n \tag{27}\]  
\(\alpha\) is a small positive number (\(10^{-4}\leq\alpha\leq 1\)). \(\beta\) is used for absorbing a priori information for variable \(\chi\). For Gaussian distribution, \(\beta=2\) is optimal. \(\kappa\) is a scaling factor that determine the degree of freedom of the sigma points, usually set \(0\) or \(3-n\) to guarantee the positive definiteness of output variable covariance. Prediction update:  
\[\chi_{i,k|k-1}=f\big{(}\chi_{i,k-1},\ u_{k}\big{)}\qquad i=0,\ \ldots,\ 2n \tag{28}\]  
\[\overline{x}_{k|k-1}=\sum_{i=0}^{2n}W_{i}^{m}\chi_{i,k|k-1} \tag{29}\]  
Update the error covariance:  
\[P_{k|k-1}=\sum_{i=0}^{2n}W_{i}^{c}\Big{(}\chi_{i,k|k-1}-\overline{x}_{k|k-1} \Big{)}\Big{(}\chi_{i,k|k-1}-\overline{x}_{k|k-1}\Big{)}^{T}+Q_{k} \tag{30}\]  
where \(Q_{k}\) is the covariance matrix of the state noise. Measurement update:  
\[y_{i,\ k|k-1}=g\big{(}\chi_{i,k-1},u_{k}\big{)}\qquad i=0,\ \ldots,\ 2n \tag{31}\]  
\[\overline{y}_{k|k-1}=\sum_{i=0}^{2n}W_{i}^{m}y_{i,k-1} \tag{32}\]  
Calculate prediction covariance and cross-covariance:  
\[P_{yy,\ k}=\sum_{i=0}^{2n}W_{i}^{c}\Big{(}y_{i,k|k-1}-\overline{y}_{k|k-1} \Big{)}\Big{(}y_{i,k|k-1}-\overline{y}_{k|k-1}\Big{)}^{T}+R_{k} \tag{33}\]\[P_{xy,\ k}=\sum\limits_{i=0}^{2n}W_{i}^{c}\Big{(}x_{i,k|k-1}-\overline{x}_{k|k-1} \Big{)}\Big{(}y_{i,k|k-1}-\overline{y}_{k|k-1}\Big{)}^{T} \tag{34}\]  
where \(R_{k}\) is the covariance matrix of the measurement noise.