computes an arbitrary, statistically reproducible sum/average