Array builtins are designed to supplement the array capabilities of the software. Use these builtins to find the sum, the standard deviation, or the mean across dimensions of arrayed entities. Some of these builtins can also be used for non-arrayed entities.
This section describes the following builtins:
The MEAN builtin calculates the arithmetic mean across the elements in the array or expression. The calculation is defined as the sum of the elements, divided by the number of elements in the array.
The MEAN calculation can be done in either an arrayed or a non-arrayed converter or flow.
To report the mean across a subset of the dimensions of the arrayed input entity, specify an asterisk (*) to include all of the elements across a dimension. You can report the arrayed entity's mean in either an arrayed or a non-arrayed converter or flow.
Examples:
Average Salary for Employees = MEAN(Salaries)
Average Salary for Employees in Boston = MEAN(Salaries[Boston,*])
The RANK builtin gives the numerical index of the arrayed variable with the given rank number when the array is sorted in ascending order. The optional secondary sort arrayspecifies the secondary sort field for entities with the same value. The secondary sort array must be the same size as the arrayed variable or the secondary sort will not occur (this is only enforced when you simulate the model, so you will not be warned).
Example:
If array A contains the values { 6, 2, 8, 5 }
RANK(A, 2) will equal 4 (i.e., the fourth element of array A is the second smallest value)
Using RANK causes the specified array to be sorted once each time step (DT). For multi-dimensional arrays, you can pass one or more dimensions of the array to return the rank of a subset of the array.
Example:
Rank(Salaries[Boston,*],2) returns the rank of the second smallest salary in Boston.
Use the SELF builtin in conjunction with the SIZE and PREVIOUS builtins to refer to the current entity.
The SIZE builtin gives the number of elements in the array or expression.
Note: You can also use the SIZE builtin to report the length of a queue.
To get the size or dimension size of an array holding the equation, use the SELF builtin.
Examples:
SIZE(SELF) gives the number of elements in this array.
SIZE(SELF[*, 1]) gives the size of the first dimension of this array.
SIZE(SELF[1, *]) gives the size of the second dimension of this array.
SIZE (<queue>) returns the total number of elements contained in the specified queue discrete stock.
SIZE (<conveyor>) returns the total number of slots contained in the specified conveyor discrete stock.
The STDDEV builtin calculates standard deviation for all the elements in the array or expression.
To report the standard deviation across a subset of the dimensions of an arrayed input entity, specify an asterisk (*) to include all of the elements across a dimension. You can report the arrayed entity's standard deviation in either an arrayed or a non-arrayed converter or flow.
Example:
Standard Deviation of Salary in Boston= STDDEV(Salaries[Boston,*])
The SUM builtin calculates the sum of all the elements in the array or expression.
To report the sum across a subset of the dimensions of an arrayed input entity, specify an asterisk (*) to include all of the elements across a dimension. You can report the arrayed entity's sum in either an arrayed or a non-arrayed converter or flow.
Example:
Total Salary for Employees in Boston = SUM(Salaries[Boston,*])