view m-toolbox/test/test_ao_lpsd_variance_montecarlo.m @ 2:18e956c96a1b
database-connection-manager
Add LTPDADatabaseConnectionManager implementation. Matlab code
author
Daniele Nicolodi <nicolodi@science.unitn.it>
date
Sun, 04 Dec 2011 21:23:09 +0100 (2011-12-04)
parents
f0afece42f48
children
line source
+ − % test_ao_lpsd_variance_montecarlo
+ − %
+ − % Tests that the standard deviation returned by ao.dy in one
+ − % frequency bin is equivalent to the matlab's std taking
+ − % considering all realisations
+ − %
+ − % M Nofrarias 05-08-09
+ − %
+ − % $Id: test_ao_lpsd_variance_montecarlo.m,v 1.2 2009/08/11 14:20:10 miquel Exp $
+ −
+ − % function test_ao_lpsd_variance_montecarlo()
+ −
+ − clear
+ −
+ − % data
+ − nsecs = 500;
+ − fs = 5;
+ − pl = plist('nsecs', nsecs, 'fs', fs, 'tsfcn', 'randn(size(t))');
+ −
+ − %lpsd
+ − pl2 = plist('Kdes', 20, 'Jdes', 100);
+ −
+ − % loop
+ − for i = 1:100
+ − a(i) = ao(pl);
+ − b1(i) = lpsd(a(i),pl2);
+ − end
+ −
+ −
+ − %% compare
+ −
+ − % select a realisation
+ − index = 10;
+ −
+ − % compare estimated std to the one using all realisations
+ − clear rel
+ − for i =1:len(b1(1))
+ − mn(i) = [mean(b1(:).y(i))];
+ − rel(:,i) = [std(b1(:).y(i))/mn(i) b1(index).dy(i)/b1(index).y(i)];
+ − end
+ −
+ − % k = find(b1(1).procinfo,'k')
+ −
+ − figure
+ − loglog(b1(1).x,rel')
+ − hold
+ − loglog(b1(1).x,abs(rel(2,:)-rel(1,:)),'-or')
+ − ylabel('difference (%)')
+ − % xlabel('Frequency [Hz]')
+ − % ylabel('Rel. error')
+ − % legend('montecarlo','estimated','difference')
+ − % print -deps2c test_ao_lpsd_variance_montecarlo_1.eps
+ −
+ − % end
+ −
+ −
+ −