# Observation Matrix in Kalman Filter

I've been trying to understand the concept of the Kalman Filter. I came across this great article which makes the concept sufficiently clear.

However I could not understand the concept of the matrix $\mathbf{H}$ which I think is the observation matrix. In Equation 8 in the article, the sensors are modeled using this matrix. I've been through a few posts in this site, where I found that the $\mathbf{H}$ matrix is always a combination of 1's and 0's.

Is this always true for any system where I am trying to estimate the value of a parameter like velocity or position?

If you can do it that way, it makes it straight forward to implement the Kalman filter. As an example - consider a constant velocity model in Cartesian coordinates, but the only thing you are measuring is the position (not velocity) and you are measuring the position in a Cartesian coordinate system. Then your $\mathbf{H}$ matrix will only pick off the position value as you've described.

Now consider a Sonar or Radar system - which measure range and bearing rather than x, y, z. Now the measurements take place in a Polar/Spherical coordinate system but it is easier to keep the model for your targets as having constant velocities in the cartesian coordinate system. Now your state propagation matrix is the same as in the previous case, but now your $\mathbf{H}$ matrix needs to convert your Cartesion state coordinates to Polar/Speherical coordinates for your measurements. e,g, $R =\sqrt{x^2+y^2+z^2}$. So now your $\mathbf{H}$ matrix is not simply extracting one of the state variables. In fact your $\mathbf{H}$ is not even a constant value - it varies with the values of the state vector. Thus the transformation in the measurement matrix $\mathbf{H}$ is non-linear, so the Kalman filter is not even optimal anymore. In this case you now get into the Extended Kalman Filter to try and handle the non-linearity in the transformation.

This was meant to give you one specific example. Also, note that there are other ways of handling the Cartesian to Spherical conversion issue.

• Nice example!!! – Peter K. Dec 3 '15 at 16:10
• @David I'm taking the same example of the Radar system. Does this mean that since my radar system's sensors measure range and bearing, I have to model the sensors using the State matrix and the observation matrix H so that I get a new matrix whose elements contain range and bearing . ? – Jose Kurian Dec 4 '15 at 10:12
• @JoseKurian No, you don't have to do it that way. You could convert your range, bearing measurements to Cartesian coordinates and use Cartesian coordinates for the state and observation - both then your covariance matrix for the measurement noise gets more complicated and also time-varying. Yet another alternative is a modified coordinate system e.g. Modified Polar Coord - Range, bearing and 1/Range. I'm not an expert in the field - you will probably have to review the literature to see the pros and cons of the different methods. – David Dec 4 '15 at 14:57

Precisely the form that the $\mathbf{H}$ matrix takes depends on your signal model.

The nice thing about positional models is that we have a very clear relationship between acceleration, velocity, and position --- and the instruments we use to measure those quantities measure them directly.

That means we can write down the state update equations and the measurement equations in terms of those quantities --- and those quantities are good selections for the state of the system (sometimes without acceleration).

In this instance, when the state of a system that we are applying a Kalman filter to is directly measurable (through some noisy sensor) then the $\mathbf{H}$ matrix is just 1's and 0's.

That is sometimes not the case. For example, an equivalent state space system could be defined with a different selection of states. The system still models our positional problem, but the states don't map directly to position and velocity.

The observation matrix H is actually a transformation matrix. It transforms State space to measurement space.

Example, a system state can be "s" and is the sum of two sensor outputs "a" and "b".

s = a + b


Now during the update of state variables in the update stage, the kalman gain is to be applied to the difference between measured(aka observed)data and predicted state.

The predicted state in our contrived example is a scalar whilst the measured data is a vector [a vector comprising output of two sensors]. The observation matrix transforms the predicted state into a vector so that the difference can be taken and kalman gain applied.

assume we are tracking a vehicle with a radar/lidar. The radar/lidar is placed some where to observe the vehicle. the state of the vehicle is

$$\mathbf{x}=\begin{bmatrix} x \\ v \end{bmatrix},P=\begin{bmatrix} cov(x,x) && cov(x,v) \\ cov(v,x) && cov(v,v) \end{bmatrix}$$

from the radar/lidar, we can read the time of echo signal, not the distance, but the time. In order to connect the state vector and the measurement, we need the measurement matrix $$H$$. In this case,

$$H=\begin{bmatrix} 1/c && 0 \end{bmatrix}$$

where $$c$$ is the light speed.

thus, the measurement is about time, then we project the estimated state to measurement unit.

here is an example, $$\mathbf{x}_{k\vert k-1}$$ is the predicted state at time k based on the state of time k-1. We project the predicted state into measurement unit system with observation model $$H_k$$, in order to merge the distribution in the next step.

$$\begin{eqnarray} \mathbf{z}_{k}&=&H_k \mathbf{x}_{k\vert k-1}=\begin{bmatrix} 1/c && 0 \end{bmatrix}\begin{bmatrix} x_{k\vert k-1} \\ v_{k\vert k-1} \end{bmatrix}=x_{k\vert k-1}/c \\ \text{var}(H_k\mathbf{x}_{k\vert k-1})&=&H_kP_{k\vert k-1}H_k^T=\text{var}(x_{k\vert k-1})/c^2 \end{eqnarray}$$