Library / Tracking and estimation / TRK-01
Tracking and estimation
Scalar Kalman filter measurement update
One measurement update for a single state.
- Ref
- TRK-01
- Rev
- v1
- Field
- Tracking and estimation
- Result
- x̂+ [m]
The prediction x̂⁻ has variance P⁻ and the measurement z has variance R. The Kalman gain K = P⁻/(P⁻ + R) says how far to move towards the measurement: a certain measurement (small R) gives a gain near 1, an uncertain one a gain near 0. The updated variance P⁺ = (1 − K)P⁻ is always smaller than both inputs. For the optimal gain this is identical to the Joseph form used in numerical code. The updated estimate is the output.
One measurement update for a single state. The estimate moves towards the measurement by a fraction K, set by how uncertain the prediction is compared with the sensor.
Calculator
- Kalman gain, K = P−/(P− + R)0.8
- Updated variance, P+ = (1 − K)P−0.8 m²
- Innovation, ν = z − x̂−2 m
- Innovation variance, S = P− + R5 m²
What drives the result
Each variable is moved across its typical range while the others stay at the values above. The longest bar is the key driver.
- The prediction is 4 times more uncertain than the sensor, so the filter moves 80 % of the way to the measurement, from 10 m to 11.6 m. The uncertainty falls from 4 m² to 0.8 m².
- If the sensor were as uncertain as the prediction (R = 4 m²) the gain would be 0.5 and the estimate 11 m, with a variance of 2 m². Combining two equally good sources halves the variance.
Chart data as tables
Ranked variables
| Variable | Typical range | Lowest result | Highest result | Swing (m) | Local step | Change in result |
|---|---|---|---|---|---|---|
| z Measurement | 0 to 100 m | 2 | 82 | 80 | +10% | +8.28 % |
| x̂- Predicted state | 0 to 100 m | 9.6 | 29.6 | 20 | +10% | +1.72 % |
| R Measurement variance | 0.1 to 25 m² | 10.28 | 11.95 | 1.675 | +10% | −0.27 % |
| P- Prediction variance | 0.5 to 25 m² | 10.67 | 11.92 | 1.256 | +10% | +0.255 % |
Sweep of Measurement variance
| Measurement variance (m²) | Updated estimate (m) |
|---|---|
| 0.1 | 11.95 |
| 3.212 | 11.11 |
| 6.325 | 10.77 |
| 9.437 | 10.6 |
| 12.55 | 10.48 |
| 15.66 | 10.41 |
| 18.77 | 10.35 |
| 21.89 | 10.31 |
| 25 | 10.28 |
Sweep one variable
Variables and how each one contributes
Updated estimate
What the equation gives you. Everything else feeds it.
Predicted state
The predicted state before seeing the measurement, in m. Moves the updated estimate by the fraction (1 − K) of its change. Raising it by 10 % (to 11) moves the result by +1.72 %, from 11.6 to 11.8 m.
Prediction variance
The variance of the prediction, in m². It is the square of the standard deviation. A more uncertain prediction means the filter trusts the measurement more, so the estimate moves closer to it. Raising it by 10 % (to 4.4) moves the result by +0.255 %, from 11.6 to 11.63 m.
Measurement
The measurement, in m. Moves the updated estimate by a fraction K of its change. Raising it by 10 % (to 13.2) moves the result by +8.28 %, from 11.6 to 12.56 m.
Measurement variance
The variance of the measurement noise, in m². A noisier sensor reduces the gain, so the estimate stays closer to the prediction. Raising it by 10 % (to 1.1) moves the result by −0.27 %, from 11.6 to 11.57 m.
Worked example with the values above
- Gain: K = P⁻/(P⁻ + R) = 4 / (4 + 1) = 0.8.
- Innovation: ν = z − x̂⁻ = 12 − 10 = 2 m, so x̂⁺ = 10 + 0.8 × 2.
- x̂⁺ = 11.6 m, with variance P⁺ = (1 − 0.8) × 4 = 0.8 m².
Assumptions and limits
- A scalar linear Gaussian model, with zero-mean white noise whose variances P⁻ and R are known correctly.
- The measurement is of the state itself (H = 1), and the prediction and measurement errors are independent.
Common mistakes
- Using standard deviations where variances are expected. P and R are variances, in m².
- Trusting the updated variance without checking. If R or the process noise are set wrongly, P⁺ can be far too optimistic. Examine the innovations.
Statistics and uncertainty
The update is an inverse-variance weighted average, and the variances add as reciprocals: 1/P⁺ = 1/P⁻ + 1/R = 0.25 + 1 = 1.25, so P⁺ = 0.8 m². The variance is smaller than either input, so the uncertainty always falls with a measurement. It is only as reliable as P⁻ and R: if the noise levels are set too low, the filter becomes overconfident.
Where it is used
- Understanding how a Kalman filter weights a prediction against a measurement.
- Checking the first step of a tracker or a navigation filter by hand.
Maths you need
- Variance: the square of the standard deviation
- Weighted average: weights proportional to 1 / variance