File:Linear least squares.svg

页面内容不支持其他语言。
這個文件來自維基共享資源
维基百科,自由的百科全书

原始文件(SVG文件,尺寸为512 × 621像素,文件大小:77 KB)


描述 Illustration of linear least squares.
日期 (UTC)
来源 self-made with MATLAB, tweaked in Inkscape.
作者 Oleg Alexandrov
授权
(二次使用本文件)
Public domain 我,本作品著作权人,释出本作品至公有领域。这适用于全世界。
在一些国家这可能不合法;如果是这样的话,那么:
我无条件地授予任何人以任何目的使用本作品的权利,除非这些条件是法律规定所必需的。
SVG开发
InfoField
W3C grn 
SVG的源代码为有效代码
Matlab Logo 
矢量图使用MATLAB创作。
源代码
InfoField

MATLAB code

% Illustration of linear least squares.
function main()
   
   % KSmrq's colors
   red    = [0.867 0.06 0.14];
   blue   = [0, 129, 205]/256;
   green  = [0, 200,  70]/256;
   yellow = [254, 194,   0]/256;
   white = 0.99*[1, 1, 1];
   gray = 0.2*white;
   
% Set up the grid and other parameters
   N = 100;
   A = -2.2; B = 2; 
   X = linspace(A, B, N);
   C=-4; D = 4;
   
   % Set up the figure
   lw = 4; % linewidth
   fs = 18; % font size
   figure(1); clf; hold on;
   set(gca, 'fontsize', fs);
   set(gca, 'linewidth', lw/2.5)
   hold on; grid on;

   % random numbers
   a = 1.1; b = 3.5; c = 1.4;
   M = 50;
   XX=linspace(A+0.3, B-0.3, M+1);
   Xr = 0*(1:M);
   Yr = Xr;
   for i=1:M
      r=rand(1);
      Xr(i) = XX(i)*r+XX(i+1)*(1-r);
      Yr(i) = a*Xr(i) + b + c*0.4*erfinv(2*rand(1) - 1);
   end

   myrad = 0.05;
   for i=1:length(Xr)
      ball(Xr(i), Yr(i), myrad, red);
   end


   % least squares fitting
   Yr = Yr';
   Mat = [Xr' (0*Xr+1)'];
   V=Mat'*Yr;
   V=(Mat'*Mat)\V;
   ae = V(1); be = V(2);   
   plot(X, ae*X+be, 'b', 'linewidth', lw);

   grid on;
   set(gca, 'GridLineStyle', '-', 'xcolor', gray);
   set(gca, 'GridLineStyle', '-', 'ycolor', gray);
   set(gca, 'XTick', [-2 -1 0 1 2]);


   axis equal;
   axis([-2, 2, 1, 6]);
   
   saveas(gcf, 'Linear_least_squares.eps', 'psc2'); % save as eps
   %plot2svg('Linear_least_squares.svg'); % save as svg

   
function ball(x, y, r, color)
   Theta=0:0.1:2*pi;
   X=r*cos(Theta)+x;
   Y=r*sin(Theta)+y;
   H=fill(X, Y, color);
   set(H, 'EdgeColor', 'none');

说明

添加一行文字以描述该文件所表现的内容

此文件中描述的项目

描繪內容

文件历史

点击某个日期/时间查看对应时刻的文件。

日期/时间缩⁠略⁠图大小用户备注
当前2009年2月22日 (日) 04:332009年2月22日 (日) 04:33版本的缩略图512 × 621(77 KB)Oleg AlexandrovNormal noise per Michael Hardy
2008年2月3日 (日) 00:582008年2月3日 (日) 00:58版本的缩略图412 × 523(75 KB)Oleg Alexandrovtweak width
2008年2月2日 (六) 20:272008年2月2日 (六) 20:27版本的缩略图401 × 523(75 KB)Oleg Alexandrovtweak bd box
2008年2月2日 (六) 19:542008年2月2日 (六) 19:54版本的缩略图4,609 × 5,778(75 KB)Oleg Alexandrovtweak bd box
2008年2月2日 (六) 19:502008年2月2日 (六) 19:50版本的缩略图4,609 × 5,778(75 KB)Oleg Alexandrovtweak bd box
2008年2月2日 (六) 19:412008年2月2日 (六) 19:41版本的缩略图754 × 945(74 KB)Oleg Alexandrovtweak text font size
2008年2月2日 (六) 19:382008年2月2日 (六) 19:38版本的缩略图55 × 69(74 KB)Oleg Alexandrovtweak text font size
2008年2月2日 (六) 19:152008年2月2日 (六) 19:15版本的缩略图303 × 411(74 KB)Oleg Alexandrov{{Information |Description=Illustration of linear least squares. |Source=self-made with MATLAB, tweaked in Inkscape. |Date=~~~~~ |Author= Oleg Alexandrov |Permission=See below |other_versions= }} {{PD

以下页面使用本文件:

全域文件用途

以下其他wiki使用此文件: