computing variance and mean slightly different

Should be more robust to float precision problems (and unbiased
estimate!)