Optimising the calculation of statistical functions. (2017)