Mercurial > hg > ltpda
comparison m-toolbox/test/test_ao_lpsd_variance_montecarlo.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_lpsd_variance_montecarlo | |
2 % | |
3 % Tests that the standard deviation returned by ao.dy in one | |
4 % frequency bin is equivalent to the matlab's std taking | |
5 % considering all realisations | |
6 % | |
7 % M Nofrarias 05-08-09 | |
8 % | |
9 % $Id: test_ao_lpsd_variance_montecarlo.m,v 1.2 2009/08/11 14:20:10 miquel Exp $ | |
10 | |
11 % function test_ao_lpsd_variance_montecarlo() | |
12 | |
13 clear | |
14 | |
15 % data | |
16 nsecs = 500; | |
17 fs = 5; | |
18 pl = plist('nsecs', nsecs, 'fs', fs, 'tsfcn', 'randn(size(t))'); | |
19 | |
20 %lpsd | |
21 pl2 = plist('Kdes', 20, 'Jdes', 100); | |
22 | |
23 % loop | |
24 for i = 1:100 | |
25 a(i) = ao(pl); | |
26 b1(i) = lpsd(a(i),pl2); | |
27 end | |
28 | |
29 | |
30 %% compare | |
31 | |
32 % select a realisation | |
33 index = 10; | |
34 | |
35 % compare estimated std to the one using all realisations | |
36 clear rel | |
37 for i =1:len(b1(1)) | |
38 mn(i) = [mean(b1(:).y(i))]; | |
39 rel(:,i) = [std(b1(:).y(i))/mn(i) b1(index).dy(i)/b1(index).y(i)]; | |
40 end | |
41 | |
42 % k = find(b1(1).procinfo,'k') | |
43 | |
44 figure | |
45 loglog(b1(1).x,rel') | |
46 hold | |
47 loglog(b1(1).x,abs(rel(2,:)-rel(1,:)),'-or') | |
48 ylabel('difference (%)') | |
49 % xlabel('Frequency [Hz]') | |
50 % ylabel('Rel. error') | |
51 % legend('montecarlo','estimated','difference') | |
52 % print -deps2c test_ao_lpsd_variance_montecarlo_1.eps | |
53 | |
54 % end | |
55 | |
56 | |
57 |