# Is a Kalman filter ever the optimal way to estimate a dynamic value given a full history of measurements?

I'm trying to get some intuition for Kalman filtering, and I conceived this toy example:

Say that I have a sensor that tracks a moving 1-dimensional target. Say that the measurements from the sensor are {1.1 2.1 2.4 2.9 3.0 2.6 3.2}, with one measurement per second since it started detecting the target (just to have some toy data to make things clearer). Assume I have a pretty good motion model for how the target moves dynamically, that the sensor noise is Gaussian and that the problem is similarly "nice" in most other ways. My goal is to estimate the position of this target at the last frame (i.e. at the time I got the "3.2" measurement) as well as possible given this information.

My instinctual approach would be to use a Kalman filter, feed it with the data, and use its estimate at the last frame as my estimate. This approach has many advantages: it is simple, the Kalman filter is "optimal" which sounds nice, it easy to update the filter if new measurements are made, I don't have to save all measurements etc. But doesn't this approach lose information? When I do the last measure update, all the other measurements have been compressed to the filter state. Isn't information lost? If I wanted to get the best estimate of the target position at all times, I would have to do some kind of smoothing? Will that give the same result as the Kalman filter for the last frame?

• Thanks for the answer! So smoothing will give the same result as filtering for the last frame? I'm just having a hard time with my intuition about this. The Kalman filter "eats" the measurements in a certain order, and it feels like this order should matter somehow. – blåblomma Jan 3 '19 at 10:50

It often happens that the name Kalman Filter is used, while actually it is a Kalman Predictor or Kalman Smoother.

• Kalman Predictor if we have no measurements from the present
• Kalman Filter when we make an estimate given the past and present measurements
• Kalman Smoother when we make an estimate acausally (using future measurements too)

The optimality of Kalman Filter is nice, but it is only optimal if the right assumptions are met. The most difficult to get around is the linearity of the model, but the Gaussian nature of noise is also one that is often not met in practice. The Extended and Unscented Kalman Filters alleviate the linearity, but they don't guarantee optimality.

To get more understanding of the Kalman Filter, it is really helpful to look at the derivation of the Kalman Filter from the perspective of recursive Bayesian estimation. It is nicely explained in Wikipedia, but I will discuss the more important points.

Briefly, what the framework consists of is treating the measurements $$\mathbf{z}$$ as quantities which reflect information about the true state $$\mathbf{x}$$ of the system that we wish to know. What we wish to find is the most probable state given the previous measurements and states, $$p( \mathbf{x}_{k} | \mathbf{x}_{1:k-1}, \mathbf{z}_{1:k-1})$$.

I think what you are pointing at is the Markovian assumption of the framework, which is $$p(\mathbf{x}_{k} | \mathbf{x}_{1:k-1} ) = p( \mathbf{x}_k | \mathbf{x}_{k-1} ),$$

so that the current state only depends on the previous state of the system. That is indeed some compression, but often quite a reasonable one, and makes the problem computationally tractable.

• Thanks! I will look into the Markovian assumption. :) – blåblomma Jan 3 '19 at 14:05