Finished second part of task 1

This commit is contained in:
Sam Perry
2016-10-19 09:37:50 +01:00
parent b9486fc422
commit 676b75d0b6
+3 -3
View File
@@ -26,7 +26,7 @@ function theta = gradient_descent(X, y, theta, alpha, iterations, do_plot)
sigma = 0.0;
for i = 1:m
hypothesis = X(i, 1) * theta(1) + X(i, 2) * theta(2);
hypothesis = calculate_hypothesis(X, theta, i);
output = y(i);
sigma = sigma + (hypothesis - output);
end
@@ -38,7 +38,7 @@ function theta = gradient_descent(X, y, theta, alpha, iterations, do_plot)
sigma = 0.0;
for i = 1:m
hypothesis = X(i, 1) * theta(1) + X(i, 2) * theta(2);
hypothesis = calculate_hypothesis(X, theta, i);
output = y(i);
sigma = sigma + (hypothesis - output) * X(i, 2);
end
@@ -68,4 +68,4 @@ function theta = gradient_descent(X, y, theta, alpha, iterations, do_plot)
disp 'Press enter!';
pause;
end
end