From 3dc889763461b992740f63763248de5d915b1902 Mon Sep 17 00:00:00 2001 From: neingeist Date: Thu, 2 Oct 2014 22:32:56 +0200 Subject: [PATCH] Compute cost for multiple variables --- ex1/computeCostMulti.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ex1/computeCostMulti.m b/ex1/computeCostMulti.m index 5f59913..22e462b 100644 --- a/ex1/computeCostMulti.m +++ b/ex1/computeCostMulti.m @@ -13,7 +13,11 @@ J = 0; % Instructions: Compute the cost of a particular choice of theta % You should set J to the cost. +predictions = X * theta; +errors = predictions - y; +squared_errors = errors .^ 2; +J = 1/(2*m) * sum(squared_errors); % =========================================================================