The Extended Kalman Filter: An Interactive Tutorial for Non-Experts

Part 4: State Estimation

Here again (ignoring process noise) are our two equations describing the state of a system we are observing: \[ \begin{aligned} x_k & = a x_{k-1} + w_k\\ z_k & = x_k + v_k \\ \end{aligned} \] Since our goal is to obtain the states $x$ from the observations $z$, we could rewrite the second equation as: \[ \begin{aligned} x_k & = z_k - v_k \end{aligned} \] The problem of course is that we don't know the current noise $v_k$: it is by definition unpredictable. Fortunately, Kalman had the insight that we can estimate the state by taking into account both the current observation and the previous estimated state. Engineers use a little caret or “hat” ^ over a variable to show that it is estimated: so $\hat{x}_k$ is the estimate of the current state. Then we can express the estimate as a tradeoff between the previous estimate and the current observation: \[ \begin{aligned} \hat{x}_k & = \hat{x}_{k-1} + g_k(z_k - \hat{x}_{k-1}) \end{aligned} \] where $g$ is a “gain” term expressing the tradeoff.[5] I've highlighted this equation in red because it is one that we will use directly in implementing our Kalman filter.

Now, this all looks rather complicated, but think of what happens for two extreme values of the gain $g_k$. For $g_k = 0$, we get \[ \begin{aligned} \hat{x}_k & = \hat{x}_{k-1} + 0(z_k - \hat{x}_{k-1}) = \hat{x}_{k-1} \end{aligned} \] In other words, when the gain is zero, observation has no effect, and we get the original equation relating the current state to the previous. For $g_k = 1$ we get \[ \begin{aligned} \hat{x}_k & = \hat{x}_{k-1} + 1(z_k - \hat{x}_{k-1}) = \hat{x}_{k-1} + z_k - \hat{x}_{k-1} = z_k \end{aligned} \] In other words, when the gain is one, the previous state doesn't matter, and we get the current state estimation entirely from the current observation.

Of course, the actual gain value will likely fall somewhere between these two extremes. Try moving the slider below to see the effect of gain on current state estimation:

$x_{k-1} = 110$       $z_k = 105$               $g_k =$ 0.5 $\hat{x}_k = $7.5

Previous:       Next:

[5] The variable $k$ is usually used for gain, because it is known as the Kalman gain. With due respect to Rudolf Kalman, I find it confusing to use the same letter for a variable and a subscript, so I have opted for the letter $g$ instead.