Fundamentals / Numerical mathematics / Inverse problems and least squares

Learning a drifting temperature from a sequence of readings

Derive the scalar Kalman update by completing the square and see how process uncertainty controls memory of the past.

Propagate a distribution through time

A drifting offset follows \(x_k=x_{k-1}+w_k\). A thermometer reports \(z_k=x_k+v_k\). Assume independent, zero-mean Gaussian process increments of variance \(Q\) and sensor noise of variance \(R\), independent at each time and of the initial state. Before the next reading, the mean stays at \(m^-=m_{k-1}\) and the variance adds, \(P^-=P_{k-1}+Q\).

The negative log posterior, up to constants, is \((x-m^-)^2/(2P^-)+(z_k-x)^2/(2R)\). Collect the coefficient of \(x^2\) and its linear term. The result can be written in two equivalent forms:

\[P_k=(1/P^-+1/R)^{-1},\]
\[m_k=m^-+K(z_k-m^-),\]
\[K=P^-/(P^-+R).\]

Thus the fraction of the innovation used is a model prediction. When sensors are noisy the gain falls. When the model permits rapid drift, uncertainty grows between readings, giving the new measurement a larger role. These are variances, so a stated standard deviation must be squared first.

A reading with units and a repeated reading

A prior says \(20.0\pm2.0\) °C (one standard deviation), with negligible intervening drift. A sensor of standard deviation 1 °C reads 23 °C. The gain is \(4/(4+1)=0.8\), giving \(22.4\) °C and variance \(0.8\) °C². A second independent reading of 23 °C gives gain \(0.8/1.8\) and mean \(22.6667\) °C. Treating a duplicate record as independent would falsely claim the same information gain.

In a long random walk with \(Q=0.25\) and \(R=1\) in squared units, a steady posterior variance satisfies

\[P=(P+Q)R/(P+Q+R).\]

Rearrangement gives \(P^2+QP-QR=0\), so the physically positive root is about 0.3904. New uncertainty replenishes the information squeezed out by measurement.

Follow a change in the underlying temperature

For a reproducible illustration, a fixed synthetic thermometer trace contains a smooth periodic disturbance and a step in the hidden temperature. It is deliberately held fixed while the filter's assumed \(Q\) and \(R\) change. Compare the lag just after the step with the wiggle once the temperature settles.

Tutorial on noisy data over time

If \(Q=0\), show how \(n\) independent readings with the same variance affect precision.

Worked solution

Each update adds \(1/R\) to precision \(1/P\). Induction gives

\[1/P_n=1/P_0+n/R.\]

This is precisely the precision of a batch Gaussian update.

What pattern in the innovations would call the random-walk assumptions into question?

Worked solution

A long run of positive innovations after a systematic ramp suggests bias in the prediction. Serial correlation suggests missing dynamics or correlated observation errors. Check against predicted innovation variance \(P^-+R\) and examine signs and lags as well as their sizes.

Read the university treatment

Extend the scalar precision update to several state variables and identify the matrix made invertible by a positive observation variance. Stephen Boyd · Stanford EE363, estimation and the Kalman filter

Study the full derivation

What each new sensor reading changes in a Gaussian inverse problem · Inferring parameters and fields from observations

Start with an uncertain vector, condition on one noisy linear observation, and reconstruct the posterior mean and covariance without repeating a batch inversion. Check shared calibration errors before treating repeated measurements as independent evidence.