Mercurial > hg > ltpda
view m-toolbox/html_help/help/ug/ltpda_training_topic_5_3.html @ 29:54f14716c721 database-connection-manager
Update Java code
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Mon, 05 Dec 2011 16:20:06 +0100 |
parents | f0afece42f48 |
children |
line wrap: on
line source
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html lang="en"> <head> <meta name="generator" content= "HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org"> <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii"> <title>Fitting time series with polynomials (LTPDA Toolbox)</title> <link rel="stylesheet" href="docstyle.css" type="text/css"> <meta name="generator" content="DocBook XSL Stylesheets V1.52.2"> <meta name="description" content= "Presents an overview of the features, system requirements, and starting the toolbox."> </head> <body> <a name="top_of_page" id="top_of_page"></a> <p style="font-size:1px;"> </p> <table class="nav" summary="Navigation aid" border="0" width= "100%" cellpadding="0" cellspacing="0"> <tr> <td valign="baseline"><b>LTPDA Toolbox</b></td><td><a href="../helptoc.html">contents</a></td> <td valign="baseline" align="right"><a href= "ltpda_training_topic_5_2.html"><img src="b_prev.gif" border="0" align= "bottom" alt="Generation of noise with given PSD"></a> <a href= "ltpda_training_topic_5_4.html"><img src="b_next.gif" border="0" align= "bottom" alt="Non-linear least squares fitting of time series"></a></td> </tr> </table> <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Fitting time series with polynomials</h1> <hr> <p> <p> Fitting time series with polynomials exploits the function <tt>ao/polyfit</tt>. Details on the agorithm can be found in the <a href="sigproc_polyfit.html">appropriate help page</a>. </p> <h2> Fitting time series with polynomials </h2> <p> During this exercise we will: <ol> <li> Load time series noise <li> Fit data with ao/polyfit <li> Check results </ol> </p> <p> Let's open a new editor window and load test data. </p> <div class="fragment"><pre> a = ao(plist(<span class="string">'filename'</span>, <span class="string">'topic5/T5_Ex04_TestNoise.xml'</span>)); a.setName; </pre></div> <p> Try to fit data with <tt>ao/polyfit</tt>. We decide to fit with a 6th order polynomial. </p> <div class="fragment"><pre> plfit = plist(<span class="string">'N'</span>, 6); p = polyfit(a, plfit); </pre></div> <p> The output of the polifit method is a parameter estimation object (pest-object). This object contains the coefficients of the fitted polynomial. </p> <div class="fragment"><pre> ---- pest 1 ---- name: polyfit(a) param names: {'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7'} y: [9.17e-15;-1.01e-11;1.15e-08;-2.84e-06;-0.00444;0.138;47.5] dy: [] yunits: [s^(-6)][s^(-5)][s^(-4)][s^(-3)][s^(-2)][s^(-1)][] pdf: [] cov: [] corr: [] chain: [] chi2: [] dof: 993 models: smodel(P1*X.^6 + P2*X.^5 + P3*X.^4 + P4*X.^3 + P5*X.^2 + P6*X.^1 + P7*X.^0) description: UUID: 58a56ecf-24e8-40ed-a42c-ef6832c747c3 ---------------- </pre></div> <p> Once we have the pest object with the coefficients, we can evaluate the pest-object. In order to construct an object with the same time base we can pass the input AO, and specify to use its 'x' field to build the 'x' field of the output. </p> <div class="fragment"><pre> b = p.eval(a, plist(<span class="string">'type'</span>, <span class="string">'tsdata'</span>, <span class="string">'xfield'</span>, <span class="string">'x'</span>)) b.setName; </pre></div> <p> Now, check fit result with some plotting. Compare data with fitted model and look at the fit residuals. </p> <div class="fragment"><pre> iplot(a,b) iplot(a-b) </pre></div> <p> <div align="center"> <IMG src="images/ltpda_training_1/topic5/ltpda_training_5_3_1.png" align="center" border="0"> </div> <div align="center"> <IMG src="images/ltpda_training_1/topic5/ltpda_training_5_3_2.png" align="center" border="0"> </div> </p> <p> You could also try using <tt>ao/detrend</tt> on the input time-series to yield a very similar result as that shown in the last plot. </p> </p> <br> <br> <table class="nav" summary="Navigation aid" border="0" width= "100%" cellpadding="0" cellspacing="0"> <tr valign="top"> <td align="left" width="20"><a href="ltpda_training_topic_5_2.html"><img src= "b_prev.gif" border="0" align="bottom" alt= "Generation of noise with given PSD"></a> </td> <td align="left">Generation of noise with given PSD</td> <td> </td> <td align="right">Non-linear least squares fitting of time series</td> <td align="right" width="20"><a href= "ltpda_training_topic_5_4.html"><img src="b_next.gif" border="0" align= "bottom" alt="Non-linear least squares fitting of time series"></a></td> </tr> </table><br> <p class="copy">©LTP Team</p> </body> </html>