ex1的提交,只贴添加内容
warmUpExercise.m
A = eye(5);
computeCost.m
J = sum((X*theta-y).^2); J = J/(2*m);
gradientDescent.m
theta = theta - alpha*X'*(X*theta - y)/m;
featureNormalize.m
for i = 1:size(X,2) mu(1,i) = mean(X(:,i)); end for i = 1:size(X,2) sigma(1, i) = std(X(:,i)); end for i = 1:size(X,1) for j = 1:size(X,2) X_norm(i,j) = (X(i,j)-mu(1,j))/sigma(1,j); end
computeCostMulti.m
J = (X*theta-y)'*(X*theta-y)/(2*m);
gradientDescentMulti.m
theta = theta - alpha*X'*(X*theta - y)/m;
normalEqn.m
theta = (pinv(X*X')*X)'*y