Regression through least square(normal equations)
by
Koteswar Rao Jerripothula
20 Feb 2014
(Updated
20 Feb 2014)
Basic least square algorithm (Normal equations) for regression

least_square(x,y)

function [ theeta ] = least_square(x,y)
%UNTITLED6 Summary of this function goes here
% Detailed explanation goes here
% this is file for regression
% x should be provided as mXn matrix where m=number of features and
% n=number of samples
%y should be provided as row vctor
% of features, you will obtain output theeta as column vector
% and
m=size(x,2);
t=ones(m,1);
x=[t,x'];
y=y';
theeta=inv(x'*x)*x'*y;
end


Contact us