comparison m-toolbox/html_help/help/ug/ltpda_training_topic_5_3.html @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
3
4 <html lang="en">
5 <head>
6 <meta name="generator" content=
7 "HTML Tidy for Mac OS X (vers 1st December 2004), see www.w3.org">
8 <meta http-equiv="Content-Type" content=
9 "text/html; charset=us-ascii">
10
11 <title>Fitting time series with polynomials (LTPDA Toolbox)</title>
12 <link rel="stylesheet" href="docstyle.css" type="text/css">
13 <meta name="generator" content="DocBook XSL Stylesheets V1.52.2">
14 <meta name="description" content=
15 "Presents an overview of the features, system requirements, and starting the toolbox.">
16 </head>
17
18 <body>
19 <a name="top_of_page" id="top_of_page"></a>
20
21 <p style="font-size:1px;">&nbsp;</p>
22
23 <table class="nav" summary="Navigation aid" border="0" width=
24 "100%" cellpadding="0" cellspacing="0">
25 <tr>
26 <td valign="baseline"><b>LTPDA Toolbox</b></td><td><a href="../helptoc.html">contents</a></td>
27
28 <td valign="baseline" align="right"><a href=
29 "ltpda_training_topic_5_2.html"><img src="b_prev.gif" border="0" align=
30 "bottom" alt="Generation of noise with given PSD"></a>&nbsp;&nbsp;&nbsp;<a href=
31 "ltpda_training_topic_5_4.html"><img src="b_next.gif" border="0" align=
32 "bottom" alt="Non-linear least squares fitting of time series"></a></td>
33 </tr>
34 </table>
35
36 <h1 class="title"><a name="f3-12899" id="f3-12899"></a>Fitting time series with polynomials</h1>
37 <hr>
38
39 <p>
40
41 <p>
42 Fitting time series with polynomials exploits the function <tt>ao/polyfit</tt>.
43 Details on the agorithm can be found in the <a href="sigproc_polyfit.html">appropriate help page</a>.
44 </p>
45
46 <h2> Fitting time series with polynomials </h2>
47
48 <p>
49 During this exercise we will:
50 <ol>
51 <li> Load time series noise
52 <li> Fit data with ao/polyfit
53 <li> Check results
54 </ol>
55 </p>
56
57 <p>
58 Let's open a new editor window and load test data.
59 </p>
60
61 <div class="fragment"><pre>
62 a = ao(plist(<span class="string">'filename'</span>, <span class="string">'topic5/T5_Ex04_TestNoise.xml'</span>));
63 a.setName;
64 </pre></div>
65
66 <p>
67 Try to fit data with <tt>ao/polyfit</tt>. We decide to fit with a 6th order polynomial.
68 </p>
69
70 <div class="fragment"><pre>
71 plfit = plist(<span class="string">'N'</span>, 6);
72 p = polyfit(a, plfit);
73 </pre></div>
74 <p>
75 The output of the polifit method is a parameter estimation object (pest-object). This object contains the coefficients of the fitted polynomial.
76 </p>
77 <div class="fragment"><pre>
78 ---- pest 1 ----
79 name: polyfit(a)
80 param names: {'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7'}
81 y: [9.17e-15;-1.01e-11;1.15e-08;-2.84e-06;-0.00444;0.138;47.5]
82 dy: []
83 yunits: [s^(-6)][s^(-5)][s^(-4)][s^(-3)][s^(-2)][s^(-1)][]
84 pdf: []
85 cov: []
86 corr: []
87 chain: []
88 chi2: []
89 dof: 993
90 models: smodel(P1*X.^6 + P2*X.^5 + P3*X.^4 + P4*X.^3 + P5*X.^2 + P6*X.^1 + P7*X.^0)
91 description:
92 UUID: 58a56ecf-24e8-40ed-a42c-ef6832c747c3
93 ----------------
94 </pre></div>
95
96 <p>
97 Once we have the pest object with the coefficients, we can evaluate the pest-object. In order to construct
98 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
99 of the output.
100 </p>
101
102 <div class="fragment"><pre>
103 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>))
104 b.setName;
105 </pre></div>
106
107 <p>
108 Now, check fit result with some plotting. Compare data with fitted model
109 and look at the fit residuals.
110 </p>
111
112 <div class="fragment"><pre>
113 iplot(a,b)
114 iplot(a-b)
115 </pre></div>
116
117 <p>
118 <div align="center">
119 <IMG src="images/ltpda_training_1/topic5/ltpda_training_5_3_1.png" align="center" border="0">
120 </div>
121 <div align="center">
122 <IMG src="images/ltpda_training_1/topic5/ltpda_training_5_3_2.png" align="center" border="0">
123 </div>
124 </p>
125
126 <p>
127 You could also try using <tt>ao/detrend</tt> on the input time-series to yield
128 a very similar result as that shown in the last plot.
129 </p>
130
131
132
133
134
135
136
137
138
139
140
141 </p>
142
143 <br>
144 <br>
145 <table class="nav" summary="Navigation aid" border="0" width=
146 "100%" cellpadding="0" cellspacing="0">
147 <tr valign="top">
148 <td align="left" width="20"><a href="ltpda_training_topic_5_2.html"><img src=
149 "b_prev.gif" border="0" align="bottom" alt=
150 "Generation of noise with given PSD"></a>&nbsp;</td>
151
152 <td align="left">Generation of noise with given PSD</td>
153
154 <td>&nbsp;</td>
155
156 <td align="right">Non-linear least squares fitting of time series</td>
157
158 <td align="right" width="20"><a href=
159 "ltpda_training_topic_5_4.html"><img src="b_next.gif" border="0" align=
160 "bottom" alt="Non-linear least squares fitting of time series"></a></td>
161 </tr>
162 </table><br>
163
164 <p class="copy">&copy;LTP Team</p>
165 </body>
166 </html>