Implements the ComputCost method.

This commit is contained in:
julien Lengrand-Lambert
2015-11-12 18:03:16 +01:00
parent 6486a17e66
commit 84705edfc1

View File

@@ -13,9 +13,13 @@ J = 0;
% Instructions: Compute the cost of a particular choice of theta
% You should set J to the cost.
tmat = repmat( theta, 1, size(X, 1) );
h_theta = tmat' .* X;
temp_1 = (sum(h_theta,2) - y);
temp_2 = temp_1.^2;
J = 1/(2*m) * sum(temp_2);
% =========================================================================