Get the mean of many numbers

The mean object provides the average (mean) value of a list of numbers. Or, as it gets individual numbers it continually sends out the running average. If you want to know the average value of a stream of data during a certain period of time, clear the mean object’s memory, start directing the data stream to it (e.g., open a gate), capture its output into a variable (but don’t do anything with the output yet), then at the end of the period of time close the gate and get the value that’s in the variable.

This example demonstrates that technique. It uses a simulation of a stream of data (as might be coming from a continuous controller or a voltage source), and shows how to capture the average value of that stream over a period of 15 seconds.

Chapter: 
Keywords: