The worksheetDownload the PDF
Answers

U4.1 A reading is a distribution

Noise and filtering · University · about 25 min

BugBotLab

What this lesson is about

Mean, standard deviation, and what one number from a sensor is actually telling you.

Questions 6 marks in all

  1. [1 mark]A still robot's depth readings have mean 57.0 cm and standard deviation 2.0 cm, and are Gaussian. About what fraction of readings land between 55 and 59 cm?

    1. AAbout 68 percent
    2. BAbout 95 percent
    3. CAbout 50 percent
    4. DAbout 99.7 percent
    Answer: A. 55 to 59 cm is the mean plus or minus one sigma, which holds about 68 percent of a Gaussian. Plus or minus two sigma (53 to 61 cm) would be 95 percent.
  2. [1 mark]Same sensor: mean 57.0 cm, sigma 2.0 cm. About what percentage of readings fall outside 51 to 63 cm? Give a percentage to one decimal place.

    Answer: 0.3 (accept within 0.05). 51 to 63 cm is three sigma either side, which holds 99.7 percent, so about 0.3 percent fall outside. That is what engineers mean by three sigma: practically never.
  3. [1 mark]This computes the mean and sigma exactly as the lesson does. What does it print?

    readings = [56, 58, 60, 62, 64]
    mean = sum(readings) / len(readings)
    var = sum((r - mean) ** 2 for r in readings) / len(readings)
    sigma = var ** 0.5
    print(mean, var, round(sigma, 2))
    Answer:
    60.0 8.0 2.83

    The mean is 60. The squared deviations are 16, 4, 0, 4 and 16, averaging 8, which is the variance in cm squared. Sigma is its square root, 2.83 cm.

  4. [1 mark]A sensor gives readings with sigma 0.3 cm, but their mean is 4 cm short of a tape-measured distance. What will fix it?

    1. ACalibrate against the tape measure
    2. BAverage more readings
    3. CUse a stronger low pass filter
    4. DTake the readings further apart in time
    Answer: A. Small sigma and a shifted mean is bias, not noise. Averaging and filtering only reduce scatter, so only calibration against something you trust removes the shift.
  5. [1 mark]A student reads the depth sensor 100 times in a tight loop with no wait and gets sigma = 0.4 cm, much smaller than with a 0.1 s wait. Why is that number a lie?

    1. AThe sensor only produces a new measurement about every 0.1 s, so most reads repeat the same sample
    2. BReading quickly lets the sensor warm up and become more precise
    3. CThe variance should have been divided by 99, not 100
    4. DSigma is the square of the variance, so it was computed wrongly
    Answer: A. A hundred reads between updates is a handful of samples counted many times, so the spread looks small. Independence comes from time between readings.
  6. [1 mark]A reading's spread is described by its standard deviation. What is the name of its square, measured in squared units?

    Answer: variance. Variance is the mean squared deviation, in cm squared. Sigma is its square root, in cm, which is why sigma is the one that compares directly with a reading.

The task: measure the noise

Standing still, print mean: and sigma: for this sensor, in centimetres.

from bugbot import *
connect()

readings = []

The hint students can ask for: Stand still and read distance() a hundred times, a tenth of a second apart. The mean is the sum over the count; sigma is the square root of the mean squared difference from that mean.

A solution

from bugbot import *
connect()

readings = []
for i in range(100):
    readings.append(distance())
    wait(0.1)

mean = sum(readings) / len(readings)
var = sum((r - mean) ** 2 for r in readings) / len(readings)
print("mean:", round(mean, 1))
print("sigma:", round(var ** 0.5, 2))

Any program that meets the task's checks is marked correct in the simulator; this is one way, not the only way.