Mercurial > hg > ltpda
diff m-toolbox/test/test_ao_metropolis.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/test/test_ao_metropolis.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,27 @@ +% A test script for ao/metropolis +% +% M Nofrarias 17-03-09 +% +% $Id: test_ao_metropolis.m,v 1.1 2009/03/18 14:00:13 miquel Exp $ +% + +%% Make gaussian distribution + +gauss = ao(plist('xyfcn','1/(sqrt(2*pi)*2)*exp(-(x-5).^2./(2*2^2))','x',(-10:.01:20))) +gauss.setName('gaussian pdf') + +%% Sample the distribution + +pl = plist('N',500,'J',2,'sigma',2,'range',[0 1]); +b = metropolis(gauss,pl) + +% compute histogram +c = hist(b,plist('N',15)); +prob = c./len(b(1))./(c(1).x(2)-c(1).x(1)) +prob.setName('histogram') + +%% Plot +iplot(gauss,prob,plist('LineStyles',{'-','--','--'},'Function','stairs')) + + +