comparison m-toolbox/test/test_ao_sineParams.m @ 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 % Test ao/sineParams
2 %
3 % M Nofrarias 10-02-10
4 %
5 % $Id: test_ao_sineParams.m,v 1.2 2010/02/18 11:17:59 miquel Exp $
6
7 clear
8
9 % general parameters
10 fs = 5;
11 nsecs =500;
12
13
14 %% one sinusoid
15
16 % signal parameters
17 A1 = 1.23456;
18 f1 = 0.1;
19 sigma = 0.01;
20
21 % AOs
22 pl = plist('waveform','sine','f',f1,'A',A1,'fs',fs,'nsecs',nsecs);
23 a = ao(pl);
24 a.setName('signal 1')
25 pl = plist('waveform','noise','sigma',sigma,'fs',fs,'nsecs',nsecs);
26 c = ao(pl);
27 c.setName('noise')
28
29 % sum contributions
30 d = a + c;
31 d.iplot
32
33 % get parameters
34 pl = plist('N',1);
35 p = sineParams(d,pl);
36
37 % compare with contributions
38 % bb = eval(p,plist('index',1));
39 % iplot(b,bb)
40
41 aa = eval(p,plist('index',1));
42 residual = aa-a;
43 residual.setName
44 iplot(aa,a,residual)
45
46
47 %% one sinusoid montecarlo
48
49 % signal parameters
50 A1 = 1.5;
51 f1 = 0.12;
52
53 for i = 1:100
54 fprintf('iteration %d\n',i);
55 sigma(i) = 0.01;
56
57 % AOs
58 pl = plist('waveform','sine','f',f1,'A',A1,'fs',fs,'nsecs',nsecs);
59 a = ao(pl);
60 a.setName('signal 1');
61 pl = plist('waveform','noise','sigma',sigma(i),'fs',fs,'nsecs',nsecs);
62 c = ao(pl);
63 c.setName('noise');
64
65 % sum contributions
66 d = a + c;
67 % d.iplot
68
69 % get parameters
70 pl = plist('N',1);
71 p(i) = sineParams(d,pl);
72 A(i) = p(i).y(1);
73 dA(i) = p(i).dy(1);
74 f(i) = p(i).y(2);
75 df(i) = p(i).dy(2);
76 % compare with contributions
77 % bb = eval(p,plist('index',1));
78 % iplot(b,bb)
79
80 aa = eval(p(i),plist('index',1));
81 residual = aa-a;
82 residual.setName;
83 end
84
85 % compare mean(MSE) with computed Var + bias^2
86 predicted_A = sqrt(std(A)^2 + (mean(A)-A1)^2)
87 computed_A = mean(dA)
88
89 predicted_f = sqrt(std(f)^2 + (mean(f)-f1)^2)
90 computed_f = mean(df)
91
92 %% two sinusoid
93
94 % signal parameters
95 A1 = 2.2;
96 f1 = 0.1;
97 A2 = 4.5;
98 f2 = 0.33;
99 sigma = 0.02;
100
101 % AOs
102 pl = plist('waveform','sine','f',f1,'A',A1,'fs',fs,'nsecs',nsecs);
103 a = ao(pl);
104 a.setName('signal 1')
105 pl = plist('waveform','sine','f',f2,'A',A2,'fs',fs,'nsecs',nsecs);
106 b = ao(pl);
107 b.setName('signal 2')
108 pl = plist('waveform','noise','sigma',sigma,'fs',fs,'nsecs',nsecs);
109 c = ao(pl);
110 c.setName('noise')
111
112 % sum contributions
113 d = a + b + c;
114 % d.iplot
115
116 % get parameters
117 pl = plist('N',2);
118 p = sineParams(d,pl);
119
120 aa = eval(p,plist('index',1));
121
122
123 % compare with contributions
124 bb = eval(p,plist('index',1));
125 residual = bb-b;
126 residual.setName
127 iplot(bb,b,residual)
128
129 aa = eval(p,plist('index',2));
130 residual = aa-a;
131 residual.setName
132 iplot(aa,a,residual)