Commented the LeastSquaredRegression function so that it is easier to understand