pre-compute mean for speed

When working with large data sets some of the more complex statistics were calculating the mean of the set multiple times per data point.  Instead, the mean could be pre-computed outside the block.