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 6: | Line 6: | ||
<jsxgraph width="600" height="600">  | <jsxgraph width="600" height="600">  | ||
var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,5,5,-5], keepaspectratio:true, axis:true});  | var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-5,5,5,-5], keepaspectratio:true, axis:true});  | ||
var i, p = [], angle, xr, yr, delta = 0.  | var i, p = [], angle, xr, yr, delta = 0.0;  | ||
// Random points are constructed which lie roughly on a line  | // Random points are constructed which lie roughly on a line  | ||
| Line 44: | Line 44: | ||
brd.create('circle',[ [xm,ym], r]);    | brd.create('circle',[ [xm,ym], r]);    | ||
alert([xm,ym,r].toString());  | |||
/*  | /*  | ||
// Having constructed the points, we can fit a line described    | // Having constructed the points, we can fit a line described    | ||
Revision as of 11:17, 7 November 2010
This little JXSGraph application finds the line - described by homogeneous coordinates [a,b,c] - that minimizes
- [math]\displaystyle{ \sum_{i=1}^n (ax_i+by_i+cz_i)^2. }[/math]
 
Coming soon...