Skip to content

Instantly share code, notes, and snippets.

@taterbase
Created May 8, 2013 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taterbase/5538459 to your computer and use it in GitHub Desktop.
Save taterbase/5538459 to your computer and use it in GitHub Desktop.
function J = costFunctionJ(X, y, theta)
% X is the "design matrix" containg our training examples
% y is the class labels
m = size(X,1); % numbedr of training examples
predictions = X*theta; % predictions of hypothesis on all m examples
sqrErrors = (predictions - y) .^2; % squared errors
J= 1/(2*m) * sum(sqrErrors);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment