calculation of mean deviation for grouped data