Calculating Least Squares Method