Wednesday, July 20, 2016

Computing a Moving Average

Posted by Rick Kossik

GoldSim allows you to compute and display average outputs of any variable you are simulating.  For example, if you were using a daily timestep, you could compute monthly or annual values using a feature in GoldSim called reporting periods. These are defined in the Simulation Settings.

In some cases, however, you may want to compute a different kind of average – a moving average. For example, at any point in the simulation, you might want to reference the average value of a variable over the previous 10 days. GoldSim provides an easy way to do this.

Why would you want to compute a moving average?  As an example, consider a case where you are simulating a system that constantly adjusts (reacts to) one variable (e.g., a pumping rate from a pond) based on the value of some other varialble (a flow rate into the pond). If the flow rate was highly variable, you probably would not want to adjust the pumping rate based on the current (instantanteous value) of the flow rate (as the pumping rate would then also vary widely), but instead on the average value of that flow rate over some previous period (which will smooth the variations in the flow rate).

Mathematically, a moving average of X over some averaging time ATime is simply computed as follows:

That is, it is a time integral. GoldSim Stock elements (Reservoirs and Integrators) solve time integrals. Integrators are simplified versions of Reservoirs (although as we shall see, they provide some specialized features that Reservoirs do not).  In particular, Integrators provide the (optional) ability to compute a moving average.

An Integrator element looks lime this:

As you can see, the Integrator is a simplified version of the Reservoir:

  •  Both require an Initial Value.
  • The Integrator combines the Reservoir’s Addition Rate and Withdrawal Rate into a single Rate of Change.
  • The Integrator does not have a Lower Bound or an Upper Bound.

We can use one of the Integrator’s advanced capabilities to compute a moving average.
We can access these capabilities by pressing the More button:

As can be seen, the Integrator provides the ability to compute up to three moving averages. 

In the example below, we are averaging a stochastic signal (a streamflow), and computing a 30 day moving average and a 1 year moving average:

This adds two secondary outputs the the Integrator (Average.Month and Average.Year).

In this case, if we run the model and plot the results (the original signal and the two moving averages), it looks like this:

As can be seen, the moving average smooths the variations in the flow rate, and because it is backward-looking, shifts the peaks to the right (i.e., delays them).


  1. These complete moving service were great! Very reasonable pricing, conveyed numerous times while on the way so I could plan, labored really effectively, as well as didn't split a thing.

  2. They're very fast, cautious in addition to individual. These people understood these were on the time clock and may have drawn it, but didn’t, and everything have been moved. Car parking had been my personal obligation moving internationally to UAE learn more; nonetheless they have been really accommodating along with my personal short space.

  3. I'd be trampled if all sites gave articles like these awesome articles.tracks for skid steer

  4. Each time I used to always check blog posts within the first hours in the break of day, because I like to get information increasingly more.folding motorized wheelchair

  5. If somebody wants expert take on the main topic of blogging next I advise him/her to go to this site, continue the fussy job.Tina

  6. I have got the superb information from these blogs finally.good digital piano

  7. Nice answers in replace of the question with real point of view and explaining about that. Mark Curry