If there’s anything we’ve learnt after spending time with hidden Markov models (HMMs), it’s that HMMs are based on a powerful idea: the world has a hidden state that evolves over time, and all we ever get to observe is noisy, indirect measurements of that state. HMMs gave us a clean framework for reasoning about this under discrete state spaces. But, then, what happens when the hidden state is continuous? What about the exact position of a moving car, or the true temperature of a chemical reactor? Enumerating every possible state is no longer feasible, and so we need a new toolkit.
This is where the Kalman filter (KF) comes in. Safe to say it’s arguably the most elegant and practically impactful result in statistical signal processing. Personally, I’ve been using it a lot in my projects as well, so it’s 100% worth mastering for sure.
Important note: I’ll be representing probabilities as because is deeply entrenched in KF literature as covariance instead of , its typical notation in statistics.
***
Recall the structure of an HMM. We have a latent state that evolves according to a transition model, and an observation that is generated from that state. The KF is precisely this, but with two critical choices:
- The state space is continuous (real-valued vectors)
- Every distribution involved is Gaussian
Concretely, for KFs, we assume two linear models with additive Gaussian noise. First, the state transition model
and second, the observation model
where is the state transition matrix that describes how the hidden state evolves from one time step to the next, and is the observation matrix that maps the hidden state into the measurement space. The noise terms and are independent Gaussian vectors with covariances (process noise) and (measurement noise), respectively.
Note that just as in the case for HMMs, the Markov property holds here since depends on the past only through . The joint distribution over the entire sequence also factors the same way. The difference is that instead of a finite table of transition probabilities, we have a Gaussian density parameterized by and .
Prediction-Correction Cycle
In a discrete HMM, the forward algorithm computes recursively. The KF does exactly the same thing, but in continuous space. The recursion has two steps that alternate at each time point: predict, then update.
During the prediction step, at time , suppose we have computed the posterior over the hidden state as
To propagate this belief forward in time before seeing , we apply the Chapman-Kolmogorov equation as follows:
The good news is that since both factors, and , are Gaussian and the transition is linear, the integral actually has a closed form. The result is the prior predictive distribution at time :
with predicted mean and covariance
This completes the prediction step. In the update step, once is observed, we apply Bayes’ theorem to incorporate the new evidence:
where the likelihood is Gaussian in by virtue of the linear observation model. Since, the product of two Gaussians in is again (proportional to) a Gaussian, the posterior remains in the Gaussian family, and we can compute it exactly. This is what makes the KF tractable!
Kalman Gain
We define the closed-form posterior we obtained after the update step as
with updated mean and covariance
where is what we call the Kalman gain:
and is the innovation (more on this later).
I know the equations can look very daunting, but here me out for a second. The Kalman gain is the heart of the filter, and its statistical interpretation is actually beautifully intuitive. If we think of as a weighted average between two sources of information: our prediction and the current observation , the Kalman gain simply tells us how much weight to place on the observation relative to the prediction.
To be more precise, we can inspect the formula for : the numerator scales with our prediction uncertainty, and the denominator adds the observation noise . This means that when prediction uncertainty is large relative to , meaning our model’s forecast is unreliable, is large, and we trust the sensor more. When is large, meaning the sensor is noisy, is small, and we lean on the prediction.
Uncertainty Quantification
One key feature we should appreciate that distinguishes the KF from many ad-hoc estimation schemes is that it tracks more than just a point estimate; it tracks a full posterior covariance at every step. This covariance encodes our remaining uncertainty about the hidden state given all observations so far, and it dynamically evolves according to a structured recursion.
Let’s take a look at the discrete Riccati equation which governs how propagates across one full predict-update cycle:
To understand this, we must trace what happens to uncertainty at each stage. During the prediction step, uncertainty inflates, meaning the term transforms the previous covariance through the dynamics and simply adds fresh process noise. During the update step, uncertainty deflates, meaning the factor shrinks the covariance in the directions that the observation is informative about.
In the long run, under mild stability conditions, converges to a steady-state covariance that balances these two competing forces. As we can see, this equilibrium reflects the fundamental trade-off between how fast the state changes (controlled by and ) and how well our “sensors” can pin it down (controlled by and ).
Innovation and the Bayesian Update
As promised, let’s talk about the quantity that appears in the mean update formula. As is previously mentioned, we call this the innovation or residual:
The innovation basically measures the discrepancy between what the filter predicted the observation would be and what was actually observed. It’s, in a word, surprise, i.e., a large innovation means the new measurement is far from what the model expected.
Statistically, the innovation is itself a Gaussian random variable with zero mean and covariance:
where innovation covariance which combines uncertainty from both the state prediction and the sensor. It plays the role of a normalizing reference: an innovation of a given magnitude is more surprising when is small (we were confident in our prediction) and less surprising when is large.
Knowing this, we can finally compactly rewrite the Bayesian update as:
This represents a continuous-space Bayesian update where we start with the prior , observe data with likelihood , and shift the posterior mean in the direction of the innovation, scaled by the Kalman gain. The Kalman gain itself can now be interpreted as , which is the ratio of the state-observation cross-covariance to the total innovation variance.
Now in practice, monitoring the innovation sequence is an important diagnostic. Under a well-specified model, innovations should be white noise (i.e., serially uncorrelated and distributed as ). This means that systematic patterns in the innovations are a signal that the model (specifically the matrices , , , or ) may be misspecified.
Kalman Smoothing and Parameter Estimation
The KF as described is a causal algorithm, meaning at each time , it computes using only observations up to and including the present. However, there are applications such as batch data analysis and historical reconstruction where we have access to the full observation sequence and want the smoothed posterior for all instead.
The process that accomplishes this is called Kalman smoothing, and it’s most commonly implemented via the RauchβTungβStriebel (RTS) smoother in two passes:
- The forward pass is the standard Kalman filter, and
- The backward pass then propagates information from future observations back in time, correcting each filtered estimate.
This results in a tighter posterior because future data can only reduce uncertainty, and it’s computed with a cost linear in , just like the filter itself.
The more substantial extension actually concerns parameter estimation: in practice, the matrices , , , and are rarely known exactly, and so must be learned from data. We call this the system identification problem, and it’s where the ExpectationβMaximization (EM) algorithm enters (similar to how parametrization works in HMMs).
In the EM framework, the hidden states are treated as latent variables. First, the E-step runs the Kalman smoother to compute the posterior distribution over all hidden states given the current parameter estimates and the observed data. The M-step then maximizes the expected complete-data log-likelihood with respect to , , , and , thereby holding the smoothed state distributions fixed. Crucially, the M-step updates for each matrix actually have closed-form solutions, making EM particularly efficient for linear Gaussian state-space models.
With each steps defined, we conclude by stating that the algorithm simply iterates both until convergence, increasing the marginal likelihood at each iteration. I hope you can see how this is a powerful statistical inference loop: the smoother uses the parameters to infer latent states, and the M-step uses those inferred states to improve the parameters.
Beyond EM, we can also place priors over parameters and use variational inference or MCMC for full Bayesian treatment. Additionally, extensions to nonlinear and non-Gaussian systems via the Extended KF, Unscented KF, or particle filters follow the same conceptual skeleton but relax the Gaussian linearity requirement at the cost of losing the exact closed-form solutions that make the classical KF so satisfying. Anyhow, we won’t be going through any of these since the article itself is getting pretty long.
If you’ve been able to follow this and understand it all the way through, I hope you can see that at the end of the day, the KF is just the continuous and Gaussian counterpart of the HMM, given how every component traces back to familiar ideas in the latter.

Leave a Reply