Linear Regression

버전 1.0.0.0 (1.52 KB) 작성자: michael scheinfeild
linear regressing fit to line in the method of gradient descent for minimizing square error
다운로드 수: 2K
업데이트 날짜: 2010/1/30

라이선스 보기

based on
http://www.mathworks.com/matlabcentral/fileexchange/6716-orthogonal-linear-regression

http://en.wikipedia.org/wiki/Linear_least_squares

http://www.youtube.com/watch?v=5u4G23_OohI

use
%prepare some data
xdata=0:0.1:10;
ydata=2+7*xdata+6*randn(size(xdata));

%compare with normal linear regression
p0=polyfit(xdata,ydata,1);
yy0=polyval(p0,xdata);
%plot to compare data with linear fits

%% my func
xi = 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')

인용 양식

michael scheinfeild (2025). Linear Regression (https://www.mathworks.com/matlabcentral/fileexchange/26538-linear-regression), MATLAB Central File Exchange. 검색 날짜: .

MATLAB 릴리스 호환 정보
개발 환경: R14
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0