# Forward problem of Kalman filter causing NaN values during recursion?

$$\begin{eqnarray} X_k &=& F X_{k-1}+ \omega_k \nonumber \\ Z_k &=& H X_k + \nu_k \end{eqnarray}$$

The first equation is state exploration equation and second one measurement equation. Point to be noted, I dont have $$Bu$$ term in my state equation unlike common state exploration equation. Here, I was trying to generate the data (forward problem) to Kalman filter application using both the above equations with known process noise $$\omega_k$$ and measuremenet noise $$\nu_k$$. First I compute $$Xk$$ and then plug into second equation to calculate $$Z_k$$.

During the synthetic data generation, my $$X_k$$ values are going to NaN as it is recusive. Could some one help me to understand the problem and also any suggestion on Kalman filter examples where the data is generated via these two equations and then a Kalman filter is used to estimate the states $$\hat{X}_k$$? The main goal is use the known $$\omega_k$$ and $$\nu_k$$ in forward problem data generation and then use the same values in Q and R matrix to solve with Kalman filter.

I looked into several examples in the internet and I see data is randomly generated and the it is solved with Kalman filter to estimate the states by randomly creating/tuning Q and R matrix.

• Could you share code or data?
– Royi
Feb 10 at 11:41
• dsp.stackexchange.com/questions/86622/… Feb 12 at 8:57
– Royi
Jun 22 at 7:57

• @Sagar Nope. If $\lambda$ is an eigenvalue you have to have $|\lambda|<1$. In short it comes from the fact that in order to compute $X_n$ you have to compute $A^{n}$. Therefore, if you put $A$ in its triangle form on the diagonal you have all you eigenvalues put to the power n as $\lambda^{n}$. In other words, your system is as stable as $\lambda^{n}$ with $\lambda$ the eigenvalue of A with the biggest modulus Then if one of them is bigger than one, $X_n$ diverges. So check for the modulus. Feb 13 at 10:33
The model equation of the Kalman Filter: $$\boldsymbol{x}_{k} = F \boldsymbol{x}_{k} + \boldsymbol{w}_{k}$$ is basically like a Fixed Point Iteration operator.
Hence it requires the operator, $$F$$ to have its eigen values within the unit circle.
Usually, in the context of Kalman Filter, we use pre defined models with their respective $$F$$. In the common templates the model matrix is stable.