fixed counting of sample variance