Variance formula for grouped data