Basic Prerequisites: none beyond high-school algebra - this page builds the idea from scratch.


1. Intuition & Practical Objective

Start with the dumbest question: what is a price, really? You see a number on a screen - say you watch a stock trade at 100.02, then 99.98, then 100.01, then 99.99. The fundamental value you actually care about is not jumping 4 cents every second. The tick-to-tick wiggles are bid–ask bounce, discreteness, and random order flow: a buyer and a seller disagreeing about a quarter of a cent, not a change in what the business is worth. That noise is real, it is large, and - this is the key point - it is not signal.

So the object of study is not the observed price . It is the latent signal hiding inside it. We write the simplest possible model of this idea:

The practical objective of signal processing is to recover from a stream of noisy ‘s - optimally, in real time, with an honest accounting of how sure we are. The practical objective of the Kalman filter is to be that optimal recovery, and it delivers one thing no fixed-window method can: a running estimate plus its own uncertainty.

Three “aha”s carry the whole subject:

  1. A price is not a number, it is a number plus an error bar. Every naive estimator (a raw price, a rolling average, a plain OLS slope) quotes a point estimate and pretends its error is zero. The right representation is a distribution: “the true beta is “. The filter carries both.
  2. The trade-off is fundamental, not fixable by cleverness. Want to cut noise? Average more observations - but then you lag reality. Want to react instantly? Trust the latest tick - but then you inherit its noise. This is the bias–variance / lag–smoothness trade-off, and no filter escapes it. The Kalman filter’s contribution is not to break the trade-off but to let you choose the point on it explicitly (via and ) and to do so optimally.
  3. The filter is just Bayesian updating, recursively. Before the observation you hold a belief (“the value is ”). The observation is evidence, itself noisy. The filter combines prior and evidence into a posterior - and, because the model is Gaussian, that combination is a weighted average whose weight is exactly the ratio of certainty. No new machinery, just Bayes applied over and over.

2. Mathematical Ground Truth & Derivations

The simplest signal model - a random walk. The latent value drifts as a random walk; we see it through noise:

Two numbers encode the whole problem: (how much the truth moves) and (how noisy each look is). Their ratio is the signal-to-noise ratio, and it decides everything - how much to trust the data versus your own prediction.

Deriving the filter from Bayes (the Gaussian-weight view). Suppose before seeing our belief about is Gaussian with mean and variance (the “a priori” - the prediction). The observation tells us , i.e. it is plus independent noise of variance . The posterior for is Gaussian with

Read carefully: it is the fraction of the total variance that belongs to the signal. If the prediction is very uncertain (), then : trust the data, jump to it. If the data is very noisy (), then : ignore it, keep the prediction. is a shrinkage weight between two Gaussian beliefs, and it is the whole filter in one symbol.

The recursion - where prediction comes from. After updating at time we have . The signal then drifts by one step of variance , undoing none of our uncertainty:

So the filter alternates forever: predict (add to uncertainty), update (shrink uncertainty by and move toward the data), repeat. That single line - “add process noise, then subtract information” - is the entire algorithm.


3. Computational Implementation - a filter that beats the raw price

A 200-line detour is unnecessary: the scalar filter above is 10 lines. The point of the demo is to measure how much noise the filter removes versus the raw observation, on data where we know the truth.

The filter cuts the error by 59% versus the raw price, with a steady-state gain of only - because the signal moves so slowly () that the smart move is to treat each new tick as mostly noise and update only ~13% of the way toward it. This is the whole lesson: the optimal amount of the data to trust depends on , and the filter computes it for you.


4. Failure Modes & First-Principles Breakdowns

  1. “Just smooth it” is not a method. A moving average is a filter with a fixed, implicit gain and an even, useless-across-regimes weighting. Choosing its window by eyeball is choosing a point on the lag–noise curve arbitrarily. The Kalman filter makes the same choice derivable from - and updates it as uncertainty evolves.
  2. Assuming the noise is white when it is not. Bid–ask bounce produces negatively autocorrelated price changes (Tsay Ch 5: induces ). A filter that treats consecutive observations as independent will over-count correlated noise as information. Model the noise structure, don’t just assume iid.
  3. Confusing the latent state with the observable. The filter estimates , the latent value; you still trade the observable . If your fill price is but your edge is in , the gap between them is a cost you must budget for.
  4. The gain never fully settles if is wrong. is optimal *for the assumed . Feed the same filter a signal that actually moves 10× faster and is now far too small - the filter lags, and the “optimal” claim is void because it was optimal for the wrong model (see 05 · Failure Modes).

5. References

  • Tsay, Analysis of Financial Time Series (3rd ed.)
  • Welch & Bishop, An Introduction to the Kalman Filter (UNC TR 95-041)
  • Kalman (1960), A New Approach to Linear Filtering and Prediction Problems
  • Durbin & Koopman, Time Series Analysis by State Space Methods

6. Connected Graph Bridges