Calculation of averages and standard deviation