Calculate totals and statistics for an array
Summarize several balances with the appropriate aggregation.
Optional extension. It is not required to complete the core path.
Goal: Summarize several balances with the appropriate aggregation.
Before you start: The number Actor; return to this extension when you use arrays.
Optional extension. Finish the core path first, then return when you need this capability.
The idea you will use
Sum and Average answer different questions. Choose the aggregation that represents your need.
Predict before running
Does replacing 50 with 100 change the minimum of 10, 20, 30, 40, 50?
Build and check
Now you will work with several numbers at once. Continue in BP_MiNumero and use a variable of your own.
- Create a variable Values of type Scientific Number. Change its container to Array and compile.
- In its default values, add five elements with Base 10, 20, 30, 40, and 50; leave Exponent at 0. You can also connect five Make Scientific Number nodes to a Make Array.
- Drag a Get of Values into the graph and connect the array to each operation in the table, testing one at a time.
- Connect their execution pins if they have them, and check success/error before displaying the result.
| Operation | Result with 10, 20, 30, 40, 50 | Result after changing 50 to 100 |
|---|---|---|
| Sum of Array | 150 | 200 |
| Average of Array | 30 | 40 |
| Min of Array | 10 | 10 |
| Max of Array | 50 | 100 |
- Stop Play, change the last element to 100, and repeat all four operations.
When finished: the sum and average should reflect the array change; the minimum should remain 10.
Check your reasoning
See the explanation
The minimum stays 10. The sum becomes 200 and the average 40.
Your turn: Add a value and calculate the sum and average by hand before running.
Ready to continue when: you can justify the aggregation and verify its result.
Progress is saved only in this browser and carries over when you switch language.