KomuraSoft LLC
Chapter 4

Kalman gain — how much to trust prediction vs. observation

The Kalman gain K decides how much to trust the prediction versus the observation. Build a feel for how the ratio of Q to R governs the filter's behavior.

The star of this chapter is the Kalman gain K. In the scalar version the formula is extremely simple, which makes it easier to understand intuitively what is happening.

The formula for K

K = P⁻ / (P⁻ + R)

The larger P⁻ is, the more "the prediction is shaky." The larger R is, the more "the observation is shaky." The ratio between numerator and denominator alone decides how much to trust each side.

This form arises because, when the estimate is mixed linearly as x̂ = (1 − K)x̂⁻ + K z, the K that minimizes the post-update variance P = (1 − K)² P⁻ + K² R works out to K = P⁻ / (P⁻ + R). In other words, the Kalman gain is the weight that, when prediction and observation are mixed linearly, makes the post-mix uncertainty as small as possible. Substituting the optimal K back in simplifies the variance to the form P = (1 − K)P⁻ used in the body. This course takes the derivation as given; it is enough to remember the form: the predicted uncertainty in the numerator, and the sum of the predicted and observation uncertainties in the denominator.

Check 1 — Compute K directly

Using K = P⁻ / (P⁻ + R), think about how much to trust each side from the numerator and denominator.

Q1. With predicted variance P⁻ = 9 and observation noise R = 1, what is the Kalman gain K?

Q2. With predicted variance P⁻ = 1 and observation noise R = 9, what is the Kalman gain K?

Q affects K through P⁻

Q does not appear directly in K, but it works through P⁻ = P + Q. The more you distrust the model, the bigger the prediction variance becomes, and the filter tends to move toward the observation.

Check 2 — Q affects K through P⁻

With P = 2, Q = 3, and R = 5, first compute P⁻, then K.

Q1. What is the predicted variance P⁻ = P + Q?

Q2. Continuing, what is the Kalman gain K = P⁻ / (P⁻ + R)?

Q3. Holding R fixed and increasing Q, what happens to the Kalman gain K in general?

Always follow through to the post-update variance

After computing K, always follow through not only to the new estimate but also to the new variance. That is what lets you start the next prediction step.

Check 3 — From K to the post-update variance

Once K is known, always follow through not only to the new estimate but also to the new variance P = (1 − K)P⁻.

Q1. With predicted variance P⁻ = 5 and observation noise R = 5, what is the Kalman gain K?

Q2. Continuing, what is the updated variance P = (1 − K)P⁻?

Takeaway intuition for this chapter

The Kalman gain bundles "how much to trust the prediction versus the observation" into a single number. Just by changing the ratio of Q to R, you decide the behavioral characteristics of the filter.