Added mean squared sum calculation.