Files
lab/ds/25-1/r/6/mlclass-ex1/normalEqn.m
2025-12-19 19:39:34 +03:00

24 lines
671 B
Matlab

function [theta] = normalEqn(X, y)
%NORMALEQN Computes the closed-form solution to linear regression
% NORMALEQN(X,y) computes the closed-form solution to linear
% regression using the normal equations.
theta = zeros(size(X, 2), 1);
% ====================== YOUR CODE HERE ======================
% Instructions: Complete the code to compute the closed form solution
% to linear regression and put the result in theta.
%
% ---------------------- Sample Solution ----------------------
theta = inv(X' * X) * X' * y
% -------------------------------------------------------------
% ============================================================
end