# Variance Propagation

Developing Models for Kalman Filters

Last installment, we observed that the variance in the state values changes over time, starting with a flaky covariance that reflects a lack of knowledge about what the initial system state is. As system activity continues, more and more information from observation of system outputs is incorporated. In time, the variations in the state variables become dependent on the driving internal noise, rather than the peculiar representation of initial uncertainty.

In this installment, we will examine this in more detail, watching the changes in the state covariance analytically.

## Variance Propagation in an Observer system

Suppose the system starts in a completely unknown initial state. We can represent this by picking an arbitrary state vector of initial values randomly from within the normal operating range, obtaining initial state `x0`. For purposes of implementation, a zero state is as representative of the input range as any. So a plausible choice for initializing in the presence of no initial state information is simply to start with a zero state vector. For normalized variables, the covariance matrix `P0` assumed for this state vector has values `1/3` on the main diagonal by construction.

The state transition equations for the first update has terms for the state transition response, coupled inputs, and random state noise.

```   x1 = A x0 + B u0 + w0
```

However, we know that from the separability property of linear systems, we can consider the effects of the input terms `B u` separately from the effects of the noise. Consequently, we can simplify this by considering only the disturbance offset terms `e`.

```   e1 = A e0 +  w0
```

When we add in some additional observer terms, the feedback term `K` will couple some of the original noise back from output to input, and in addition to that, couple some amount of the output observation noise. This has the effect of modifying the noise propagation terms and adding a new one.

```   e1 = (I - K C) A e0  +  (I - K C) w0  K v0
```

We have previously defined notations for covariances of the noise terms ` e, w,` and `v`.

1. New internal random noise with covariance `Q`. This comes from unknown sources and directly disturbs the variables in the next state.
2. Observation random noise with covariance `V`. This is coupled into the state error through the observer action.
3. State uncertainty propagating in from the initial state vector `x0`. This is represented by the constructed `P0` covariance matrix.

We know that variances are additive when random variables are added. We also know that for a transformed variable `M x`, where `x` has covariance `P`, that the covariance of the result is going to be `M P MT`. Consequently, we can determine that the new state covariance subsequent to the update will be as follows.

`   P1 =  (I - K C) A P0 AT (I - K C)T AT  +  (I - K C) Q (I - K C)T  +  K V K`

The output observation equations apply transformation `C` to the vector of state variables, so this will also show variance effects that can be calculated. The two contributing terms are the state vector and a vector of random observation noise described by covariance `V`.

```y1 = C x1 + v0

Y1  =  C P1 CT + V
```

Given the `P0` variance of the state, we can repeat this processing to determine the state variance at each instant.

As always, we are not going to fully believe any of this until we see it put into practice. But before we can generate a suitable simulation, we need to know how to produce random vectors having a specified covariance; that's the topic for next time.

[1] The term Riccati Equations originally came from the study of a family of differential equations by Jacopo Riccati (1676–1754), see the Encyclopedia of Mathematics, Springer, ISBN 978-1-55608-010-4 at a university technical library near you. Since those original studies, the meaning has been expanded to include "algebraic" quadratic equations with a very similar form.

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.