Noise and filtering · University · about 25 min
Mean, standard deviation, and what one number from a sensor is actually telling you.
[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 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.
[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))
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.
[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 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 mark]A reading's spread is described by its standard deviation. What is the name of its square, measured in squared units?
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.
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.