EETimes

Embedded Systems November 2000 Vol13_12

Issue link: http://dc.ee.ubm-us.com/i/71849

Contents of this Issue

Navigation

Page 101 of 189

PHIL EKSTROM Better Than Average Some avet'ages are better than others. In particular, the median may give more useful results than the mean in some circumstances. magine that you we re building a robot to find fire or glowing embers in the dark. You would proba- bly install a couple of sensors to detect red light and command the robot to move in the direction from which the brightest light was coming. Now imagine that you have to use noisy detectors. The usual answer would be to average a number of successive readings, looking for the steady glow behind all that noise. Now let's make it all work in a lightning storm. You don't know how close you will be either to the fire or to the light- ning- either one may be brighter. A flash might be much brighter, or you might be close to th e fire and the bolts may be distant, but you know one crucial fact: lightning will fl ash only now and the n; the sky will go dark in between those flashes. Fire may fli cker, but it is significantly diffe rent in giv- ing substantial light nearly all the time. In the language of statis tics, the lightning has hung a fat tail on o ur probabili ty distribution. My favo ri te tools fo r handling tl1at are order statistics like tl1e median . The problem wi th a simple running ave rage or any linear fi lter in this kind of situation is that it has tl1e wrong kind of memoqr. If its j ob is to combine N observations, then the effect of a single large data value will be significant for some- 100 NOVEMBER 2000 Embedded Systems Programming thing like N sample times-longer if tl1e filter does not have finite impulse response, the flash is a bright one, and the firelight is dim. Dming that time, our robot would go trundling off towards the flash and igno re the fi re. Instead, we should apply a non-linear filter, the nmning median. To compute the median , create a sorted list of data and pick ou t tl1e middle entry. The advantage is tl1at the process systematically ignores any unusually large and small data elements. These extreme elemen ts turn up near the ends of tile sorted list, and are only counted. If a few ofthem are unreasonably extreme, it doesn't matter. Once the brightness of a lightning fl ash exceeds tile magnitude of a typical measurement, it can be as bright as it like and can- not furth er affect the resul t. If someone walks between the robot and the fire, blocking the view for a moment, it ignores that too. The wonder ful thing is tl1at this all hap- pens automatically. You don't need to make an advance guess about how bright eithe r tile glow o r the flash will be. Averages There are some good reasons why the mean, our fa miliar average, is ordinarily used instead of the median. One is the relative difficulty of forming tl1at sorted list instead of just

Articles in this issue

Archives of this issue

view archives of EETimes - Embedded Systems November 2000 Vol13_12