Calculating the sample variance