Skip to content

Instantly share code, notes, and snippets.

@katsu1110
Last active March 31, 2017 09:35
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 katsu1110/1d1055001e74620618aef8fc2f832b57 to your computer and use it in GitHub Desktop.
Save katsu1110/1d1055001e74620618aef8fc2f832b57 to your computer and use it in GitHub Desktop.
数学の苦手なバイオの学生がCourseraの機械学習コースを修了して気づいたこと ref: http://qiita.com/katsu1110/items/423fc9ac567710a1bd9b
% Compute covariance matrix
sigma = (X'*X)/size(X,1);
% Singular value decomposition
[U,S,V] = svd(sigma);
% Compute covariance matrix
sigma = (X'*X)/size(X,1);
% Singular value decomposition
[U,S,V] = svd(sigma);
J(\theta) = \frac{1}{2m} (X\theta - y)^{\mathrm{T}}(X\theta - y)
J = 0;
for i = 1:m
for k = 1:n
J = J + (X(i,k)*theta(k) - y(i))^2;
end
end
J = J/(2*m);
J = 0;
for i = 1:m
for k = 1:n
J = J + (X(i,k)*theta(k) - y(i))^2;
end
end
J = J/(2*m);
J = ((X*theta - y)'*(X*theta - y))/(2*m);
J = ((X*theta - y)'*(X*theta - y))/(2*m);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment