control//state estimation//Kalman filter//filter tuning
Filter tuning is the choice of a Kalman filter's noise covariances, the process noise \(\cd{Q}\) and the measurement noise \(\cc{R}\), together with its starting uncertainty \(\ca{P_0}\), and it decides how quickly the filter believes a change and how sure it claims to be. The model in violet, what the sensor brings in copper, the filter's uncertainty in green. Both numbers are opinions the designer has to sign. \(\cc{R}\), the distrust in the sensor, rests on a test: leave the sensor still for a few minutes and compute the variance of its noise (measurement noise). \(\cd{Q}\), the distrust in the model, says how much acceleration or wind the model ignores, and it is almost never measured; it is a design decision (process noise).
Filter tuning is the choice of a Kalman filter's noise covariances, the process noise Q\cd{Q}Q and the measurement noise R\cc{R}R, together with its starting uncertainty P0\ca{P_0}P0, and it decides how quickly the filter believes a change and how sure it claims to be. The model in violet, what the sensor brings in copper, the filter's uncertainty in green. Both numbers are opinions the designer has to sign. R\cc{R}R, the distrust in the sensor, rests on a test: leave the sensor still for a few minutes and compute the variance of its noise (measurement noise). Q\cd{Q}Q, the distrust in the model, says how much acceleration or wind the model ignores, and it is almost never measured; it is a design decision (process noise).
They are not independent knobs. Multiply Q\cd{Q}Q, R\cc{R}R and P0\ca{P_0}P0 by the same factor and the gain KKK does not change, so every estimate is identical, while P\ca{P}P is multiplied by that factor.
The ratio of Q\cd{Q}Q to R\cc{R}R shapes the estimate; their size shapes the claim. The ratio decides how fast the filter believes a change, the absolute size how sure it says it is. Two filters can draw exactly the same line with bands ten times apart, and only one of them is honest: a filter can estimate well and lie about its uncertainty.
What mistuning looks like is easiest to see live, with the filter's R\cc{R}R and Q\cd{Q}Q on sliders apart from the sensor's real noise.
RMS error, filter0.31 m RMS error, sensor1.01 m gain K0.11 ±σ it believes0.33 m A cart followed by a constant-velocity Kalman filter from a sensor with 1.0 m of real noise; the filter assumes Q = 0.4 and R = 1, which matches the sensor's variance. After 40 s the filter's error, 0.31 m, is below the sensor's 1.01 m, the gain K has settled at 0.11 and the filter believes it is within ±0.33 m.
Set the filter's R to 100 and the estimate turns smooth and late; set it to 0.01 and it copies the noise. Raise the real sensor noise to 3 without touching R: the band the filter believes stays put while the real error grows. Then lower Q to 0.001, switch on the manoeuvres and watch the truth leave a confident band.
The procedure runs in an order. Measure R\cc{R}R on the bench; give Q\cd{Q}Q its shape from the physics (a white acceleration spreads into position and velocity through Δt\Delta tΔt, as in the state-space model) and a size slightly larger than the physics suggests; start with a large P0\ca{P_0}P0; then replay real logs and adjust until the innovations are the size the filter predicts (NIS).
Two settings put a filter to sleep, and they are symmetric. Q=0\cd{Q}=0Q=0 because the model looks perfect makes P\ca{P}P and KKK shrink to zero, and the filter stops listening for good; a tiny P0\ca{P_0}P0 for a state nobody knows makes it ignore the readings it most needs at the start (initial covariance). Some Q\cd{Q}Q always stays, as the humility term.
The innovations alone often cannot say whether Q\cd{Q}Q or R\cc{R}R is wrong, since a larger surprise fits a worse model and a worse sensor alike; designs fix one from the bench and tune the other, or let a filter estimate one while running (adaptive Kalman filter).
The same two letters, with the same ratio logic, set an optimal controller, where they mean prices instead of doubts (LQR).