Code to calculate root-mean-squared-error