Code covered by the BSD License  

Highlights from
Regression through least square(normal equations)

Regression through least square(normal equations)

by

 

20 Feb 2014 (Updated )

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