# If there are state variables in the Kalman filter that aren't being measured, is their output just rubbish?

I've been learning about the Kalman filter on this website: https://www.kalmanfilter.net/multiExamples.html

As you can see there is a numerical example regarding a car that is traveling in a 2 dimensional space, and his position along the x and y axes is measured, but there is a total of 6 state variables (position, velocity and acceleration along each axis). The filter does provide some estimates for velocity and acceleration, but I believe those numbers are just rubbish numbers?

On that note, I have a task at my uni to estimate a variable using the Kalman filter, but that variable is not being measured by the system, so I'm not sure how to do this...

• "but I believe those numbers are just rubbish numbers?" are you just here to argue about the established math of the Kalman filter, have you not studied the math underlying the Kalman filter, or do you have an actual question? If I gave you two measurements of my car's position, spaced one second apart, could you estimate its velocity? Is the estimate rubbish? If I gave you three measurements of my car's position, spaced 1/2 second apart, could you estimate both its velocity and acceleration? Are the estimates rubbish? If not, why can't the Kalman's answers be good, or even better? Aug 14 at 21:59
• I could take the position estimates and calculate velocity and acceleration with that information but I don't see how the Kalman filter does this by itself. Also, by looking at the velocity and acceleration estimates in the mentioned numerical example in the first 3 steps (-260, 53, 0.25) it doesn't seem to work. The only reason those numbers change are because of the included uncertainties of the estimates and noise, if I understand correctly, Aug 15 at 4:13
• The state transformation matrix only says that v(k)=v(k-1)+dt*a(k-1), and a(k)=a(k-1). So I don't see where to velocity or acceleration are linked to the positions. Aug 15 at 4:38
• When you work through the math, at what step do you get lost? If you haven't worked through the math -- why not? If you work through the math, it may just become obvious. If you're feeling a lack of being spoon-fed answers, just remember that you led out by telling the world that one of the most successful state estimation algorithms is "rubbish". Aug 15 at 5:20
• Well, obviously the velocity can be calculated based on the difference in position between times k and k-1, but I don't understand where is this done by the Kalman filter. I can only assume it's somehow included in the covariance matrix, but I don't understand some of the formula derivations completely so I'm not sure Aug 15 at 7:46

First, if you're reading a treatment of the Kalman filter and it's not coming to you as chapter 4, 5, or 6 in a book on state estimation or statistics or estimation & detection theory, then that treatment is missing a lot of background.

Second, the Kalman filter is one of a class of algorithms called "state estimators" or "state observers". My graduate level "introduction to state-space systems" course taught me about how to make observers that were stable, without ever mentioning Kalman filters -- those came in a different course.

So if you're just coming upon them cold and feel a bit under-educated -- that's why. And -- this post will still be inadequate. If you find yourself frustrated by the things, remember that you need to take a course (or get a good book and spend a course's worth of effort in self-study).

In your case, based on your comment about not seeing where the connection is between hidden states and measurements -- yes, the information about how to turn the evolution of the observed variables into refinements of the state estimates is buried in the covariance matrix.

The Kalman gain is calculated from the covariance matrix and the measurement matrix. Then the next covariance matrix is calculated from the Kalman gain and the state evolution matrix. This use of the state evolution matrix and the measurement matrix to determine the evolution of the covariance matrix is what makes the magic.

For you I think a good short cut to at least getting an example of this would be to choose a rational set of process noises (the $$\mathbf Q$$ matrix) and measurement noises (the $$\mathbf R$$ matrix), start with a covariance matrix that's something absurdly large (i.e. $$10^{10} \cdot \mathbf I$$), then calculate just the covariance matrix evolution for a good long time, until it settles out. At this point, your Kalman gain will become a constant.

(This is called a "steady state Kalman", btw)

Then you can find the filter transfer function from the measured variable to each of the states. You should find that the filtered position is just a low-pass of the measured state, the filtered velocity is a low-pass of the position's derivative, and the filtered acceleration is a low-pass of the position's double-derivative.