Control systems · also Electrical engineering
Noise and filtering
Every sensor reading contains some noise: small random variations around the true value. A filter combines several readings to reduce it. A moving average takes the mean of the last few samples. An exponential filter keeps a running estimate and nudges it a fixed fraction of the way towards each new reading, which needs very little memory. Both smooth noise, but both also add delay: the stronger the smoothing, the longer the filtered value takes to follow a real change. Choosing a filter is a trade-off between smoothness and lag.
Why it mattersFiltering a noisy distance sensor stops a robot's speed from jittering, but filtering too much makes it react late to obstacles.