Aggregate numbers¤
The aggregateNumbers plugin applies an aggregation operator to the sequence of input values.
The allowed aggregation operators are sum (+), product (*), minimum (min), maximum (max)
and average (average).
Notice that the “number” Infinity is allowed as input and to be expected as possible output. For example, the
minimum of 1 and Infinity is 1, but its maximum, its sum, its product and its average are Infinity.
The aggregation operations of this plugin are exclusively numerical. They are exactly the expected operations upon a list or sequence of numbers, in order to ‘aggregate’, ‘reduce’, ‘sum’ or ‘join’ them.
The computations are done with
double-precision floating-point numbers.
This means that e.g. integers such as 1 or 2 will be converted to 1.0 and 2.0.
This also regards the output of the operation, as in 1 + 1 leading to 2.0 rather than the integer 2.
Only the five listed aggregation operations are allowed (and understood) by this numeric transformer plugin. If an invalid operation is given, an error or exception will occur. On the other hand, if any values aren’t (valid) numbers, they will be ignored.
Examples¤
Notation: List of values are represented via square brackets. Example: [first, second] represents a list of two values “first” and “second”.
Example 1:
-
Parameters
- operator:
+
- operator:
-
Input values:
[1, 1, 1]
-
Returns:
[3.0]
Example 2:
-
Parameters
- operator:
*
- operator:
-
Input values:
[2, 2, 2]
-
Returns:
[8.0]
Example 3:
-
Parameters
- operator:
min
- operator:
-
Input values:
[1, 2, 3]
-
Returns:
[1.0]
Example 4:
-
Parameters
- operator:
max
- operator:
-
Input values:
[1, 2, 3]
-
Returns:
[3.0]
Example 5:
-
Parameters
- operator:
average
- operator:
-
Input values:
[1, 2, 3]
-
Returns:
[2.0]
Example 6:
-
Parameters
- operator:
+
- operator:
-
Input values:
[1.0, Infinity]
-
Returns:
[Infinity]
Example 7:
-
Parameters
- operator:
*
- operator:
-
Input values:
[1.0, Infinity]
-
Returns:
[Infinity]
Example 8:
-
Parameters
- operator:
min
- operator:
-
Input values:
[1.0, Infinity]
-
Returns:
[1.0]
Example 9:
-
Parameters
- operator:
max
- operator:
-
Input values:
[1.0, Infinity]
-
Returns:
[Infinity]
Example 10:
-
Parameters
- operator:
average
- operator:
-
Input values:
[1.0, Infinity]
-
Returns:
[Infinity]
Example 11:
-
Parameters
- operator:
+
- operator:
-
Input values:
[1, Whatever]
-
Returns:
[1.0]
Example 12:
-
Parameters
- operator:
*
- operator:
-
Input values:
[1.0, Whatever]
-
Returns:
[1.0]
Example 13:
-
Parameters
- operator:
min
- operator:
-
Input values:
[1.0, Whatever]
-
Returns:
[1.0]
Example 14:
-
Parameters
- operator:
max
- operator:
-
Input values:
[1.0, Whatever]
-
Returns:
[1.0]
Example 15:
-
Parameters
- operator:
average
- operator:
-
Input values:
[1.0, Whatever]
-
Returns:
[1.0]
Example 16:
-
Parameters
- operator:
notAnOperator
- operator:
-
Input values:
[1.0, 2.0, 3.0]
-
Returns:
[]
Parameter¤
Operator¤
The aggregation operation to be applied to all values. One of +, *, min, max, average.
- ID:
operator - Datatype:
string - Default Value:
None
Advanced Parameter¤
None
Related Plugins¤
- numOperation — The Aggregate numbers plugin and the Numeric operation plugin both reduce a sequence of numeric inputs to one result, overlapping on addition and multiplication. Aggregate numbers ignores non-numeric values and adds min, max, and average, while Numeric operation fails on non-numeric input and adds subtraction and division.
- numReduce — The silent discard of non-numeric values in Aggregate numbers is not a cleaning step — non-numeric characters within a value leave the entire value unparseable. Numeric reduce strips those characters from each value, exposing a digit sequence that Aggregate numbers can then include in its computation.