State estimator design using Jordan based long short-term memory networks Avneet Kaur a and Kirsten Morris a Abstract State estimation of a dynamical system refers to estimating the state of a system given an imperfect model, noisy measurements and some or no information about the initial state. While Kalman filtering is optimal for estimation of linear systems with Gaussian noises, calculation of optimal estimators for nonlinear systems is challenging. We focus on establishing a pathway to optimal estimation of high-order systems by using recurrent connections motivated by Jordan recurrent neural networks(JRNs). The results are compared to the corresponding Elman structure based long short-term memory network(ELSTM) and the KF for linear and EKF for nonlinear systems. The results suggest that for nonlinear systems, the use of long short-term memory networks can improve estimation error and also computation time. Also, the Jordan based long short-term memory networks(JLSTMs) require less training to achieve performance similar to ELSTMs. keywords state estimation, machine learning, neural networks, long short-term memory networks † † affiliation: a Department of Applied Mathematics, University of Waterloo, Ontario, Canada 1 Introduction The problem of estimating the state of a dynamical system given a noisy model, noisy measurements and partial information about the initial state is called state estimation. In practical applications estimating the state is a challenging task for various reasons. The complexity of high-order systems, availability of a finite number of measurements, inaccurate measurements, incomplete information about the initial state and errors in model can make it difficult to estimate the state of the system. Some review papers on state estimation are Kutschireiter et al. ((2020)) ; Bernard et al. ((2022)) ; Jin et al. ((2021)) ; Jin et al. ((2021)) . Various model-based approaches to the problem of state estimation exist. The Kalman filter(KF) in Kalman ((1960)) is a recursive and easy to implement filter. It is used for optimal state estimation of linear systems with Gaussian stochastic noises. The most obvious generalization of this filter to nonlinear systems is the extended Kalman filter(EKF). The EKF relies on linearization of the system at each time-step. Such a generalization does not work well for many nonlinear systems and only local convergence guarantees are available (see for example, Krener ((2003)) ; Afshar et al. ((2023)) ). Furthermore, the EKF is not optimal. Another common approach is to use the unscented Kalman filter which has lesser linearization error than the EKF. The idea is to chose some specific sample points instead of using the entire density function to propagate means and co-variances. The nonlinear transformation is then applied only on the sample points leading to a decrease in the linearization error. But it is still not an optimal method and can be computationally intensive. To perform state estimation in an optimal manner, the Kalman filter approach is extended in Mortensen ((1968)) to continuous-time nonlinear state-space systems. The idea is to estimate the initial condition noise and process noise which in turn provides the optimal state estimator. Certain assumptions ensure that an optimum for the maximum likelihood cost function for continuous-time systems exists. Moireau ((2018)) extended the results in Mortensen ((1968)) to discrete-time state space systems. However, this approach involves solving the Hamilton-Jacobi Bellman equation which in itself is a challenging task as it is a second-order nonlinear partial differential equation whose solution is affected by the curse of dimensionality (see for example, Krener ((2003)) ; Pequito et al. ((2011)) ; Kang & Wilcox ((2017)) ; Nakamura-Zimmerer et al. ((2021)) ). Thus, even though optimal, this approach is not widely used. Using only input-output data to identify states is called system identification or trajectory tracking. A major difference between these methods and state estimation is that they do not use the model, even when it is available. Recurrent neural networks have been shown to work well for system identification (see for example, Park et al. ((2020)) . Jordan recurrent neural networks(JRNs) have been used for system identification by several researchers, including Kasiran et al. ((2012)) ; Wu et al. ((2019)) , and have been shown to work as well as Elman recurrent neural networks(ERNs). Convergence analysis, with some assumptions, of JRNs as well as ERNs for system identification has been discussed in Kuan et al. ((1994)) . To predict future values based on observed trends in data is called time-series analysis or forecasting. Recurrent neural networks have been used for forecasting from several years. ERNs provided the best estimation properties when compared with the method of least squares and feedforward neural networks for noisy time series data with fully observable states in Gencay & Liu ((1997)) . In Cana et al. ((2021)) , an Elman-based long short-term memory (ELSTM) network architecture is explored for different systems and compared with an EKF for filtering. The authors conclude that the proposed ELSTM structure performs better than the EKF for nonlinear systems. In Kandiran & Hacinliyan ((2019)) , authors show that the ERN performs at least as well as a feedforward neural network for Lyapunov exponents forecasting, discussing cases where it performs better in detail as well. Since a model, when available, can help improve estimate accuracy, methods combining model as well as data are attractive. Machine learning approaches to state estimation are being explored. A machine learning framework that overcame the requirement to find solutions to the Hamilton-Jacobi Bellman partial differential equation in the continuous-time case is discussed in Breiten & Kunisch ((2021)) . A neural network to approximate the gradient of the solution of Hamilton-Jacobi Bellman equation is used. The equation is exploited to construct the filter which is referred to as the observer gain. It is shown that the results coincide with the Kalman-Bucy filter for a linear problem. A hybrid approach, which utilised the KF framework of correction and prediction for discrete-time systems, is discussed in C. Gao et al. ((2019)) . Even though the focus of this work was trajectory tracking, the modified assumptions and use of model, led to the problem being that of state estimation. Recurrent neural networks are used, in particular, long short-term memory networks, to approximate the state from observations, initial data and noise estimates. A two step process of prediction and correction is used and two frameworks are presented, one Bayesian and the other non-Bayesian. For the Bayesian approach, the neural network is designed so that it predicts and filters iteratively within the same network. This framework is supported by using Bayes rule. For the non-Bayesian approach two deep ELSTM networks are used, one network for prediction and the other for filtering, based on the fact that neural networks are individually capable of performing both the steps independently. Thus, one network performed prediction without measurements and the other network corrected the predictions by using new measurements. This approach is considered hybrid as the model is used for training data generation. da C. Ramos et al. ((2020)) used nonlinear regression on data generated by solving the system and estimator dynamics to approximate a Luenberger estimator. A Luenberger estimator for discrete-time nonlinear systems is found by approximating the mapping using unsupervised learning in Peralez & Nadri ((2021)) . In Benosman & Borggaard ((2021)) , a method to design robust, low-order observers for a class of spectral infinite-dimensional nonlinear systems was discussed. This method included a data-driven learning algorithm to optimise observer performance. Jun Fu Fu et al. ((2016)) proposed a multi-time scales neural-network based adaptive estimator design. A deep-learning method to solve the Hamilton-Jacobi Bellman equation for state estimation was proposed in Adhyaru ((2012)) . A neural network was used to approximate the solution, which further helped find the estimator gain. Benosman & Borggaard ((2021)) discuss a robust, low order estimator using principal orthogonal decomposition(POD) for a class of spectral infinite-dimensional nonlinear systems. A data-driven method is used to auto-tune the estimator gains. The results are tested on 1D Burgers equation Benosman & Borggaard ((2021)) and 2D Boussinesq equations Benosman & Borggaard ((2021)) . Reinforcement learning-based approaches are also becoming popular due to recent advancements in the field. In X. Gao et al. ((2020)) , the authors proposed a reinforcement learning framework combined with a KF for tracking ground vehicles using an integrated navigation system, and called it an adaptive KF navigation algorithm. The state of the system was estimated using a KF and then used to calculate rewards for a reinforcement learning framework which updated the process noise covariance. In Slade et al. ((2020)) the problem is viewed as a Bayes-adaptive Markov decision process and solved online using Monte Carlo tree search with an unscented KF to account for process noise and parameter uncertainty. For details about Monte Carlo tree search see Bertsekas ((2019)) . Use of a reduced-order system is a common approach since it helps overcome the curse of dimensionality. A deep state estimator which used a neural network methodology to develop a nonlinear relationship between the measurements and a reduced order state was developed in Nair & Goza ((2020)) . This relationship was commonly approximated as linear and then they used the advancements in the field of deep learning to make better approximations. The approximated reduced-order state was used as an initial condition to estimate the full state. His proposed methodology outperformed common linear estimation algorithms when tested on 1D Burgers equation and 2D Boussinesq equations. Several neural networks for state estimation of low-order systems were proposed in Xie & Zhang ((2021)) . A recurrent neural network based on the principles of a decoupled EKF for state estimation was introduced in Yadaiah et al. ((2011)) and used on reduced order models. While feedforward neural networks do not link outputs or the hidden states at the previous time-step to the one at the next time-step, recurrent neural networks have varying structures linking outputs and/or hidden states at different time-steps. This property is of great importance for us, since in dynamical systems, the state at the previous time-step, plus any inputs, determine the state at the next time-step. Another advantage of recurrent neural networks is that they can have a nonlinear activation function which is helpful for estimating the states of nonlinear systems. While this suggests that JRNs would be a good choice for state estimation of sequences, when it comes to longer sequences, training them can be extremely time-consuming (see for example, Manaswi ((2018)) ). This motivates the use of long short-term memory networks. Furthermore, choosing the right type of connections in a network is important. This can help the network to converge faster leading to lesser training time. It can also help in stability analysis and convergence analysis. In this work, we combine the idea of a state estimation algorithm with the tools of machine learning. Section 2 discusses the structure of an ERN and a JRN followed by a universal approximation theorem for state estimation using JRNs. The Jordan recurrent network is more closely related to the structure of a dynamical system than Elman networks which suggests that it might be more appropriate for state estimation. The Elman long short-term memory network (ELSTM) framework is thus extended to a Jordan-based long short-term memory (JLSTM) network in hope that this structure will have reduced training time. In Section 4 implementation of ELSTM and JLSTM is described. Implementation of both structures was done similarly to ensure valid comparison. In section 5 , both structures are used to construct estimators for a number of examples. In Section 6 , the results of ELSTM, JLSTM and KF/EKF are discussed. Both neural network-based estimators compare well to the traditional Kalman filters. However, the JLSTM network takes lesser training time as compared to an ELSTM to achieve similar performance. 2 State estimation using simple recurrent neural networks This work considers noisy discrete-time state space systems \displaystyle\begin{split}x^{(t+1)}&=f(x^{(t)})+\omega^{(t+1)}\\ y^{(t+1)}&=h(x^{(t+1)})+\nu^{(t+1)}\\ x^{(0)}&=x^{0}+\bar{x}^{0}\end{split} (1) where x^{(t+1)}\in\mathcal{X}\subseteq\mathbb{R}^{n},n\in\mathbb{N} is the state vector of the system at time-step t+1,y^{(t+1)}\in\mathcal{Y}\subseteq\mathbb{R}^{m},m\in\mathbb{N} is the measurement vector at time-step t+1,\omega^{(t+1)} is the process noise vector at time-step t+1 , \nu^{(t+1)} is the measurement noise vector at time-step t+1 , x^{0} is the true initial condition and \bar{x}^{0} is the initial condition noise. The functions f and h are known and continuously differentiable. The aim of state estimation is to estimate the state x^{(t+1)} based on new measurement y^{(t+1)}, previous state estimate \hat{x}^{(t)} , and some information on the distribution of the initial condition x^{(0)}. Definition 2.1 (Activation function) . A function \sigma(\cdot):\mathbb{R}\rightarrow[a,b] is called an activation function, if \sigma is monotonically increasing, \lim\limits_{z\to-\infty}\sigma(z)=a and \lim\limits_{z\to\infty}\sigma(z)=b. Figure 1: The structure of an Elman recurrent neural network(ERN) for state estimation. It uses hidden to hidden recurrent connections. The symbols y^{(t)},a^{(t)},x^{(t)} and \hat{x}^{(t)} represent input measurement vector, hidden layer vector, true state vector and estimated state vector respectively at time t . The cost function J is considered to be mean squared error(MSE). The weights and biases are represented by W_{ay},W_{aa},W_{xa},b_{a} and b_{x}. An Elman recurrent network (ERN) can been used for state estimation. In an ERN, the hidden layer at the previous time-step connects to the hidden layer at the next time-step(Fig. 1 ). ERNs are proven to be universal approximators for dynamical systems in Schäfer & Zimmermann ((2007)) . For state estimation, one can choose the inputs of the ERN at time-step t to be the measurements at time-step t and the outputs of the ERN to be the estimated state at time-step t. Thus, an ERN acts like a filter. The forward propagation of an ERN for state estimation is \displaystyle\begin{split}a^{(t)}&=\sigma(W_{ay}y^{(t)}+W_{aa}a^{(t-1)}+b_{a})\\ \hat{x}^{(t)}&=W_{xa}a^{(t)}+b_{x}\end{split} (2) where \sigma(\cdot) is the activation function and \hat{x}^{(t)} is the estimated state vector at time-step t . The hidden layer vector at time-step t is a^{(t)}. The measurement vector at time-step t is denoted by y^{(t)}. The weights and biases of the network are represented by W_{ay},W_{aa},W_{xa},b_{a} and b_{x} respectively. The approximation theorem for ERNs of a dynamical system presented in Schäfer & Zimmermann ((2007)) can be extended to estimation with slight modifications. Since the proof is very similar to that in Schäfer & Zimmermann ((2007)) , it is omitted. In a JRN, instead of using the previous hidden vector in calculation of the updated estimate, the estimate at the previous time-step t is to update the state (Fig. 2 ). Thus, a Jordan-based recurrent neural network structure mimics the structure of a dynamical system ( 1 ). This suggests that training and accuracy of an estimator may be improved over other structures by using a JRN. The forward propagation of a JRN for state estimation(Fig. 2 ) is \displaystyle\begin{split}a^{(t)}&=\sigma(W_{ay}y^{(t)}+W_{ax}\hat{x}^{(t-1)}+b_{a})\\ \hat{x}^{(t)}&=W_{xa}a^{(t)}+b_{x}\end{split} (3) where \sigma(\cdot) is the activation function and \hat{x}^{(t)} is the estimated state vector at time-step t . The hidden layer vector at time-step t is given by a^{(t)}. The weights and biases of the network are represented by W_{ay},W_{ax},W_{xa},b_{a} and b_{x} respectively. Figure 2: The structure of the Jordan recurrent network(JRN) proposed for state estimation. It uses output-to-hidden recurrent connections similar to the filter’s dynamical system. The symbols y^{(t)},a^{(t)},x^{(t)} and \hat{x}^{(t)} represent input measurement vector, hidden layer vector, true state vector and estimated state vector respectively at time t . Cost function J^{(t)} is the mean squared error at time t . The weights and biases of the network are represented by W_{ay},W_{ax},W_{xa},b_{x} and b_{y}. It will now be shown that JRNs are universal approximators for an estimator. We first recall the definitions and main results first presented in Hornik et al. ((1989)) and later mentioned in Schäfer & Zimmermann ((2007)) . Definition 2.2 . Let A^{n},n\in\mathbb{N} be the set of all affine functions A(\cdot):\mathbb{R}^{n}\rightarrow\mathbb{R} defined as A(z)=w.z-b where w,z\in\mathbb{R}^{n},b\in\mathbb{R} and ‘.’ denotes dot product. Definition 2.3 . For any Borel-measurable function \sigma(\cdot):\mathbb{R}\rightarrow\mathbb{R} and n\in\mathbb{N} define \Sigma^{n}(\sigma)=\{(NN:\mathbb{R}^{N}\rightarrow\mathbb{R}):NN(z)=\sum_{j=1}^{J}\theta_{j}\sigma(A_{j}(z)),\\ z\in\mathbb{R}^{n},\theta_{j}\in\mathbb{R},A_{j}\in A^{n},J\in\mathbb{N}\}. (4) The function class \Sigma^{n}(\sigma) can be written in matrix form as NN(z)=\theta\sigma(Wz-b), where x\in\mathbb{R}^{n},\theta,b\in\mathbb{R}^{\tilde{h}} and W\in\mathbb{R}^{\tilde{h}\times n}. Here function \sigma is applied component-wise. Similarly, the for function class JRN^{m,n}(\sigma),\sigma is defined component-wise. Let \mathcal{M}^{n} and \mathcal{C}^{n} be the set of all Borel-measurable and continuous functions (both from \mathbb{R}^{n}\rightarrow\mathbb{R} ) respectively. Let the Borel \sigma algebra of \mathbb{R}^{N} be denoted by \mathbb{B}^{n}. Thus, (\mathbb{R}^{n},\mathbb{B}^{n}) refers to the n -dimensional Borel measurable space. Clearly, for every continuous Borel-measurable function \sigma , \Sigma^{n}(\sigma)\subset\mathcal{C}^{n}\subset\mathcal{M}^{n}. Definition 2.4 . Let (X,\rho) be a metric space and U,T\subseteq X. Then U is \rho- dense in T, if \forall\epsilon>0 and \forall t\in T,\exists u\in U, such that \rho(u,t)<\epsilon. Definition 2.5 . A subset U of \mathcal{C}^{n} is said to be uniformly dense on a compact domain in \mathcal{C}^{n} if for every compact subset K\subseteq\mathbb{R}^{n},U is \rho_{K} -dense in \mathcal{C}^{n}, where for g_{1},g_{2}\in\mathcal{C}^{n}, \rho_{K}(g_{1},g_{2})\equiv\sup_{x\in K}|g_{1}(x)-g_{2}(x)|. Definition 2.6 . Let \mu be a probability measure on (\mathbb{R}^{n},\mathbb{B}^{n}). Functions g_{1},g_{2}\in\mathcal{M}^{n} are said to be \mu -equivalent if \mu\{x\in\mathbb{R}^{n}:g_{1}(x)=g_{2}(x)\}=1. Definition 2.7 . Define the metric \rho_{\mu}:\mathcal{M}^{n}\times\mathcal{M}^{n}\rightarrow\mathbb{R}^{+} on (\mathbb{R}^{n},\mathbb{B}^{n}) as \rho_{\mu}(g_{1},g_{2})=\inf\{\epsilon>0:\mu\{x\in\mathbb{R}^{n}:|g_{1}(x)-g_{2}(x)|>\epsilon\}<\epsilon\} (5) where \mu is a probability measure on (\mathbb{R}^{n},\mathbb{B}^{n}). Note that if functions g_{1} and g_{2} are \mu -equivalent, then \rho_{\mu}(g_{1},g_{2})=0. Theorem 2.8 . Hornik et al. ((1989)) (Universal approximation theorem for feed-forward neural networks) For any activation function \sigma:\mathbb{R}\rightarrow[0,1], any dimension n and any probability measure \mu on (\mathbb{R}^{n},\mathbb{B}^{n}),\Sigma^{n}(\sigma) is uniformly dense on a compact domain in \mathcal{C}^{n} and \rho_{\mu}- dense in \mathcal{M}^{n}. Corollary 2.9 . Hornik et al. ((1989)) Theorem 2.8 holds for the approximation of functions \mathcal{C}^{m,n} and \mathcal{M}^{m,n} by the extended function class \Sigma^{m,n}. Thereby the metric \rho_{\mu} is replaced by \rho^{n}_{\mu}:=\sum_{l=1}^{n}\rho_{\mu}(f_{l},g_{l}). We now introduce the following definition to extend the universal approximation theorem for feedforward neural networks to universal approximation of internal states of a state space system by Jordan recurrent networks. Definition 2.10 . For any Borel-measurable function \sigma and m,n\in\mathbb{N} define {JRN}^{m,n}(\sigma) as the class of functions x^{(t+1)}=W_{xa}\sigma(W_{ay}y^{(t)}+W_{ax}x^{(t)}-b) where x^{(t)}\in\mathbb{R}^{n},y^{(t)}\in\mathbb{R}^{m}, for t=1,2,...,T. Also, W_{ax}\in\mathbb{R}^{\tilde{h}\times n},W_{ay}\in\mathbb{R}^{\tilde{h}\times m},W_{xa}\in\mathbb{R}^{n\times\tilde{h}} are weight matrices and \theta\in\mathbb{R}^{\tilde{h}} is the corresponding bias where \tilde{h} is the dimension of the hidden state. Theorem 2.11 . (Universal approximation theorem of state estimators using Jordan recurrent neural networks(JRNs)) Let F(\cdot):\mathbb{R}^{n}\times\mathbb{R}^{m}\rightarrow\mathbb{R}^{n} be measurable and h(\cdot):\mathbb{R}^{n}\rightarrow\mathbb{R}^{m} be continuous, the states x^{(t)}\in\mathbb{R}^{n}, and the measurements y^{(t)}\in\mathbb{R}^{m} where t=1,2,...,T for finite T . Then, any state estimator of the form \bar{x}^{(t+1)}=F(\bar{x}^{(t)},y^{(t)}) for the discrete-time dynamical system \begin{split}x^{(t+1)}=f(x^{(t)})\\ y^{(t)}=h(x^{(t)})\end{split} (6) can be approximated by an element of the function class JRN^{m,n}(\sigma) with an arbitrary accuracy, where \sigma is a continuous activation function. Proof. We want to conclude that the estimator \bar{x}^{(t+1)}=F(\bar{x}^{(t)},y^{(t)}) can be approximated by a JRN of the form \hat{x}^{(t+1)}=W_{xa}\sigma(W_{ay}y^{(t)}+W_{ax}\hat{x}^{(t)}-b)\quad\forall t=1,2,...,T with an arbitrary accuracy, where W_{xa},W_{ax} and W_{ay} are appropriate weight matrices, b refers to bias and \sigma is the required activation function. We will begin by using the universal approximation theorem for feed-forward neural networks and then use the continuity of F to reach the conclusion. Let \epsilon>0 and K\subseteq\mathbb{R}^{n}\times\mathbb{R}^{m} be a compact set which contains (\bar{x}^{(t)},y^{(t)}) and (\hat{x}^{(t)},y^{(t)}),\forall t=1,2,...,T. From Theorem 2.8 and Corollary 2.9 , we know that for any measurable function F(\bar{x}^{(t)},y^{(t)}):\mathbb{R}^{n}\times\mathbb{R}^{m}\rightarrow\mathbb{R}^{n} and for an arbitrary \delta>0, a function NN(\bar{x}^{(t)},y^{(t)})=W_{xa}\sigma(W_{ay}y^{(t)}+W_{ax}\bar{x}^{(t)}-b) with weight matrices W_{xa}\in\mathbb{R}^{n\times\tilde{h}},W_{ax}\in\mathbb{R}^{\tilde{h}\times n},W_{ay}\in\mathbb{R}^{\tilde{h}\times m}, bias b\in\mathbb{R}^{\tilde{h}}, and a component-wise applied continuous activation function \sigma(\cdot):\mathbb{R}^{\tilde{h}}\rightarrow\mathbb{R}^{\tilde{h}} exists, such that \forall t=1,2,...,T, \sup_{\bar{x}^{(t)},y^{(t)}}\|F(\bar{x}^{(t)},y^{(t)})-NN(\bar{x}^{(t)},y^{(t)})\|_{\infty}<\delta. (7) Corresponding to a recurrent neural network architecture, \tilde{h} refers to the dimension of the hidden state. Since F is continuous, corresponding to the \delta>0 in Eqn.( 7 ) the following condition holds \|\bar{x}^{(t)}-\hat{x}^{(t)}\|_{\infty}<\epsilon for the following recurrent neural network architecture \hat{x}^{(t+1)}=W_{xa}\sigma(W_{ay}y^{(t)}+W_{ax}\hat{x}^{(t)}-b)\quad\forall t=1,2,....,T where T is finite. This completes the proof. ∎ Thus, JRNs are a suitable choice for state estimation. 3 State estimation using long short-term memory networks While the simple recurrent neural networks described in section 2 can be trained to perform as well as a KF for linear systems and better than the EKF for nonlinear systems (see Kaur et al. ((2024)) ), it has been observed that for complex problems and long term predictions, long short-term memory networks are generally a better choice as they help to resolve the vanishing gradient problem (see for example, Manaswi ((2018)) ) and tend to converge faster. Each LSTM network consists of a cell. In order to handle long term dependencies, several gates are introduced. The forget gate decides the information that should not be carried forward to the next time-step. The input gate determines the new information that needs to be remembered in the cell state. The output gate decides which information will be output from the cell state. A more detailed explanation of these gates, for an ELSTM can be found in, for example, Manaswi ((2018)) . Figure 3: Structure of an Elman long short term memory network(ELSTM) for state estimation. It uses hidden to hidden recurrent connections for state estimation of a nonlinear dynamical system. The symbols y^{(t)},a^{(t)} and \hat{x}^{(t)} represent input measurement vector, hidden layer vector and estimated state vector respectively.The forget, input and output gates are represented by f^{(t)},i^{(t)} and o^{(t)}. The cell state vector and the cell input activation vector are represented by c^{(t)} and \tilde{c}^{(t)} respectively. The weights and biases are represented by W_{fy},W_{fa},W_{iy},W_{ia},W_{oy},W_{oa},W_{\tilde{c}y},W_{\tilde{c}a},W_{xa},b_{f},b_{i},b_{o} and b_{\tilde{c}}. The forward propagation equations of ELSTM (see Fig. 3 ) for state estimation are \displaystyle\begin{split}f^{(t)}&=\sigma(W_{fy}y^{(t)}+W_{fa}a^{(t-1)}+b_{f})\\ i^{(t)}&=\sigma(W_{iy}y^{(t)}+W_{ia}a^{(t-1)}+b_{i})\\ o^{(t)}&=\sigma(W_{oy}y^{(t)}+W_{oa}a^{(t-1)}+b_{o})\\ \tilde{c}^{(t)}&=\tanh(W_{\tilde{c}y}y^{(t)}+W_{\tilde{c}a}a^{(t-1)}+b_{\tilde{c}})\\ c^{(t)}&=f^{(t)}\odot c^{(t-1)}+i^{(t)}\odot\tilde{c}^{(t)}\\ a^{(t)}&=o^{(t)}\odot\tanh(c^{(t)})\\ \hat{x}^{(t)}&=W_{xa}a^{(t)}+b_{x}\end{split} (8) where f^{(t)},i^{(t)} and o^{(t)} are the forget, input and output gate’s activation vectors respectively. Also, \sigma(\cdot) is the recurrent activation function. The cell state vector and the cell input activation vector are represented by c^{(t)} and \tilde{c}^{(t)} respectively. The hidden layer vector is represented by a^{(t)}. The weight matrices and biases are represented by W_{fy},W_{fa},W_{iy},W_{ia},W_{oy},W_{oa},W_{\tilde{c}y},W_{\tilde{c}a},W_{xa},b_{f},b_{i},b_{o} and b_{\tilde{c}}. The symbol \odot represents element-wise product. We now introduce here a new structure called Jordan based long short-term memory network(JLSTM) for state estimation. The forward propagation equations of JLSTM (see Fig. 4 ) for state estimation will be: \displaystyle\begin{split}f^{(t)}&=\sigma(W_{fy}y^{(t)}+W_{fx}\hat{x}^{(t-1)}+b_{f})\\ i^{(t)}&=\sigma(W_{iy}y^{(t)}+W_{ix}\hat{x}^{(t-1)}+b_{i})\\ o^{(t)}&=\sigma(W_{oy}y^{(t)}+W_{ox}\hat{x}^{(t-1)}+b_{o})\\ \tilde{c}^{(t)}&=\tanh(W_{\tilde{c}y}y^{(t)}+W_{\tilde{c}x}\hat{x}^{(t-1)}+b_{\tilde{c}})\\ c^{(t)}&=f^{(t)}\odot c^{(t-1)}+i^{(t)}\odot\tilde{c}^{(t)}\\ a^{(t)}&=o^{(t)}\odot\tanh(c^{(t)})\\ \hat{x}^{(t)}&=W_{xa}a^{(t)}+b_{x}\end{split} (9) where f^{(t)},i^{(t)} and o^{(t)} are the forget, input and output gate’s activation vectors respectively and function similar to the ELSTM except that they are now connected to the previous output layer instead of the previous hidden layer. The function \sigma(\cdot) is the recurrent activation function. The cell state vector and the cell input activation vector are represented by c^{(t)} and \tilde{c}^{(t)} respectively. The hidden layer vector is represented by a^{(t)}. The weight matrices and biases are represented by W_{fy},W_{fx},W_{iy},W_{ix},W_{oy},W_{ox},W_{\tilde{c}y},W_{\tilde{c}x},W_{xa},b_{f},b_{i},b_{o} and b_{\tilde{c}}. The symbol \odot represents element-wise product. Figure 4: Structure of a Jordan long short term memory network(JLSTM) for state estimation. It uses output to hidden recurrent connections. The symbols y^{(t)},a^{(t)} and \hat{x}^{(t)} represent input measurement vector, hidden layer vector and estimated state vector respectively. The forget, input and output gates are represented by f^{(t)},i^{(t)} and o^{(t)}. The cell state vector and the cell input activation vector are represented by c^{(t)} and \tilde{c}^{(t)} respectively. The weights and biases are represented by W_{fy},W_{fx},W_{iy},W_{ix},W_{oy},W_{ox},W_{\tilde{c}y},W_{\tilde{c}x},W_{xa},b_{f},b_{i},b_{o} and b_{\tilde{c}}. The connections in a JLSTM resemble the connections in a JRN. In particular, the previous output \hat{x}^{(t-1)} is fed back into the network at the next time-step as can be seen in ( 9 ) and Fig. 4 . Note that simple recurrent neural networks are a special case of long short term memory networks where the gates are not involved. The introduction of f^{(t)},i^{(t)},o^{(t)},\tilde{c}^{(t)} and c^{(t)} in ( 8 ), ( 9 ), Fig. 3 and Fig. 4 is to handle long term dependencies better. Thus, the universal approximation theorems discussed in the previous section are valid. 4 Implementation of ELSTM and JLSTM The fact that the functions f and h are known in ( 1 ) was used in data generation. We considered sequences starting from time 0. Gaussian initial conditions were sampled over an interval with covariance of (0.01)\times I where I is an identity matrix of appropriate dimensions. Gaussian process and measurement noises with zero mean and known covariance were sampled for each time-step. This was done for each sequence in the data set. Measurement and process noise covariance were considered to be (0.01)\times I where the matrix I is of appropriate dimensions. The number of hidden units considered were 50 for both networks. A total of 100 sequences were generated. These were divided into three parts: training, validation and testing sequences in the ratio 80:10:10. ELSTM and JLSTM with forward propagation as in ( 8 ) and ( 9 ) respectively are implemented. The weight matrices W_{fy},W_{iy},W_{oy},W_{\tilde{c}y},W_{fa},W_{ia},W_{oa},W_{\tilde{c}a},W_{fx},W_{ix},W_{ox} and W_{\tilde{c}x} are initialised using Glorot uniform distribution while the weight matrix W_{xa} is initialised to be an orthogonal matrix using Tensorflow ’s tensorflow.keras.initializers module. The recurrent activation function \sigma(z) is chosen to be to be sigmoid(z). The backward propagation is implemented using Tensorflow ’s apply\_gradients module. The loss function at time-step t for each sequence is J_{i}^{(t)}(\phi)=\frac{1}{n}\sum_{i=1}^{n}{(x^{(t)}_{i}-\hat{x}^{(t)}_{i,\phi})}^{2}, (10) where 1\leq i\leq n and n is the number of states, x^{(t)}_{i} represents the true value of state x_{i} at time-step t and \hat{x}^{(t)}_{i,\phi} represents the estimated value of state x_{i} at time-step t by the respective network where \phi denotes hyper-parameters of the network. This is called the minimum variance cost function and was considered as we want the estimated state to be as close to the true state as possible. Adam optimization was used for training the networks. The number of hidden units and the maximum number of epochs were kept same for a particular example for both networks to make sure the comparison is accurate. Early stopping with a fixed patience value(the same for both networks) to decide the number of epochs needed is used. In each epoch, the network’s performance on validation data was used as the measure to decide whether to proceed or keep training for another epoch. We tested JLSTM for 3 different examples in Section 5 and compared the results with ELSTM and KF for the linear system and EKF for the nonlinear systems. Standard implementations of KF and EKF are used, see for example Simon ((2006)) . Testing was done with two sets of initial conditions. We first test the estimators using 10% of the data set reserved for testing. We then test using data generated from a random Gaussian initial condition with a mean different from that of the first set. We compare JLSTM, ELSTM and KF/EKF using average error at time t over all features and all test sequences \text{Error}(t)=\frac{1}{m_{test}n}\sum_{k=1}^{m_{test}}\sum_{i=1}^{n}(x_{i}^{(t)[k]}-\hat{x}_{i}^{(t)[k]})^{2}, (11) where m_{test} is the number of test sequences, n is the number of states, x_{i}^{(t)[k]} represents the true value of state x_{i} at time-step t for the k^{th} sequence and \hat{x}_{i}^{(t)[k]} represents the estimated value of state x_{i} at time-step t for the k^{th} sequence. We also used normalised mean square error (NMSE) to compare different methods. It is calculated as \text{NMSE}=\frac{1}{m_{test}nT}\sum_{k=1}^{m_{test}}\sum_{j=1}^{T}\sum_{i=1}^{n}(x_{i}^{(j)[k]}-\hat{x}_{i}^{(j)[k]})^{2}, (12) where m_{test} is the number of test sequences, T is the number of time-steps in each sequence, n is the number of states, x_{i}^{(j)[k]} represents the true value of state x_{i} at time-step j for the k^{th} sequence and \hat{x}_{i}^{(j)[k]} represents the estimated value of state x_{i} at time-step j for the k^{th} sequence. Tensorflow was used for the implementation of both networks. Codes were run on a T4 GPU. 5 Examples In this section, we compare the proposed method with existing methods for several examples. Discrete-time state-space models can arise as discretisations of a system of ordinary differential equations used for estimating state of a system equipped with measurements. Several methods exist to discretise a continuous-time system of ordinary differential equations. We used zero order hold discretisation for the linear system and an RK-45 discretisation for the nonlinear systems of ODEs. 5.1 Linear system: Connected springs We considered a zero-order hold time discretization with \Delta t=0.1s of a system of 10 connected springs \begin{split}m_{1}\ddot{x}_{1}(t)&=-k_{1}x_{1}(t)+k_{2}(x_{2}(t)-x_{1}(t))\\ &\quad-d_{1}\dot{x}_{1}(t)+d_{2}(\dot{x}_{2}(t)-\dot{x}_{1}(t))\\ m_{2}\ddot{x}_{1}(t)&=-k_{2}(x_{2}(t)-x_{1}(t))+k_{3}(x_{3}(t)-x_{2}(t))\\ &\quad-d_{2}(\dot{x}_{2}(t)-\dot{x}_{1}(t))+d_{3}(\dot{x}_{3}(t)-\dot{x}_{2}(t))\\ \vdots\\ m_{9}\ddot{x}_{9}(t)&=-k_{9}(x_{9}(t)-x_{8}(t))+k_{10}(x_{10}(t)-x_{9}(t))\\ &\quad-d_{9}(\dot{x}_{9}(t)-\dot{x}_{8}(t))+d_{10}(\dot{x}_{10}(t)-\dot{x}_{9}(t))\\ m_{10}\ddot{x}_{10}(t)&=-k_{10}(x_{10}(t)-x_{9}(t))-d_{10}(\dot{x}_{10}(t)-\dot{x}_{9}(t))\end{split} (13) where m_{i}=10,d_{i}=6 and k_{i}=800 for all i. The state vector consists of 20 discretised states, the position x_{i}(t) and velocity \dot{x}_{i}(t) for each of the 10 springs. The process noise is added to each state after discretization. The discretised measurement vector at time-step t is given by y^{(t)}=\begin{bmatrix}x_{1}^{(t)}\\ x_{2}^{(t)}\\ \vdots\\ x_{10}^{(t)}\end{bmatrix}+\nu^{(t)} where x_{i}^{(t)} is the discretised state representing position of spring i and \nu^{(t)} is the measurement noise at time-step t . We considered sequences of length 500 starting at time 0 seconds. Gaussian initial conditions for each sequence were chosen randomly from [-1,1]^{20} with a covariance of (0.01)\times I_{20} where I_{k} represents an identity matrix of order k. All noises were assumed to be Gaussian with zero mean and known covariance. Measurement and process noise covariance were considered to be (0.01)\times I where matrix I is of appropriate dimensions. A total of 100 sequences were considered with a batch size of 10. The number of hidden units considered were 50. Early stopping was implemented with a patience of 50 . The maximum number of epochs considered was 8000. Training using Adam optimization with a learning rate of 10^{-3} for ELSTM as well as JLSTM achieved a close NMSE value for both networks. Figure 5: This figure compares the performance of KF, JLSTM and ELSTM using the average errors over 10 test sequences for 50 seconds of 10 connected springs with a noisy Gaussian initial condition. While the ELSTM and JLSTM have almost equal errors at all time-steps (see Fig. 5 ), the KF has the largest error at the initial time-step but converges quickly. Figure 6: This figure compares the performance of KF, JLSTM and ELSTM using the average errors over 10 test sequences for 50 seconds of 10 connected springs with a noisy Gaussian initial condition outside the training region. For testing outside the initial interval of mean of initial condition, in this example, we used the interval {[1,1.5]}^{20}\sim\mathbb{R}^{20}. As can be seen from Fig. 6 , the ELSTM and JLSTM converge slower than the KF. This is not surprising as theory shows the KF to be the best estimator for a linear system. However, the closeness of the errors of the ELSTM and JLSTM validates the training of the networks. To keep the comparison fair, for outside the range testing, the KF was not changed. 5.2 Nonlinear system: down pendulum We considered an RK-45 discretization with \Delta t=0.01s of the down pendulum \boldsymbol{\dot{x}}(t)=\begin{bmatrix}\dot{x_{1}}(t)\\ \dot{x_{2}}(t)\end{bmatrix}=\begin{bmatrix}x_{2}(t)\\ -\frac{g}{l}\sin({x_{1}(t)})-\frac{b}{m}x_{2}(t)\end{bmatrix}, (14) where x_{1}(t) and x_{2}(t) are the states representing position and velocity of the pendulum respectively. The parameters are g=9.8m/{sec}^{2}, m=2kg, b=0.9kg/sec and l=1m. The process noise is added to each state after discretization. The discretised measurement vector at time-step t is y^{(t)}=x_{1}^{(t)}+\nu^{(t)} where x_{1}{(t)} is the discretised state representing position of the pendulum and \nu^{(t)} is the measurement noise at time-step t . We considered sequences of length 4000 starting at time 0 seconds. Gaussian initial conditions for each sequence were chosen randomly from [-2,2]\times[-2,2] with an initial condition covariance of (0.01)\times I_{2} where I_{k} represents an identity matrix of order k. All noises were assumed to be Gaussian with zero mean and known covariance. Measurement and process noise covariance were considered to be (0.01)\times I where matrix I is of appropriate dimensions. A total of 100 sequences were considered with a batch size of 20. The number of hidden units considered were 50. Early stopping was implemented with a patience of 50 . The maximum number of epochs considered was 3000. Training using Adam optimization with a learning rate of 10^{-4} for ELSTM and 10^{-3} for JLSTM achieved a close NMSE value for both networks. Figure 7: This figure compares the performance of EKF, JLSTM and ELSTM using the normalised mean squared errors over 10 test sequences for 40 seconds of down pendulum with a noisy Gaussian initial condition. While the ELSTM and JLSTM have almost equal errors at all time-steps(see Fig. 7 ), the EKF has the largest error at the initial time-step and converges later than the other two. Figure 8: This figure compares the performance of EKF, JLSTM and ELSTM using the normalised mean squared errors over 10 test sequences for 40 seconds of down pendulum with a noisy Gaussian initial condition outside the training region. For testing outside the initial interval of mean of initial condition, in this example, we used the interval {[2,2.5]}^{2}\sim\mathbb{R}^{2}. As can be seen from Fig. 8 , the ELSTM and JLSTM perform better than the EKF especially at the initial time-steps. To keep the comparison fair, for outside the range testing, the EKF was not changed. 5.3 Nonlinear system: reversed Van der Pol oscillator We considered an RK-45 discretization with \Delta t=0.1s of the reversed Van der Pol oscillator \boldsymbol{\dot{x}}(t)=\begin{bmatrix}\dot{x_{1}}(t)\\ \dot{x_{2}}(t)\end{bmatrix}=\begin{bmatrix}-x_{2}(t)\\ x_{1}(t)+(({x_{1}}(t))^{2}-1)x_{2}(t)\end{bmatrix} (15) where x_{1}(t) and x_{2}(t) is the position and velocity of the oscillator. The discretised measurement vector at time-step t is y^{(t)}=x_{1}^{(t)}+\nu^{(t)} where \nu^{(t)} is the measurement noise at time-step t . For this example, we have considered sequences of length 300 starting from time 0. The Gaussian initial condition was sampled from [-1,1]\times[-1,1] with covariance (0.01)\times I_{2} where I_{k} represents an identity matrix of order k for each sequence. All noises were assumed to be Gaussian with zero mean and known covariance. Measurement and process noise covariance were again (0.01)\times I where matrix I is of appropriate dimensions. A total of 100 sequences were considered with a batch size of 20 . The number of hidden units considered were 50. Early stopping was implemented with a patience of 15 . The maximum number of epochs was set to be 3000. Training using Adam optimization with a learning rate of 10^{-3} for ELSTM and 10^{-2} for JLSTM achieves a close NMSE for both networks. Figure 9: This figure compares the performance of EKF, JLSTM and ELSTM using the average errors over 10 test sequences for 30 seconds of reversed Van der Pol oscillator with a noisy Gaussian initial condition. While the ELSTM and JLSTM have almost equal errors at all time-steps(see Fig. 9 ), the EKF has the largest error at the initial time-step and converges later than the other two estimators. This is similar to the case of the down pendulum. Figure 10: This figure compares the performance of EKF, JLSTM and ELSTM using the average errors over 10 test sequences for the first 30 seconds of reversed Van der Pol oscillator with a noisy Gaussian initial condition outside the training region. For testing outside the initial interval of mean of initial condition, in this example, we used the interval {[1,1.5]}^{2}\sim\mathbb{R}^{2}. As can be seen from Fig. 10 , the ELSTM and JLSTM perform better than the EKF especially at the initial time-steps. Again, for outside the range testing, the EKF was not changed. 6 Results and conclusions We have compared JLSTM, ELSTM and KF for a 100 dimensional linear system and the JLSTM, ELSTM and EKF for two nonlinear systems of order 2, the down pendulum and the reversed Van der Pol oscillator. Table 1: Normalised mean square error(NMSE) for E(KF), JLSTM and ELSTM State space Estimator system E(KF) JLSTM ELSTM Connected springs 0.0174 0.0162 0.0153 Down pendulum 0.0695 0.0542 0.0461 r. Van der Pol 0.0635 0.0485 0.0441 The results in Table 1 indicate that the NMSE value corresponding to JLSTM and ELSTM is close to the KF’s NMSE value for the linear system. For both nonlinear systems, both JLSTM and ELSTM have a smaller NMSE than the EKF. This is likely because there is less linearization error. Thus, the presence of a nonlinear activation function appears advantageous. Table 2: Training time(in seconds) for JLSTM and ELSTM State space Estimator system JLSTM ELSTM Connected springs 15983 16298 Down pendulum 95644 99473 r. Van der Pol 619 3389 Because the learning rate was chosen so that the error values for ELSTM and JLSTM became comparable for all 3 examples, a comparison of their training times is relevant. The time taken to train an ELSTM was considerably larger than the time taken to train a JLSTM (Table 2 ). This suggests that having direct connections with state estimates at the previous time-step helps to minimise the loss function faster. Table 3: Testing time(in seconds) for E(KF), JLSTM and ELSTM State space Estimator system E(KF) JLSTM ELSTM Connected springs 0.8 0.3 0.3 Down pendulum 38.2 2.7 2.7 r. Van der Pol 3.2 0.2 0.2 While the time taken to train both the JLSTM and ELSTM is large as can be seen in Table 2 , the testing time only involves simple operations and is quite fast. We show their comparison for time taken to test 10 sequences for each example in Table 3 . Both the LSTM architectures are faster than the KF and the EKF in the respective cases. The execution time for both the ELSTM and JLSTM is almost the same. Table 4: Normalised mean square error(NMSE) for E(KF), JLSTM and ELSTM for initial conditions outside the training region State space Estimator system E(KF) JLSTM ELSTM Connected springs 0.0179 0.0567 0.0459 Down pendulum 0.0850 0.0687 0.0700 r. Van der Pol 0.0927 0.0586 0.0497 When tested on data generated using initial conditions outside the training range, we observe from Table 4 that the NMSE for JLSTM and ELSTM is much better than that for EKF for non-linear examples but more than the NMSE for KF for the linear example. It does appear from this that the networks are learning the model better for the nonlinear examples. We thus conclude that both JLSTM and ELSTM provide smaller errors than an EKF for nonlinear systems. Using a JLSTM instead of an ELSTM appears preferable because the JLSTM network has considerably smaller training time to achieve the same error. 7 Future Work Given the success of JLSTM on low-order nonlinear systems, extending this approach to high-order nonlinear systems is of value. A framework to speed up back-propagation which will in turn speed up the training process will be investigated. One advantage of the Jordan structure is that it mimics the structure of a dynamical system. This facilitates obtaining stability results. Some preliminary results in this direction are reported in Kaur et al. ((2024)) for a simpler Jordan architecture. An important goal is to establish stability and convergence properties of the JLSTM.