Least-squares line fitting: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) No edit summary  | 
				A WASSERMANN (talk | contribs) No edit summary  | 
				||
| Line 24: | Line 24: | ||
// where x_i, y_i is the position of point p_i  | // where x_i, y_i is the position of point p_i  | ||
// y is equal to the zero vector.  | // y is equal to the zero vector.  | ||
var M = [], y= [  | var M = [], y= [], MT, B, c, z, n;  | ||
n = p.length;  | n = p.length;  | ||
for (i=0;i<n;i++) {  | for (i=0;i<n;i++) {  | ||
     M.push([  |      M.push([p[i].X(), p[i].Y()]);  | ||
    y.push(1.0);  | |||
}  | }  | ||
| Line 46: | Line 47: | ||
//var r = Math.sqrt(z[2]+xm*xm+ym*ym);  | //var r = Math.sqrt(z[2]+xm*xm+ym*ym);  | ||
brd.create('line',z);    | brd.create('line',[1,z[0], z[1]]);    | ||
</jsxgraph>  | </jsxgraph>  | ||