0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 % test_ao_ltfe_variance_montecarlo
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 % Tests that the standard deviation returned by ao.dy in one
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % frequency bin is equivalent to the matlab's std taking
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % considering all realisations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % M Nofrarias 22-07-09
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % $Id: test_ao_lcohere_variance_montecarlo.m,v 1.1 2009/08/11 14:20:11 miquel Exp $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % function test_ao_lcohere_variance_montecarlo()
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 clear
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 % data
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 nsecs = 200;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 fs = 10;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 pl = plist('nsecs', nsecs, 'fs', fs, 'tsfcn', 'sin(2*pi*2*t) + randn(size(t))');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % Make a filter
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 f1 = miir(plist('type', 'highpass', 'fc', 4, 'fs', fs));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % Window
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 Nfft = 1000;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 win = specwin('Hanning', Nfft);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 pl2 = plist('Kdes',20,'win',win,'Olap',-1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % loop
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 for i = 1:100
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 a1 = ao(pl);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 a2 = filter(a1,plist('filter', f1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 t1(i) = lcohere(a1,a2,pl2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 %% mean
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 index = 6;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 clear rel
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 for i =1:len(t1(1))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 mn(i) = [mean(t1(:).y(i))]; % both means are equal
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 rel(:,i) = [std(t1(:).y(i)) mean(t1(:).dy(i))]/abs(mn(i));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 figure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 loglog(t1(1).x,rel')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 figure
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 loglog(t1(1).x,abs(rel(2,:)-rel(1,:)))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 |