# Recursive Optimal Finite Impulse Response Filter and Its Application to Adaptive Estimation
## 2 Recursive Optimal FIR Filter and Adaptive FIR Filter
### Adaptive FIR Filter with Sequential Noise Statistics Estimation  
Since the structure of the proposed ROFIR filter is exactly same as the Kalman filter on the horizon, many useful techniques of Kalman filtering can be applied to the the proposed ROFIR filter for improving the performance of FIR filter. In this section, we propose an AFIR filter as an application of the proposed ROFIR filter. By applying modified sequential noise statistics esitmation method introduced in Figure 2 to ROFIR filter, an AFIR filter can be obtained as follows. The mean and covariance of the measurement noise can be obtained on the horizon \([k-N\,k]\) as  
\[\hat{r}_{k-N+i|k} = \hat{r}_{k-N+i-1|k}+\frac{1}{N}(r_{k-N+i|k}-r_{k-N+i|k-1}), \tag{58}\]  
\[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\] \[\times(r_{k-N+i|k-\hat{r}_{k-N+i|k}})^{T}-(r_{k-N+i|k-1}-\hat{r}_{ k-N+i|k})\] \[\times(r_{k-N+i|k-1}-\hat{r}_{k-N+i|k})^{T}+\frac{1}{N}(r_{k-N+i|k} -r_{k-N+i|k-1})\] \[\times(r_{k-N+i|k}-r_{k-N+i|k-1})^{T}-\frac{N-1}{N}(\gamma_{k-N+i| k}-\gamma_{k-N+i|k-1})\Big{)},\]  
for \(1\leq i\leq N-1\). For \(i=N\), \(\hat{r}_{k|k}\) and \(\hat{R}_{k|k}\) can be obtained by replacing \(r_{k-N+i|k-1}\) and \(\gamma_{k-N+i|k-1}\) in (58) and (59) with \(r_{k-N|k-1}\) and \(\gamma_{k-N|k-1}\), respectively. Secondly, for the process noise statistics, define the approximation of state noise sample on the horizon \([k-N-1\,k-1]\) as  
\[q_{k-N+i|k-1} = \hat{x}_{k-N+i|k-1}-A_{k-N+i}\hat{x}_{k-N+i-1|k-1}, \tag{60}\]  
where \(q_{k-N+i|k-1}\) is defined as the \(i\)-th process noise sample at time \(k\). In the same way as the process of measurement noise statistics, an unbiased estimate for horizon initial sampled mean \(\hat{q}_{k-N|k}\) at time \(k\) can be represented as  
\[\hat{q}_{k-N|k} = \frac{1}{N}\sum_{i=1}^{N}q_{k-i+1|k-1}, \tag{61}\]  
where \(q_{k|k-1}=\hat{x}_{k|k-1}-A_{k}\hat{x}_{k-1|k-1}\). Then, the unbiased estimation of the initial process noise covariance \(\hat{Q}_{k-N|k}\) can be represented as  
\[\hat{Q}_{k-N|k} = \frac{1}{N-1}\sum_{i=1}^{N}\Big{(}(q_{k-i|k}-\hat{q}_{k-N|k})(q_{ k-i|k}-\hat{q}_{k-N|k})^{T} \tag{62}\] \[- \frac{N-1}{N}\Delta_{k-N+i|k-1}\Big{)},\]  
where \(\Delta_{k-i|k-1}=A_{k-i}P_{k-i-1|k-1}A_{k-i}^{T}-P_{k-i|k-1}\). Then, the mean and covariance of the process noise on the horizon \([k-N\,k]\) can be calculated sequentially as  
\[\hat{q}_{k-N+i|k} = \hat{q}_{k-N+i-1|k}+\frac{1}{N}(q_{k-N+i|k-1}-q_{k-N+i|k}), \tag{63}\]  
\[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]0 \[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]1 \[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]2 \[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]3  
With the above sequential noise statistics esitmates, the AFIR filter can be obtained on the horizon \([k-N\,k]\) as:  
\[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]4 \[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]5  
where the filter gain and prediction covariance matrix are obtained as  
\[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]6\[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]7 \[\hat{R}_{k-N+i|k} = \hat{R}_{k-N+i-1|k}+\frac{1}{N-1}\Big{(}(r_{k-N+i|k}-\hat{r}_{k-N +i|k})\]8  
where the optimal unbiased estimate of the horizon initial state \(\hat{x}_{k-N|k}\) and the state covariance \(P_{k-N|k}\) are obtained by (25) and (26) with estimated noise statistics \(\hat{R}_{|k-1}\) and \(\hat{Q}_{|k-1}\) in (59) and (64), respectively.