## 2 Formulation for Modeling  
### Conventional Kalman Filter  
The Kalman filter is an algorithm that estimates the state based on the statistical properties with the measurement while using sensors. The sensor contains sensor errors and the modeled governing equation does not perfectly match the system. Kalman filtering is applied to the system model of Equations (1) and (2) in the state space. It assumes that there exists a model error \(w\) in the state \(x\) and a sensor error \(v\) in the measurement \(z\) during the transition to the next time step.  
\[x_{k+1}=\phi_{k}x_{k}+w_{k} \tag{1}\]  
\[z_{k}=H_{k}x_{k}+v_{k} \tag{2}\]  
Figure 2: NOAA forecast snapshot for North West Atlantic [10].  
where  
\(x_{k}=\) process state vector  
\(\phi_{k}=\) state transition matrix  
\(w_{k}=\) model error vector  
\(z_{k}=\) measurement vector  
\(H_{k}=\) output matrix  
\(v_{k}=\) sensor error vector  
The covariance for each of the two errors is given by;  
\[Q=E[w_{k}w_{k}^{T}] \tag{3}\]  
\[R=E[v_{k}v_{k}^{T}] \tag{4}\]  
The Kalman filter keeps reducing the prediction error of the state x through the recursive calculating process. The process is made up of four steps, as described in Figure 3. The superscript '-' means a predicted value for the next time step. Otherwise, it means a calculated (or estimated) value from measurement at the current step.  
where,  
\(x_{\overline{k}}=\) predicted state vector  
\(x_{k}=\) estimated state vector  
\(P_{\overline{k}}=\) predicted error covariance matrix  
\(P_{k}=\) estimated error covariance matrix  
\(K_{k}=\) Kalman gain  
\(Q_{k}=\) model error covariance matrix  
\(R_{k}=\) measurement (sensor) error covariance matrix  
The initial state \(x_{\overline{1}}\) is to be estimated and the initial error covariance, \(P_{\overline{1}}\) should be determined by the designer. If initial P (\(P_{\overline{1}}\)) is too small, then it will result in small Kalman gain, K by Equation (5) in the beginning of calculation. A small K means giving more weight to sensor measurement than prediction. Subsequently, at the beginning of the filtering, the measurement is relatively neglected and the prediction is overly counted. In other words, the \(P_{\overline{1}}\) determines the initial convergence rate of the state x. Small P delays the initial convergence rate. Therefore, when the designer does not have prior knowledge of x, reasonably large initial error covariance, \(P_{\overline{1}}\) should be set [13].  
\(R\) is measurement error covariance that is generally determined from the error performance of the given sensor. An adaptive \(R\) may be applied when the sensor error is not statistically constant in the  
Figure 3: Kalman filter loop [12].  
actual filtering process. \(H\) is the matrix that defines the relationship between state, \(x\) and measurement, \(z\). In the estimation step, optimum \(x\) is calculated by using the weight factor, \(K\) in the Equation (6).  
\[K_{k}=P_{\overline{k}}H_{k}^{T}(H_{k}P_{\overline{k}}H_{k}^{T}+R_{k})^{-1} \tag{5}\]  
\[\hat{x}_{k}=\hat{x}_{\overline{k}}+K_{k}(z_{k}-H_{k}\hat{x}_{\overline{k}}) \tag{6}\]  
\[P_{k}=(I-K_{k}H_{k})P_{\overline{k}} \tag{7}\]  
In the prediction step, \(P\) is increased by model error covariance, \(Q\). \(Q\) is a design parameter that can be adjusted by the designer. This process is repeated:  
\[\hat{x}_{\overline{k}+1}=\phi_{k}\hat{x}_{k} \tag{8}\]  
\[P_{\overline{k}+1}=\phi_{k}P_{k}\phi_{k}^{T}+Q_{k} \tag{9}\]  
The conventional Kalman filter is not directly suitable for practical applications. Therefore, the research that is related to using Kalman filter mainly focuses on the design of an adaptive type to fit a specific model, including the optimization of the design factors, \(R\) and \(Q\). The optimized \(Q\) and \(R\) lead to the improvement of estimation performance of the filter. In the following, we explain how the algorithm can be utilized for the real-time inverse estimation of ocean wave spectra and elevation from vessel-motion sensors.