Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hackassin
GitHub Repository: hackassin/Coursera-Machine-Learning
Path: blob/master/Week 2/Programming Assignment-1/normalEqn.m
626 views
1
function [theta] = normalEqn(X, y)
2
%NORMALEQN Computes the closed-form solution to linear regression
3
% NORMALEQN(X,y) computes the closed-form solution to linear
4
% regression using the normal equations.
5
6
theta = zeros(size(X, 2), 1);
7
8
% ====================== YOUR CODE HERE ======================
9
% Instructions: Complete the code to compute the closed form solution
10
% to linear regression and put the result in theta.
11
%
12
13
% ---------------------- Sample Solution ----------------------
14
theta = pinv(X'*X) * (X'*y);
15
% -------------------------------------------------------------
16
17
18
% ============================================================
19
20
end
21
22