ÿþ<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>The "Astronomy" framework. Nonlinear regression</title> </head> <body> <table summary="layout" width="550"> <tr> <td align="left" valign="center"> <a href="pointsindicators.html" target="_top"> <img align="middle" alt="Previous Page" border="0" height="26" src="images/back.jpg" width="26" /></a> <a href="index.html" target="_top"> <img align="middle" alt="Trail Contents" border="0" height="26" src="images/toc.jpg" width="26" /></a> <a href="containers.html" target="_top"> <img align="middle" alt="Next Page" border="0" height="26" src="images/forw.jpg" width="26" /></a></td> <td align="middle" valign="center"> <font size="-1"></font></td> <td align="right" valign="center"> <font size="-1"><a href="../search.html" target="_top"></a><br /> </font> </td> </tr> </table> <img align="bottom" alt="" height="8" src="images/blueline.gif" width="550" /> <br /> <h2> 10. Nonlinear regression</h2> <blockquote> <p> <b> <a href="regression.html#Architecture">10.1 Architecture of nonlinear regression software </a> </b> </p> <p> <b><a href="regression.html#SampleIt">10.2 Sample of iterative regression </a></b> </p> <p> </p> <p> <a href="regression.html#Sample1"><b>10.3 Sample of regression with loading selection at once. Identification of parameters of control system</b></a> </p> <a href="regression.html#Sample2"><b>10.4 Sample of regression with loading selection at once. Determination of 6D position of 3D object by photos</b></a> </blockquote> <h2> <a name="Architecture">10.1 Architecture of nonlinear regression software</a></h2> <blockquote> <p> This software solves the problem of <a href="http://en.wikipedia.org/wiki/Nonlinear_regression" target="_blank">nonlinear regression</a> using <a href="http://en.wikipedia.org/wiki/Least_squares" target="_blank">the least squares method</a>. <b>Nonlinear regression</b> in <a href="http://en.wikipedia.org/wiki/Statistics" title="Statistics">statistics</a> is the problem of fitting a model</p> <dl> <dd> <img alt="y = f(x,\theta) + \varepsilon" src="images/commonregreqn.jpg" /> </dd> </dl> <p> to multidimensional <i>x</i>,<i>y</i> data, where <i>f</i> is a <a href="http://en.wikipedia.org/wiki/Nonlinear" title="Nonlinear">nonlinear</a> function of <i>x</i> with regression parameters ¸.</p> <p> Nonlinear regression operates with selections. This sofware implements two methods of manipulation with selections. First method loads selection iteratively, i. e. step by step. Second one loads selection at once.</p> <p> &nbsp;The architecture of nonlinear regression software that uses interative regression is presented on the following scheme</p> <p> <img alt="Architecture" src="images/regressionarch.jpg" /> </p> <p> Let us describe components of this scheme. The iterator povides data-in&nbsp; selections <i>x</i> and <i>y</i> . The &nbsp;&nbsp;<em>y</em> is a <strong>Left part </strong>of fitting equations. The <strong>Transformation</strong> corresponds to nonlinear function <em>f</em>&nbsp; and generates <strong>Left part</strong> of fitting model. Processor coordinates all actions and corrects <strong>Regression parameters</strong>.</p> <p> The architeture of software with loading selection at once is presened on the following scheme</p> <p> <img alt="Architecture" src="images/regressionarchcomp.jpg"/> &nbsp;&nbsp;</p> <p> The processor compares<strong> </strong><span lang="EN-US"><strong>Calculated parameters</strong> with <strong>Selection</strong>, calculates residuals and then corrects <strong>Regression parameters</strong>.&nbsp; In these two schemas the <strong>Iterator</strong>, <strong>Selection</strong> and others are not concrete components. They are components those implements interfaces of <strong>Iterator</strong>, <strong>Selection</strong> etc. For example a <strong>Camera</strong> component may implement the <strong>Selection</strong> interface. </span> </p> </blockquote> <h2> <a name="SampleIt"> 10.2 Sample of iterative regression</a></h2> <blockquote> <p> Let us exhibit an example of nonlinear regression. Suppose that we should define regression parameters <img alt="Constants" src="images/regressionprm.jpg" /> of equations </p> <p> <img alt="Regression equations" src="images/regressioneqn.jpg" />&nbsp;</p> <p> by seclection of <img alt="Regression parameters" src="images/regressionvar.jpg" />.&nbsp;</p> <p> For this purpose we shall construct following scenario:</p> <p> <img alt="Scenario" src="images/regressionscn.jpg" /></p> <p> In this scenario a <strong>Query </strong>component performs a following SQL query:</p> <p> =============================</p> <p> SELECT f1.f1, f2.f2, x.x, y.y, z.z FROM f1, f2, x, y, z WHERE x.Id = f1.Idx AND y.Id = f1.Idy AND z.Id = f1.Idz AND f1.Idx = f2.Idx AND f1.Idy = f2.Idy AND f1.Idz = f2.Idz AND x.x IS NOT NULL AND x.x &lt; 1000</p> <p> ============================= .</p> <p> In this query parameters<img alt="Regression parameters" src="images/regressionvar.jpg" /> those correspond to&nbsp; x.x, y.y, z.z, f1.f1, f2.f2 respecively. Regression equations are presented in <strong>Formula</strong> component </p> <p> <img alt="Equations" src="images/regressioneqnui.jpg" />&nbsp;</p> <p> Regression parameters are marked in this component as constants</p> <p> <img alt="Regression constants" src="images/regressionconsts.jpg" />&nbsp;</p> <p> Other variables of equations are linked to columns of the query</p> <p> <img alt="Regression variables" src="images/regressionvars.jpg" />.</p> <p> A <strong>Processor</strong> <img alt="Processor" src="images/regressionbtn.jpg" />&nbsp; editor of properties is presented on the following picture:</p> <p> <img alt="Properties" src="images/regressionprops.jpg" />&nbsp;</p> <p> Using this editor we link equation and regression parameters to the variables of <strong>Formula </strong>and table objects.</p> <p> &nbsp; &nbsp;<a href="cfa/sampledatabase.zip">Click here to dowload database and additional files of the sample</a>.&nbsp; <a href="cfa/regression.cfa"> Click here to download this sample</a>.</p> </blockquote> <h2> <a name="Sample1">10.3 Sample of regression with loading selection at once. Identification of parameters of control system.</a></h2> <blockquote> This example is devoded to the situation when we have a control system with following transfer function <p> <img alt="Transfer finction" src="images/regressiontransferfunc.jpg" /> </p> <p> Parameters <img alt="Regression parameters" src="images/regressiontransferfuncpar.jpg" /> are unknown but we have an experimental gain-frequency characteristic. We wish to define unknown parameters. Then we shall construct the following scheme</p> <p> <img alt="Regression scheme" src="images/regressiontransferfuncscn.jpg" /> </p> <p> In this scheme the series component <strong>Graph</strong>&nbsp; implements the selection interface. The <strong>Formula</strong> implements regression parameters and transformation. The <strong>Graph</strong> property editor is presened on the following picture</p> <p> <img alt="Graph" src="images/regressiontransferfuncser.jpg" />&nbsp;</p> <p> The <strong>Graph</strong> presents &nbsp;the experimental gain-frequency characteristic. The <strong>Formula</strong> contains a formula of &nbsp;gain-frequency characteristic <img alt="Regression formula" src="images/regressiontransferfuncform.jpg" /> . In this formula we use <em>a</em>, <em>b</em>, <em>c </em>instead <img alt="Time constants" src="images/regressiontransferfunctimeconst.jpg" />&nbsp; The series component <strong>Graph</strong> also implements a <strong>vector parameters</strong> interface.&nbsp; It contains two vectors. First one is a &nbsp;vector of abscisses of series, second one is a vector of ordinates. These vectors are represented in the <strong>Formula</strong> component property editor</p> <p><img alt="Data-in" src="images/regressiondatain.jpg" /> </p> <p> The existence of these vectors on the&nbsp; <strong>Formula</strong> component property editor is caused by the information link <img alt="Information link" src="images/inflinkbtn.jpg" /> between <strong>Graph</strong> and <strong>Formula</strong>. At the above picture we have linked vector of abscisses with variable <em>p</em> of the formula <img alt="Regression formula" src="images/regressiontransferfuncform.jpg" />. It means that this formula calculates componentvise vector. Each component is calculation of this formula by substituting comonent of absciss instead <em>p</em>. To provide regression parameters <em>k</em>, <em>a</em>, <em>b</em>, <em>c</em> we have marked corresponding formula parameters as "Constants, aliases" <img alt="Constants" src="images/regressionaliases.jpg" /> . The property editor of the processor comopnent is represented at the following picture</p> <p> <img alt="Processor property editor" src="images/regressionprocpe.jpg" />&nbsp;</p> <p> At the right part of this editor we have a set of regression parameters. At the middle part we have a set of calculated parameters. The index "-1" of Formula_2 and Formula_3 means that these parameters are omitted. We can say the same about "Y" of <strong>Graph</strong>. Shortly middle and right part ot the editor means that we try to solve the following equation</p> <p> Formula_1 of Formula = Y of Graph.</p> <p> The left part means that sought quantities are <em>k</em>, <em>a</em>, <em>b</em>, <em>c </em>of the <strong>Formula</strong>. If we have fulfilled controls of this editor and pressed the <em>Accept</em> button at the left bottom side of the editor then the <strong>Processor</strong> is ready to perform regression. After pressing <em>Iterate</em> button <strong>Processor</strong> performs an iteration. In result Processor will show parameter Sigma0 that characterize residues. To perform following iteration press the <em>Iterate</em> button once again. We can find corrected values of regression parameters at <strong>Formula </strong>property editor <img alt="Parameters" src="images/regressionparval.jpg" /> . We can use these parameters for comparation results of regression with experimental data. To do this we should chagne argument <em>p</em> of the Formula. Before changing the data-in of the <strong>Formula</strong> looks like:</p> <p> <img alt="Before" src="images/regressionbefore.jpg" />&nbsp;</p> <p> After changing it should looks like:</p> <p> <img alt="After" src="images/regressionafter.jpg"/>&nbsp;</p> <p> Before this changing parameter <em>p </em>was a vector of abscisses of <strong>Graph</strong>. After it become a <em>Time</em>. The <strong>Graph</strong> component also implements interface g<em>raph function.</em> As a g<em>raph function</em> it is connected by <img alt="Series link" src="images/serieslnk.jpg" />&nbsp; to <strong>Formula</strong>. You can find it at the right part of <strong>Formula</strong> propery editor. After this chanfing you should click <em>Accept input parameters</em> and <em>Accept values buutons </em>and then the <em>Refresh</em> <img alt="Refesh button" src="images/refreshbtn.jpg" /> button on toolbar of main menu.</p> <p> <img alt="Series" src="images/seriesfrmed.jpg" />&nbsp;</p> <p> The index "0" means that the Graph is used as <img alt="f0" src="images/f0.jpg" /> in the <strong>Formula</strong>. We have three formulas</p> <p> <img alt="3 formulas" src="images/threeregformulas.jpg" />&nbsp;</p> <p> First one calculates theoretic gain-frequency characteristic, second one calculates phase-response characteristic. Third one calculates experimental gain-frequency characteristic represened in <strong>Graph</strong>. If you open property editor of <strong>Indication</strong> you can indicate this functions (see picture below)</p> <p> <img alt="Comaration" src="images/gainfreqgraph.jpg" />&nbsp;</p> <p> At this picture the <span style="color: red">red curve</span> is a theoretic gain-frequency characteristic and <span style="color: teal">green curve</span> is an experimental one.</p> <p> <a href="cfa/regressioncontrolsystem.cfa">Click here to download this sample</a>.</p> </blockquote> <h2> <a name="Sample2">10.4 Sample of regression with loading selection at once. Determination of 6D position of 3D object by photos.</a></h2> <blockquote> Let us consider the following problem. We have a set of photos of 3D object, obtained by a set of cameras. The 6D position of cameras are known and we have a 3D model of this object. We wish to find a 6D position of the object. This situation is presented in the following picture <p> <img alt="Main picture" src="images/contournavigationscn.jpg" />&nbsp;</p> <p> At this picture we have 3D object <img alt="3D Object" src="images/3dbtn.jpg" />. Its property editor </p> <p> <img alt="3D object" src="images/3dpe.jpg" /> </p> <p> enables us to set file name of 3D model of the object. We also have three cameras <img alt="Camera" src="images/camerabtn.jpg" /> . The property editor of camera is presented on the foloowing picture</p> <p> <img alt="Camera" src="images/camerape.jpg" />&nbsp;</p> <p> This camera is connected by the <img alt="Visible link" src="images/visiblelinkbtn.jpg" /> arrow with the <strong>Plane</strong>. It means that <strong>Plane</strong> is visible by this camera. &nbsp;These cameras have different 6D positions. So images of <strong> Plane</strong> are different. In&nbsp; the following picture another image is presented</p> <p> <img alt="Another image" src="images/anotherimage.jpg" />&nbsp;</p> <p> We also have three components <img alt="Contour" src="images/contourbtn.jpg"/> those performs navigation by contours of figures. Property editor of this component is presented in the following picutre</p> <p> <img alt="Contour" src="images/contourpe.jpg" />&nbsp;</p> <p> At this editor a <span style="color: red">red contour</span> corresponds to the bitmap downloaded by this component. A <span style="color: blue">blue contour</span> corresponds to&nbsp; a figure that is seen by the camera that is connected to this component by the <img alt="Contour link" src="images/contourlink.jpg"/> . In fact our task is a moving the plane for coincidence of these contours. After a set of iterations these contours looks like</p> <p> <img alt="Contour" src="images/contourlmatch.jpg"/>&nbsp;</p> <p> The plane is set to the <strong>State Frame</strong>. This frame is moved and its property editor is presented below</p> <p> <img alt="Frame" src="images/contourframepe.jpg" />&nbsp;</p> <p> The meaning of this editor is that coordinates X, Y, Z and components Q0, Q1, Q2, Q3 correspond to Formula_1, Formula_2, Formula_3, Formula_4, Formula_5, Formula_6, Formula_7 of <strong>Formula</strong>.respectively.&nbsp; The editor of&nbsp; <strong> Processor</strong> is presented on the following picture</p> <p> <img alt="Processor" src="images/contourprocessor.jpg" />&nbsp;</p> <p> Its left part correspond to defined parameters. The <strong>P1</strong> on the middle panel corresponds to contour of camera image. The <strong>P1</strong> on the right panel corresponds to image dowloaded to <strong>P1</strong>.&nbsp; Both of them are marked by number 0. It means that we wish to match both contours. Similarly we can say about <strong>P2</strong> and <strong>P3</strong>.</p> <p> <a href="cfa/imagenavigationsample.zip">Click here to download this sample</a>.</p> <p> &nbsp;</p> </blockquote> <img align="bottom" alt="" height="8" src="images/blueline.gif" width="550" /> <br /> <table summary="layout" width="550"> <tr> <td align="left" valign="center"> <a href="pointsindicators.html" target="_top"> <img align="middle" alt="Previous Page" border="0" height="26" src="images/back.jpg" width="26" /></a> <a href="index.html" target="_top"> <img align="middle" alt="Trail Contents" border="0" height="26" src="images/toc.jpg" width="26" /></a> <a href="containers.html" target="_top"> <img align="middle" alt="Next Page" border="0" height="26" src="images/forw.jpg" width="26" /></a></td> <td align="middle" valign="center"> <font size="-1"> </font> </td> <td align="right" valign="center"> <font size="-1"><a href="../search.html" target="_top"></a> </font> </td> </tr> </table> <br /> </body> </html>