Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

2.2 Sensors and Noise: What Did My Sensors Tell Me?

Source

In Section 2.1 the robot asked what might happen. Now something has happened: a sensor has produced a reading. The question becomes what did my sensor tell me, and how much should I trust it?

A delivery robot at the gate

A delivery robot is carrying a parcel into an apartment complex. It approaches the main gate, which it must stop in front of so the security guard can scan the parcel. Its ultrasonic sensor sends out a sound pulse and times the echo. The display says:

Distance to gate: 2.4 m

Is the gate exactly 2.4 m away? Almost certainly not. The echo time depends on air temperature and humidity. The gate’s bars reflect sound unevenly, and a slight tilt of the robot changes which bar returns the echo first. So the true distance is probably close to 2.4 m, but it could reasonably be 2.3 m or 2.5 m, and occasionally 2.2 m or 2.6 m.

The key idea of this section is:

measurement ≠ truth. A measurement is the truth plus some error.

The flow of information looks like this:

The robot sees only the reading. Its job is to work back from the reading to a belief about the actual distance.

Measurement = true value + noise

We can now write the idea in symbols. Let dd be the true distance (unknown) and zz the reading (known). Then

z=d+vz = d + v

where vv is the noise: the error in this particular reading. We never know vv for a single reading; if we did, we would simply subtract it. What we can know from testing is how noise behaves on average. In Section 1.2 we modeled this sensor’s noise as Gaussian with a standard deviation that grows with distance:

v∼N(0, σ(d)2),σ(d)=0.02+0.03 d metresv \sim \mathcal{N}\big(0,\ \sigma(d)^2\big), \qquad \sigma(d) = 0.02 + 0.03\,d \ \text{metres}

At about 2.4 m, σ≈0.09\sigma \approx 0.09 m, so most readings fall within about ±0.18 m (two standard deviations) of the truth.

<Figure size 770x396 with 1 Axes>

Noise is not failure

A working sensor still produces noisy readings. That is noise: small, random, and centred on the truth. It is different from failure, where the reading is wrong in a way that has nothing to do with the true distance. On an Indian residential road, an ultrasonic sensor can fail in several recognisable ways:

SituationWhat the sensor reportsKind of error
Normal operation2.33, 2.46, 2.41, …small noise around the truth
A parked scooter between robot and gate1.1 mwrong object: it measured the scooter
Sound bounces off a glass guard cabin and never returns4.0 m (maximum range)no echo: the pulse was lost
Heavy rain on the sensor facerandom valuesinterference

Noise is handled by averaging and by probability. Failures are handled differently: by checking whether a reading is plausible, comparing it with other sensors, and ignoring readings that make no physical sense. A good sensor model includes both.

<Figure size 770x396 with 1 Axes>

The cooking thermometer, again

Back in the kitchen, the oil is at about 170 °C and the thermometer gives five readings:

Reading12345
Temperature (°C)167171169173170

Which reading should the robot trust? None of them alone. Each is the true temperature plus noise, exactly like (1) with TT in place of dd. The readings are all plausible, since they spread by only a few degrees, so none looks like a failure. The best use of them is the one from Section 2.1: average them. The mean is 170 °C, and with a standard deviation of about 2.2 °C across these readings, the mean of five has a standard error of about 2.2/5≈1.02.2/\sqrt{5} \approx 1.0 °C.

The same thinking applies to both robots. A single reading is weak evidence; a sensor model tells us how weak.

Sensor models

A sensor model answers the question: if the true state were xx, what readings would I expect? We write it as a conditional probability density

p(z∣x)p(z \mid x)

read as “the probability of reading zz given that the state is xx”. The vertical bar means “given” or “assuming”. For our ultrasonic sensor, (1) and (2) give

p(z∣d)=N(z; d, σ(d)2)p(z \mid d) = \mathcal{N}\big(z;\ d,\ \sigma(d)^2\big)

which says: if the gate is at distance dd, readings are Gaussian, centred on dd, with spread σ(d)\sigma(d).

Likelihood: turning the question around

The sensor model looks forward, from a known state to possible readings. But the robot faces the reverse problem. It has the reading z=2.4z = 2.4 m and wants to know which true distances are believable.

So we fix the observed reading and ask, for each candidate true distance: if the gate were really there, how likely is the reading I actually got?

This quantity is the likelihood of the candidate:

L(d)=p(zobs∣d)L(d) = p(z_{\text{obs}} \mid d)

It is the same formula as the sensor model, but now zz is fixed at what we observed and dd varies. Let’s compute it for the five candidates:

 true distance d |   σ(d) | likelihood L(d) | relative to best
           2.2 m | 0.086 |           0.310 | 0.07
           2.3 m | 0.089 |           2.384 | 0.55
           2.4 m | 0.092 |           4.336 | 1.00
           2.5 m | 0.095 |           2.413 | 0.56
           2.6 m | 0.098 |           0.507 | 0.12
<Figure size 770x396 with 1 Axes>

Figure 1:The likelihood of every possible true distance, given the single reading z = 2.4 m. Distances near 2.4 m explain the reading well; 2.2 m and 2.6 m explain it poorly. The dots are the five candidates from the table.

A distance of 2.4 m explains the reading best, 2.3 m and 2.5 m explain it about half as well, and 2.2 m or 2.6 m explain it poorly, roughly 7–12% as well as 2.4 m does.

Two points are important:

  • A likelihood is not a probability of the state. The likelihoods above do not add up to 1, and they do not say “the gate is at 2.4 m with probability 0.43”. They only compare how well each candidate explains the evidence.

  • To get probabilities, we need one more ingredient: what the robot believed before the reading. Combining the two is the job of Bayesian inference, in Section 2.3.