Skip to content
Omnikalc

Kalman filter gain calculator: blend a prediction and a measurement in the best way

Enter the previous estimate and its variance, the process and measurement noise and a new measurement to get the Kalman gain and the updated estimate.

Updated on
Your inputs
°F

Value out of range

Value out of range

Value out of range

Value out of range

°F

Value out of range

Results

Kalman gain K

0.692

The filter trusts the new measurement more than its prediction
Updated estimate
70.492 °F
Updated variance
1.385
Predicted variance before the measurement
4.500
Weight given to the measurement
69.2 %

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.

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.

Frequently asked questions

What does the Kalman filter do?

It combines a prediction from a model with a noisy measurement to give an estimate better than either one alone. It weights the two by their uncertainty: the more certain source gets the higher weight. It is used for navigation, tracking, robotics and sensor fusion, and it was used to guide the Apollo spacecraft.

What is the Kalman gain?

The gain K is a number between 0 and 1 that sets how far the estimate moves toward the new measurement. If the sensor is very noisy, R is large and K is small, so the filter mostly keeps its prediction. If the sensor is precise, R is small and K is close to 1, and the estimate follows the measurement.

How do I choose Q and R?

R comes from the sensor: use the variance of repeated readings of a constant quantity, or the value in the data sheet. Q describes how much the true quantity can change between two steps, and it is harder to find. Tuning Q is the main task in practice: a small Q gives a smooth but slow estimate, and a large Q gives a fast but noisy one.

How is it related to the exponential moving average?

In the scalar case, the update is x = x₀ + K (z − x₀), which is an exponential moving average whose smoothing factor K changes at each step. The Kalman filter finds K from the uncertainties, and it settles to a steady value when Q and R are constant. This is why a simple filter is often a good approximation.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.