Computing the mean: accuracy and speed

One of the very first programming “tricks” I learned was that you could compute both the mean and the standard deviation with a single pass through the data values. However, the single-pass expression leads to larger roundoff errors than the two-pass expression, which limits its usefulness.