---
title: Reference Recursive Recipe (RRR) for EKF Tuning
url: https://www.emergentmind.com/topics/reference-recursive-recipe-rrr
type: topic
---

# Reference Recursive Recipe (RRR) for EKF Tuning

The Reference Recursive Recipe (RRR) is a systematic, fully recursive framework for adaptive tuning of the initial state, initial covariance, process-noise covariance, measurement-noise covariance, and fixed parameters within the Extended Kalman Filter (EKF). Developed by Ananthasayanam et al., RRR utilizes repeated forward/backward passes through available data to iteratively adjust all EKF statistics by balancing generalized cost functions that monitor the internal statistical consistency of the filter. This approach aims to achieve a “statistical equilibrium” where the cost functions stabilize at theoretically expected values, providing reliable, low-bias, and uncertainty-quantified parameter and state estimates in both simulated and real-world domains, including aerospace system identification [1505.07201][1505.07208].

## 1. EKF Tuning Problem and RRR Formulation

The fundamental challenge in Kalman filtering is tuning the statistics $\{\mathbf{X}_0, \mathbf{P}_0, \Theta, R, Q\}$—the initial state-mean and covariance, process and measurement noise covariances, and unknown model parameters—based solely on observed data without recourse to extensive off-line optimization. For a nonlinear discrete-time system,
\[
\begin{aligned}
X_k &= f(X_{k-1}, \Theta) + w_k,\;\quad w_k \sim \mathcal{N}(0, Q), \\
Z_k &= h(X_k, \Theta) + v_k,\;\quad v_k \sim \mathcal{N}(0, R), \qquad k=1,\dots,N,
\end{aligned}
\]
the EKF augments $X_k \in \mathbb{R}^{n+p}$ to include both system states $x_k$ and parameters $\Theta$ treated as pseudo-states. Selection of the aforementioned statistics markedly impacts filter convergence, bias, Cramér–Rao bounds (CRB), and the risk of divergence [1505.07201].

The RRR addresses this problem via iterative, recipe-like passes: each involves a forward EKF run, Rauch–Tung–Striebel (RTS) smoothing, and cost-based updates to all statistics. Convergence is declared when all cost functions approach theoretically predicted values.

## 2. Algorithmic Structure of RRR

The RRR operates as an outer loop over iterations $i=1,2,\ldots$, with each iteration comprising:

1. **Forward EKF Pass:** Utilizing the current statistics, advance through $k=1, \ldots, N$, producing prior, posterior, and innovation estimates.
2. **Backward RTS Smoothing:** Apply the RTS algorithm over $k=N-1,\ldots,0$ to obtain smoothed state and covariance estimates.
3. **Generalized Cost Function Computation:** Evaluate eight cost functionals ($J_0$–$J_8$) reflecting filter consistency in both measurement and state spaces.
4. **Statistical Updates:**
   - **Initial Covariance Scaling:** Set $\mathbf{P}_0^\text{new} = N P_{N|N}$, and optionally trim to parameter block-diagonal.
   - **Parameter Update:** Extract current $\Theta$ from the final state or solve a normal equation derived from a negative log-likelihood cost.
   - **Noise Covariance Updates:** Utilize reference-based EM-type statistics on smoothed residuals to update $Q$ and $R$.
5. **Convergence Test:** If all $J$-costs are within a prescribed tolerance of $m$ (measurement dimension) or $n$ (state dimension), halt; else, iterate [1505.07201][1505.07208].

## 3. Generalized Cost Functions and Their Roles

The RRR uniquely employs eight cost components reflecting the agreement of the EKF with the data and its own underlying assumptions:
\[
\begin{aligned}
J_0 &= \tfrac12(\mathbf{X}_0 - X_{0|N})^T \mathbf{P}_0^{-1} (\mathbf{X}_0 - X_{0|N}), \\
J_1 &= \tfrac{1}{N} \sum (Z_k - h(X_{k|k-1}))^T S_{1,k}^{-1} (Z_k - h(X_{k|k-1})), \\
J_2 &= \tfrac{1}{N} \sum (Z_k - h(X_{k|k}))^T S_{2,k}^{-1} (Z_k - h(X_{k|k})), \\
J_3 &= \tfrac{1}{N} \sum (Z_k - h(X_{k|N}))^T S_{3,k}^{-1} (Z_k - h(X_{k|N})), \\
J_4 &= \tfrac{1}{N} \sum \|Z_k - h(X^d_{k|N})\|^2, \\
J_5 &= \tfrac{1}{N} \sum \left[(Z_k - h(X_{k|k-1}))^T S_{1,k}^{-1} (Z_k - h(X_{k|k-1})) + \ln\det S_{1,k}\right], \\
J_6,J_7,J_8 &= \text{State-equation residuals and their corresponding normalized quadratic forms.}
\end{aligned}
\]

For correct tuning,
\[
J_1 \approx J_2 \approx J_3 \approx m,\quad J_6 \approx J_7 \approx J_8 \approx n,
\]
with $m$ the observation dimension and $n$ the number of state variables. These costs serve as diagnostic indicators: their stabilization signals statistical equilibrium and proper filter tuning, while oscillation or deviation indicates parameter or covariance mismatch or unobservable system structure [1505.07201][1505.07208].

## 4. Covariance Update Formulas and Iterative Heuristics

A core feature of RRR is the iterative update of $Q$ and $R$ based on EM-type smoothed-residual statistics:
- **Measurement-Noise Covariance:**
  \[
  R = \tfrac{1}{N} \sum_{k=1}^N \left[ (Z_k - h(X_{k|N}))(Z_k - h(X_{k|N}))^T + H_{k|N} P_{k|N} H_{k|N}^T \right ]
  \]
- **Process-Noise Covariance:**
  \[
  Q = \tfrac{1}{N}\sum_{k=1}^N \Bigl[w^{(1)}_{k|N}(w^{(1)}_{k|N})^T  +P_{k|N}+F_{k-1|N}P_{k-1|N}F_{k-1|N}^T -P_{k,k-1|N}F_{k-1|N}^T -F_{k-1|N}P_{k,k-1|N}^T\Bigr]
  \]
where $w^{(1)}_{k|N}=X_{k|N}-f(X_{k-1|N})$. The initial covariance $\mathbf{P}_0$ is heuristically reset via scaling: $\mathbf{P}_0 \leftarrow N P_{N|N}$, countering the shrinkage of posterior covariance to zero through repeated smoothing [1505.07201].

When sensor scale or bias is unknown, the augmented state approach is directly embedded within the RRR loop, and all steps above apply unaltered [1505.07208].

## 5. Simulation and Real-World Evaluation

RRR’s performance is demonstrated on both simulated and real datasets:

- **Spring–Mass–Damper Simulation:** With weak nonlinear spring, RRR achieves parameter estimates within $0.1\%$ of Newton–Raphson solutions in 2–3 iterations (noise-free) and approaches theoretical CRBs within 5–6 iterations. In the presence of process noise ($Q>0$), typical convergence occurs in 20–30 iterations with $(R,Q)$ estimated to within $5\%$ of ground truth, outperforming classical Myers–Tapley (MT) and Mohamed–Schwarz (MS) covariance-matching approaches [1505.07201].
- **Flight Data (Airplane Test Cases):** Three real-data experiments with high-dimensional states, measurements, and time-varying or colored noise illustrate that RRR yields lower bias, CRBs, and correlation between estimated parameters than MT/MS. Importantly, RRR’s use of smoothed-residual cost functions allows the discrimination of “definitive” (well-tuned) from “deceptive” fits (proper cost values not obtained), a critical consideration in system identification [1505.07208].

Quantitative comparison reveals that RRR consistently produces smaller absolute percent errors in parameter estimates and better uncertainty quantification via CRB than MT or MS. The convergence of all $J$-costs to nominal values provides a built-in termination criterion and diagnostic for result reliability.

## 6. Practical Guidance, Limitations, and Extensions

The RRR is applicable in both batch (offline) and limited-window (near real-time) scenarios, although its requirement for multiple forward/backward passes through the entire dataset naturally favors offline or batch usage. For real-time adaptation, a moving-window approach with several recursions can be adopted [1505.07201].

Recommendations and caveats explicitly stated:
- Always use $Q>0$ in practical/nearly-realistic applications due to the ubiquity of colored, non-Gaussian, or time-varying noise.
- Use smoothed-residual EM statistics for $R$ update and either smoothed-state or DSDT (difference between stochastic and zero-noise dynamics) statistics for $Q$ update.
- Innovations-only or filtered-residual-only updates are unstable when both $Q$ and $R$ are unknown.
- The scale-up of $\mathbf{P}_0$ is mandatory to prevent covariance shrinkage.
- Convergence is robust when the EKF is a reasonable local approximation and initial statistics are not badly chosen. For pronounced nonlinearity or multimodal posteriors, more sophisticated filtering or global optimization may be required.
- Large off-diagonal values in the $\Theta$-correlation matrix highlight parameter unobservability or ill-conditioning [1505.07208].

The RRR remains a heuristic approach, without a proof of global optimality, but is empirically validated against both synthetic and real datasets and offers a theoretically motivated, statistically consistent solution to EKF statistics tuning problems.

Source: https://www.emergentmind.com/topics/reference-recursive-recipe-rrr