Lab 1 - One-dimensional Kalman filter

In this lab, you will design your own filter for a thermometer.

The sensor for the thermometer outputs a voltage that corresponds to the temperature that is being measured.

The manufacturer’s specifications for the sensor tell you that the sensor exhibits white noise with a standard deviation of 0.13 volts.

  1. Create a function volt(voltage, std) that simulate the temperature measurement.

Now for the prediction. We do not consider a sensor for the movement in the voltage.

We have no known movement, so we will set that to zero. However, that means that we are predicting that the temperature will never change.

If that is true, then over time we should become extremely confident in our results.

Once the filter has enough measurements it will become very confident that it can predict the subsequent temperatures, and this will lead it to ignore measurements that result due to an actual temperature change.

This is called a smug filter, and is something you want to avoid.

  1. Create the initial belief state x centred at 25 with a variance of 1000.

  2. Create the process_model (gaussian) centred in 0 with a variance of \(.05^2\).

  3. Create a function generate_measurement(n) that will generate n measurements.

  4. Create a function kalman_filter(x, zs, process_model, voltage_std) that will implement the kalman filter, where

    • x: the initial belief state

    • zs: the measurements generated

    • process_model: the process model

    • voltage_std: the std of the voltage.

If we consider an actual voltage of 16.3, we obtain something close to the following figures.

_images/lab1_volt.png
_images/lab1_volt_variance.png
  1. Change the value of the actual voltage and see what happens.