User Tools

Site Tools


Running mean

The running mean will integrate a given input over time and return the mean value. In versions prior to Ecolego 6, this functionality was incorporated in the recorder block.

When creating a running mean block, you must specify either the name of the object to integrate, or an expression to integrate. This is called the “Target expression”.

The running mean block makes heavy use of discrete events. By selecting discrete events you can tell the block when to start or stop the integration or when you want to reset the integration.

Creating a running mean block

From the Projects window

  • Expand the Project to which you wish to add the running mean by clicking the + symbol next to it. Right-click on ‘Blocks’, or a sub-system in ‘Blocks’, and select Running mean from the pop-up menu.

From the Matrix window

  • Right click an empty diagonal cell of the matrix and select Running mean from the the pop-up menu.

From the Blocks window

  • Place the mouse anywhere over the area of this window and right-click on it. Select New | Running mean from the pop-up menu, or
  • In the title bar, select Running mean from the Type drop-down list and click on the New button.

Editing a running mean block

NoteMost block properties can be edited directly in the Blocks window.

The block editor is shown by right-clicking the block in a window and selecting Edit. In the Blocks window, you can also show the block editor by selecting the block and clicking the Edit button, or by double-clicking the right-most “validation” column of the block.

The block editor has three tabs:


This page lets you edit basic properties such as name, sub-system and base unit. See editing properties for more information.


This page lets you edit the visual properties of the block in the matrix window and graph window. See editing appearance for more information.


Dimension - You can specify the dimension of the block by using the Type drop down list. Depending on the dimension the index drop down lists are activated.

Data - The data table let you specify index specific properties like target expression and start/stop recording events.

  • Indices - For blocks that are non-scalar, the first columns will specify indices from the index lists. This allows you to specify different expressions for different indices.
  • Target expression - Enter either just the ID of an object to integrate, or enter a full expression.
  • Start recording - Select a discrete event or time event which will indicate when the integration should start.
  • Stop recording - Select a discrete event or time event which will indicate when the integration should stop. The last value calculated will be saved.
  • Reset - Select a discrete event or time event which will trigger a reset. The value of the running mean will then be reset to the current value of target expression, and will start a new running mean calculation, starting from the input reset point.
  • Information - By using the Table control button you can display more columns that will help you document your model.

*Note that if the user has put both Reset and Stop to the Running mean, Stop will have the priority.
*If Star/Stop/Reset are left empty, running mean will calculate from the Time point 0 until the end of the Simulation.

Example: Running mean

Consider a model for contamination of air, where we want to consider the average dose received by a person visiting the area between may and august.

Let us assume that the current concentration in air is given by an expression C_air, the time (may) when the person enters the area is given by parameter t_enter and that the time (august) when the person leaves the area is given by parameter t_leave.

First create a discrete event named Event_enter which will start the integration at t = t_enter. The values given to this block are:

Property Value
Left expression time
Right expressiont_enter

Create another discrete event Event_leave which will stop the integration at t = t_leave, where the values are the same as for the first event but where t_leave is used instead of t_enter.

Create a running mean block and give it the following values:

Property Value
Target expressionC_air
Start recording Event_enter
Stop recording Event_leave

See also

running_mean.txt · Last modified: 2022/06/23 13:23 by mina