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