# Reformulating the State Observer

Developing Models for Kalman Filters

Depending on your ultimate goal, you don't necessarily need to go beyond previous discussions. You might not need the state transition model at all — you might be able to discard it and apply the state observer alone for purposes of your application. However, if you are going to take things further, and certainly to advance all the way to Kalman Filters, there are some changes required.

Both the state transition equations and the observer equations attempt to model what is happening in the system in terms of state variables. There is a distinct smell of redundancy. Maybe a more compact implementation is possible? Can the two next-state estimates be consolidated in some manner?

## Consolidated equations

Assume that the initial state estimates are equal (equally good or equally bad). The `x` vectors represent the state of the system as projected by the state transition equations, while the `z` vectors represent the best state estimates after adjustments by the observer equations.

${x}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}=\phantom{\rule{1.0em}{0ex}}{z}^{\left(0\right)}$

Suppose the goal is to deploy the state equation system and also an observer equation system for it. The state transition model equations are:

${x}^{\left(1\right)}\phantom{\rule{1.0em}{0ex}}=\phantom{\rule{1.0em}{0ex}}A{x}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}B{u}^{\left(0\right)}$

The state observer equations are:

${z}^{\left(1\right)}\phantom{\rule{1.0em}{0ex}}=\phantom{\rule{1.0em}{0ex}}E{z}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}B{u}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}F{y}^{\left(0\right)}$

The superscripts denote the advancement of time; each equation system projects an estimate that applies to the next instant of discrete time.

Recall from the design of the state observer that its transition matrix `E` was defined in terms of matrices from the original state system, augmented with an additional `F` matrix of observer gains (to be selected by the designer). Making this substitution:

${z}^{\left(1\right)}\phantom{\rule{1.0em}{0ex}}=\phantom{\rule{1.0em}{0ex}}\left(A-FC\right){z}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}B{u}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}F{y}^{\left(0\right)}$

Reorganizing the terms:

${z}^{\left(1\right)}\phantom{\rule{1.0em}{0ex}}=\phantom{\rule{1.0em}{0ex}}A{z}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}B{u}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}-\phantom{\rule{1.0em}{0ex}}FC{z}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}F{y}^{\left(0\right)}$

Recalling that the C matrix from the model observation equations determines the model output values given the value of the states, the product ` yp = C z` is an initial prediction of the system output values, based on state observer results.

${{y}_{p}}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}=\phantom{\rule{1.0em}{0ex}}C{z}^{\left(0\right)}$

Applying this new notation, the observer equations now assume the form of the original state transition equations augmented with an additional observer correction term, in the form of the output tracking error times an observer gain.

${z}^{\left(1\right)}\phantom{\rule{1.0em}{0ex}}=\phantom{\rule{1.0em}{0ex}}A{z}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}B{u}^{\left(0\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}F\left({y}^{\left(0\right)}-{{y}_{p}}^{\left(0\right)}\right)$

## Consolidating processing

Since the first two terms of the reformulated observer equations have exactly the same form as the state transition equations, an implementation can apply the same equation system twice, once to calculate the state transition model, and then to calculate part of the state observer update. But this too can be simplified.

Recall that in past installments, when we reached the point that we had two state estimates, one from the state transition equations and one from the state observer equations, we were in a bind. To resolve the conflict, we chose a mix of the state transition estimate and the state observer estimate to obtain a combined next state estimate to be applied.

Having done this, we found that the state estimates from the two systems tracked very closely. So closely in fact, that the exact nature of the mix doesn't make much difference. So, why not go all the way and completely replace the original state transition estimate with the state observer estimate for the next cycle of calculations?

Once we make that substitution, the assumption that the model's state estimates and the observer's estimates are equal prior to the first step becomes an invariant for every step. Since each cycle starts with model estimates and observer estimates being the same, we do not need to maintain separate copies, and the same matrix calculations can be used for both purposes. Then the incremental observer adjustments can be calculated as follows.

${z}^{\left(1\right)}\phantom{\rule{1.0em}{0ex}}=\phantom{\rule{1.0em}{0ex}}{x}^{\left(1\right)}\phantom{\rule{1.0em}{0ex}}+\phantom{\rule{1.0em}{0ex}}F\left({y}^{\left(0\right)}-{{y}_{p}}^{\left(0\right)}\right)$ ${x}^{\left(1\right)}\phantom{\rule{1.0em}{0ex}}←\phantom{\rule{1.0em}{0ex}}{z}^{\left(1\right)}$

## What does it mean?

In the context of Kalman Filters, this is the Kalman update.

If there is anything in this relatively short installment that is not completely clear, it is worth starting over from the top and going through it all again. Once you understand how this consolidated observer processing works, you understand how Kalman Filters work.

You saw in the previous installments how to design an observer manually. You saw that the process worked well enough that for some purposes you might need only a simplified state transition model to produce highly useful tracking results. You saw in this installment how a two-equation state transition and state observer formulation can be reduced to one state update formula with a two step evaluation process. How much more simplification is possible? Next time, we will explore whether there is any benefit from reducing the observer almost to nothing.

 In the language of Kalman filtering, this difference between the model and reality is termed innovations. Though it seems strange to call random aberrations driven by pure noise "innovation," I suppose it is consistent with popular usage by companies such as Microsoft.

 When these observer gains are selected in a very special way, they are called Kalman gains.

 The Kalman folks show no remorse about keeping the orthodoxy pure with a little Latin grammar. They call the initial state projections the a priori state estimates, and the revised estimates after the observer corrections the a posteriori estimates. Sanctus sempiterna.

Contents of the "Developing Models for Kalman Filters" section of the ridgerat-tech.us website, including this page, are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License unless otherwise specifically noted. For complete information about the terms of this license, see http://creativecommons.org/licenses/by-sa/4.0/. The license allows usage and derivative works for individual or commercial purposes under certain restrictions. For permissions beyond the scope of this license, see the contact information page for this site.