ツール? Ubuntu12.04の問題 †
CentOSでのインストール †yum --enablerepo=rpmforge install p7zip yum install icoutils ライブラリ †ファイル書き出し †
最適化 †global verbose; verbose = true; %Load Data mx = [0:0.1:10]'; vy = mx.*mx; %Set Function function vY = myfun( mX, vP ) a=vP(1); b=vP(2); c=vP(3); vY = a*mX(:,1).*mX(:,1) + b*mX(:,1) + c; endfunction %Inital Values vp0 = [0.9; 0; 0]; %NLS opt = optimset('Display', 'iter'); [vyhat vp] = leasqr( mx, vy, vp0, @myfun ); ssr = (vy-vyhat)'*(vy-vyhat); disp('========== RESULTS =========='); vp ssr %Output Results myfile = fopen('output_nls.txt', 'w'); fprintf(myfile, '========== RESULTS ==========\n'); fprintf(myfile, 'vp = %12.7f\n', vp); fprintf(myfile, 'SSR = %12.7f\n', ssr); fclose(myfile);
clear #global verbose; verbose = true; %Load Data mx = [0:0.1:10]'; global vy_tobe = mx.*mx; %Set Function function vY = myfun( mX, vP ) global vy_tobe; a=vP(1); b=vP(2); vY = a*mX + b - vy_tobe; endfunction %Inital Values vp0 = [10; 0]; %NLS opt = optimset('Display', 'iter'); [vyhat vp] = leasqr( mx, zeros(size(mx)), vp0, @myfun ); disp('========== RESULTS =========='); vp vyhat plot(mx, vy_tobe); hold on; plot(mx, vp(1)*mx+vp(2)) hold off; clear #global verbose; verbose = true; %Load Data mx = [0:0.1:10]'; global vy_tobe = 5*rand(size(mx)) + mx; %Set Function function vY = myfun( mX, vP ) global vy_tobe; a=vP(1); b=vP(2); vY = a*mX + b - vy_tobe; # vY(vY<0)=10*vY(vY<0); #上 vY(vY>0)=10*vY(vY>0); #下 endfunction %Inital Values vp0 = [-100; 0]; # だいぶエクストリームな初期値(0.98,0.44とかが本当の値) %NLS opt = optimset('Display', 'iter'); [vyhat vp] = leasqr( mx, zeros(size(mx)), vp0, @myfun ); disp('========== RESULTS =========='); vp vyhat plot(mx, vy_tobe); hold on; plot(mx, vp(1)*mx+vp(2)) hold off; |