I like this...thanks. Pictures always help.... Mark Skeels Engineer Competition Electronics, Inc. TEL: 815-874-8001 FAX: 815-874-8181 www.competitionelectronics.com RussellMc wrote: >> So you can give it new names, but you're really just computing the >> average of the last N samples. (now, if there's a lot of difference >> in samples, you might notice that recent samples have more "weight" >> than older samples, but that's just a little detail...) >> =20 > > I'll quibble gently. > I know you know, and your comment further reflects the knowledge, but > I think a better way of putting it would be something like: > > 'The "average" of ALL prior samples + the latest sample, with the new > sample being given a "weighting" of 1/Nth of the new "average" '. > > Note that "average" here does NOT have the same meaning as 'average' > usually does. > Olin explicitly addressed this with his signature "do you really want > to keep all N sample". I didn't think so". > Readers are free to decide whether his "I didn't think so" is valid > for them - and in many cases it will be - but by making this decision > you have a MUCH different beast than an average over N samples. > > What this is, as has been noted, is a single pole exponential function. > > With a true N samples average you start dropping off whole prior > samples N periods after they have happened. With the exponential > function you drop off only an Nth of the effect of a sample N+1 ago. > > That they can be very different in response is easily seen by graphing > some typical step responses. I just produced some Excel graphs with > varying N lengths and step functions of Y samples =3D 1 and all others = =3D > 0. > > A graph of only one such is attached. > Blue curve is input step. > Octarine curve is true average > Yellow curve is exponential filter under discussion here. > > Do you think they are identical? I didn't think so :-). > > Whether this matters depends on application. Input function can make a > large difference. > > I have used the exponential filter extensively in the past BUT it has > such sluggish performance under some conditions when it is usually but > not always useful that I sometimes add ad hoc rules to it to modify > its behaviour. eg priming it with current sample value on input would > be one possibility (depending on input function). > > The exponential function has the advantage of starting up properly > from 1st sample whereas true averaging needs either a sliding length > for the 1st N samples or some other handling of its boundary > conditions. "Horses for courses". > > > Russell > =20 > > ------------------------------------------------------------------------ > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .