polyfit and LinearReg should have a side effect of populating a global variable, perhaps rError, representing the mean squared error of the fit.