Moving average

Use this forum to post Vensim related questions.
Post Reply
rogercai69
Junior Member
Posts: 5
Joined: Thu Mar 13, 2008 11:13 am

Moving average

Post by rogercai69 »

hi,

I am wondering, does Vensim provide any function to perform moving average. specifically speaking, I would like to take an average of a variable in its last three time steps. For example, Average =(Variable(t-3)+variable (t-2)+variable(t-1))/3, where t is time.

I would appreciate that any one could give me some clue.

roger
bob@vensim.com
Senior Member
Posts: 1107
Joined: Wed Mar 12, 2003 2:46 pm

Post by bob@vensim.com »

The following will work for any time window:

past quantity held = INTEG(value-delayed value,value*averaging time)
delayed value = DELAY FIXED(value,averaging time,value)
average value = past quantity / averaging time

This also continues to work when TIME STEP is smaller than one.
tomfid
Administrator
Posts: 3806
Joined: Wed May 24, 2006 4:54 am

Re: Moving average

Post by tomfid »

For many purposes it is both much easier and more realistic to use an exponentially-weighted moving average via the SMOOTH or SMOOTH3 functions however.
Post Reply