TrackedVariables have a built-in "average" command that calculates the average for STAT_TYPE_LEVEL (weighted by time) and STAT_TYPE_TIME_SERIES (unweighted) TrackedVariables.
It would be really helpful if these two types of TrackedVariable also supported calculating the Standard Deviation of the data points.