Every sensor is noisy, and every model is imperfect. The Kalman filter combines the two in an optimal way. The Kalman filter gain calculator performs one step of the scalar Kalman filter. With the previous estimate, its variance, the process noise, the measurement noise and a new measurement, it gives the Kalman gain, the updated estimate, the updated variance and the weight given to the measurement.
How the calculation works
- Enter your previous estimate of the quantity and its variance P, which measures how uncertain it is.
- Enter the process noise Q, the uncertainty added as time passes, the measurement noise R, the uncertainty of the sensor, and the new measurement.
- The calculator does one step of the scalar Kalman filter. The prediction step gives P⁻ = P + Q, and the Kalman gain is K = P⁻ / (P⁻ + R).
- The update step gives the new estimate x = x₀ + K (z − x₀) and the new variance (1 − K) P⁻. Repeat the step for each new measurement.
Example
A room temperature estimate is 68 °F with a variance of 4. The process noise is 0.5 and the sensor noise is 2. The predicted variance is 4 + 0.5 = 4.5, so the Kalman gain is 4.5 / (4.5 + 2) = 0.692. A new reading of 71.6 °F moves the estimate by 0.692 × 3.6 = 2.49 °F, to 70.49 °F, and the variance falls to 1.385.
Why it matters
The scalar filter is the easiest way to understand the idea behind the Kalman filter that is found in phones, drones, cars and spacecraft. It shows how the gain depends on the uncertainty, and how the variance shrinks after each measurement. It also helps to tune a simple sensor filter without a full state-space model.
Good to know
The calculator is for one quantity with a constant model, a random-walk process and Gaussian noise of known variance. Real systems have several states, models that are not linear, and noise that is not Gaussian, which call for matrix versions, the extended or the unscented filter. Use the result as a guide for smoothing a single sensor.
Related tools
The exponential moving average calculator is the simplest smoothing filter, the weighted average calculator combines values with weights, the standard deviation calculator measures spread, and the linear regression calculator fits a trend.