[PD] calculating running average

Johannes M Zmoelnig zmoelnig at iem.kug.ac.at
Sun Sep 16 18:19:17 CEST 2001

On Sat, 5 Aug 2000, Jim Ruxton wrote:

> I'm wondering if someone could give me some advice for capturing a running
> average of incoming numbers. ie capture 10 numbers / 10 take in the next
> number and drop the first one  etc. I'm still a newbie so there is probably
> an easy way to do this that I can't see. Thanks!
> Jim

if you need your moving average filter for reasonably small numbers only
(like 10) and you only need it for this number of values (10; but not 11
or 4) you can build a moing average with elemnts like "t f f", "f", "+"
and "/".
the easiest moving average (vor only 2 values) would be a

|t f f|
\   /
 \ /
 / \  
 |* 0.5|

by just cascading this, you can build a moving average for floats for any 

if you are lazy or need a filter that supports various window-sizes, you
might want to try out the "mavg"-object in the zexy-external.



More information about the Pd-list mailing list