Quantcast
Channel: MATLAB Central - File Exchange - tag:"least squares"
Viewing all articles
Browse latest Browse all 522

Linear Regression

$
0
0
265382010-01-30T06:12:39Z2010-01-30T06:12:39Z

based onhttp://www.mathworks.com/matlabcentral/fileexchange/6716-orthogonal-linear-regressionhttp://en.wikipedia.org/wiki/Linear_least_squareshttp://www.youtube.com/watch?v=5u4G23_OohIuse%prepare some dataxdata=0:0.1:10;ydata=2+7*xdata+6*randn(size(xdata));%compare with normal linear regressionp0=polyfit(xdata,ydata,1);yy0=polyval(p0,xdata);%plot to compare data with linear fits%% my funcxi = xdata';yi=ydata';theta_st=[ 0 0];nsteps=150;mindiff=1e-3;learnrate=1e-5;[theta_out,err_vec,theta_vec] = gradient_descent_opt(xi,yi,theta_st,nsteps,mindiff,learnrate);ygrad=theta_out(1)+theta_out(2)*xdata;figure(1)plot(xdata,ydata,'.',xdata,ygrad,xdata,yy0,':');xlabel('x');ylabel('y')title('. org ,: polyval, r my')


Viewing all articles
Browse latest Browse all 522

Trending Articles