The answersDownload the PDF
Worksheet

U4.4 Outliers

Noise and filtering · University · about 25 min

BugBotLab
NameClassDate

What this lesson is about

Some readings are not noisy, they are wrong. The median, and gating on what you expected.

Questions 6 marks in all

  1. [1 mark]Nine readings of 60 cm and one of 400 cm are averaged. By how many centimetres does the outlier shift the mean away from 60?

  2. [1 mark]A window of five holds two maximum-range readings. What does this print?

    window = [61, 400, 59, 60, 400]
    median = sorted(window)[len(window) // 2]
    mean = sum(window) / len(window)
    print(median, mean)
  3. [1 mark]How many bad readings out of five can a median of five survive with its output still one of the good readings?

  4. [1 mark]A gate is rejecting about half of all readings. What does that most likely say?

    1. AThe expectation the readings are compared with is wrong, and the gate is hiding it
    2. BThe gate is working well and protecting the estimate
    3. CThe sensor noise has halved
    4. DThe gate should be widened to three times the median
  5. [1 mark]Which of these are real costs of a median filter?

    Tick every answer that is true.

    1. AIt rounds off genuine sharp changes as well as outliers
    2. BIt needs a sort every tick, which is not free on a microcontroller at 200 Hz
    3. CA single maximum-range reading ruins its output
    4. DIt only works when the noise is Gaussian
  6. [1 mark]In a Kalman filter, the validation gate is set from the covariance. What does that achieve?

    1. AThe gate widens when the filter is genuinely unsure and tightens when it is confident
    2. BThe gate stays fixed so the rejection count is comparable
    3. CEvery reading is accepted once the covariance has settled
    4. DThe gate rejects readings that agree too closely with the estimate

The task: throw out the wrong ones

Drive towards the wall with a median filter and a gate running, and stop 35 cm from it, without being fooled by the robot that crosses in front. Plot raw and median, and print thrown out:, the number of readings your gate rejected.

from bugbot import *
connect()

window = []
thrown = 0

Plan your program here, then type it in and press Run.

QR code
Do it on the robot
www.bugbotlab.com/learn/u4-4-outliers/
The simulator checks it and tells you when it passes. Nothing to install, no account.

Challenges

  1. Compare a mean of five with a median of five on the same data, plotted together.
  2. Set the gate too tight and watch the count of rejections climb. What does the estimate do?
  3. Reject any reading at maximum range before doing anything else. Is that a gate or a special case?