# An Improved Adaptive Iterative Extended Kalman Filter Based on Variational Bayesian
## 2 Computational Procedure
### Posterior PDFs  
Here, we elaborate on the meticulous process of updating posterior PDFs. In order to calculate \(\tilde{\chi}_{t}\), \(P_{t\mid t-1}\), and \(R_{t}\), the joint posterior probability density function \(p\Big{(}\tilde{\chi}_{t},P_{t\mid t-1},R_{t}\mid\hat{Z}_{1:t}\Big{)}\) needs to be determined. Since there is no analytical solution available for this joint posterior probability density function (PDF), the variational Bayesian (VB) approach is employed to derive an approximate PDF that is factorized and flexible for:  
\[p\Big{(}\tilde{\chi}_{t},P_{t\mid t-1},R_{t}\mid\hat{Z}_{1:t}\Big{)}\approx q \big{(}\tilde{\chi}_{t}\big{)}q\Big{(}P_{t\mid t-1}\Big{)}q(R_{t}) \tag{19}\]  
where \(q(\cdot)\) corresponds to the somewhat posterior PDF of \(p(\cdot)\). Therefore, it is possible to produce the VB approximation by minimizing the Kullback-Leibler Divergence (KLD) [38] between the posterior PDFs of the genuine joint \(p\Big{(}\tilde{\chi}_{t},P_{t\mid t-1},R_{t}\mid\hat{Z}_{1:t}\Big{)}\) and the approximation \(q\big{(}\tilde{\chi}_{t}\big{)},q\Big{(}P_{t\mid t-1}\Big{)},q(R_{t})\):  
\[\Big{\{}q\big{(}\tilde{\chi}_{t}\big{)},\Big{(}P_{t\mid t-1}\Big{)},q(R_{t}) \Big{\}}=arg\ minKLD\left( \begin{array}{c}q\big{(}\tilde{\chi}_{t}\big{)},q \Big{(}P_{t\mid t-1}\Big{)}q(R_{t})\\ \parallel p\Big{(}\tilde{\chi}_{t},P_{t\mid t-1},R_{t}\mid\hat{Z}_{1:t} \Big{)}\end{array} \right) \tag{20}\]  
Therefore, it can also be written as:  
\[\log q^{(i+1)}\Big{(}P_{t\mid t-1}\Big{)}=-\tfrac{1}{2}\Big{(}a+\hat{t}_{t \mid t-1}+2\Big{)}\log\Big{|}P_{t\mid t-1}\Big{|}-\tfrac{1}{2}\tr\Big{(} \Big{(}\tilde{\Lambda}_{t}^{(i)}+T_{t\mid t-1}\Big{)}P_{t\mid t-1}^{-1}\Big{)} +c_{P_{t\mid t-1}} \tag{21}\]  
Additionally, Equations (22) and (27) can be obtained. \(q^{(i+1)}(\cdot)\) represents the approximate PDF of the \(i+1\)th iteration of \(q(\cdot)\), and \(\tilde{\Lambda}_{t}^{(i)}\) is defined as follows:  
\[ \begin{split}&\tilde{\Lambda}_{t}^{(i)}=\mathrm{E}^{(i)}\bigg{[} \Big{(}\tilde{\chi}_{t}-\hat{\chi}_{t\mid t-1}\Big{)}\Big{(}\tilde{\chi}_{t}- \hat{\chi}_{t\mid t-1}\Big{)}^{T}\bigg{]}\\ &=P_{t\mid t}^{(i)}+\Big{(}\hat{\chi}_{t\mid t}^{(i)}-\hat{\chi}_ {t\mid t-1}\Big{)}\Big{(}\hat{\chi}_{t\mid t}^{(i)}-\hat{\chi}_{t\mid t-1} \Big{)}^{T}\end{split}  \tag{22}\]  
where \(\mathrm{E}^{(i)}[\rho]\) represents the expected value of variable \(\rho\) at iteration \(i\)-th. The IW distribution with the parameter of freedom \(\hat{t}_{t\mid t-1}^{(i+1)}\) and scale matrix \(\hat{T}_{t\mid t-1}^{(i+1)}\) can be regarded as \(q^{(i+1)}\Big{(}P_{t\mid t-1}\Big{)}\):  
\[q^{(i+1)}\Big{(}P_{t\mid t-1}\Big{)}=IW\Big{(}P_{t\mid t-1},\hat{t}_{t}^{(i+1) },\hat{\Upsilon}_{t}^{(i+1)}\Big{)} \tag{23}\]  
where \(\hat{t}_{t\mid t-1}^{(i+1)}\) is the parameter of freedom and \(\hat{\Upsilon}_{t\mid t-1}^{(i+1)}\) is the scale matrix:  
\[\hat{t}_{t}^{(i+1)}=\hat{t}_{t\mid t-1}+1 \tag{24}\]\[\hat{T}_{t}^{(i+1)}=\tilde{A}_{t}^{(i)}+\hat{T}_{t|t-1} \tag{25}\]  
Its comprehensive form is:  
\[\log q^{(i+1)}(R_{t})=-\tfrac{1}{2}\Big{(}b+\hat{u}_{t|t-1}+2\Big{)}\log|R_{t}|- \tfrac{1}{2}\operatorname{tr}\Big{(}\Big{(}\tilde{Z}_{t}^{(i)}+\hat{U}_{t|t-1} \Big{)}R_{t}^{-1}\Big{)}+c_{R_{t}} \tag{26}\]  
where \(B_{k}^{(i)}\) has the following definition:  
\[ \begin{array}{l}\tilde{B}_{k}^{(i)}=E^{i}\Big{[}\big{(}\tilde{Z}_{t}-h\big{(} \tilde{X}_{t}\big{)}\big{)}\big{(}\tilde{Z}_{t}-h\big{(}\tilde{X}_{t}\big{)} \big{)}^{T}\Big{]}\\ =\int\big{(}\tilde{Z}_{t}-h\big{(}\tilde{X}_{t}\big{)}\big{)}\big{(}\tilde{Z}_ {t}-h\big{(}\tilde{X}_{t}\big{)}\big{)}^{T}N\Big{(}\tilde{X}_{t};\hat{X}_{t|t }^{(i)}P_{t|t}^{(i)}\Big{)}d\tilde{X}_{t}\end{array}  \tag{27}\]  
Equation (26) states that \(q^{(i+1)}(R_{t})\) may be thought of as the IW distribution, where \(\hat{u}_{t|t-1}^{(i+1)}\) stands in for the freedom parameter and \(\hat{U}_{t|t-1}^{(i+1)}\) for the scale matrix.