Fix the stddev/mean computations

They have been garbled since commit e5f5a0d30e91d94b0563a0c92bbc2a71b4361daa, leading to a mean that was not in the min/max range and to zero-divide in the stddev computation, among others.