constructs the gradient for linear regression.
constructs the gradient for linear regression. the Pos type is (Double, IndexedSeq[Double]) note the LAST element in the weights is the constant term. and note that the length of the IndexedSeq in the tuple is one less than the weights (we don't carry the constant term)