Kalman Filter for Static State & Single Measurement

1 minute read

Published:

Kalman filter is an iterative mathematical process applied on consecutive data inputs to quickly estimate the true value (position, velocity, weight, temperature, etc) of the object being measured, when the measured values contain random error or uncertainty.

In this post, we’re going to look at how to implement Kalman filter in the context of static model where the true value of the object’s states are constant over time. In addition, for simplicity, we’ll only consider single measurement where there’s only one object’s state being measured.

Code

You can find the Kalman filter implementation in Python on this repo.

How it works?

Suppose that we receive the following inputs prior to performing Kalman filter:

  • Initial estimate
  • Initial estimate error
  • Measurement error (assumed to be constant over time)

There are three main calculations:

  • Kalman gain: previous_estimate_error / (previous_estimate_error + measurement_error)
  • Current estimate: previous_estimate + (kalman_gain * (measurement - previous_estimate))
  • Current estimate error: (1 - kalman_gain) * previous_estimate_error

For our example, suppose that we’d like to measure a temperature. Here are some basic information:

  • The true temperature: 72
  • Initial estimate: 68
  • Initial estimate error: 2
  • Initial measurement: 75
  • Measurement error: 4

The measured temperature values are 75, 71, 70, and 74.

We’d like to estimate the true temperature value based on the above data.

Performing Kalman filter calculation will yield the following results.

TimeMeasurementMeasurement ErrorEstimateEstimate ErrorKalman Gain
t-1--682-
t75470.331.330.33
t+171470.510.25
t+270470.40.80.2
t+3744710.660.17

According to the given data, the true value estimate is 71.