view m-toolbox/test/test_ao_metropolis.m @ 33:5e7477b94d94 database-connection-manager

Add known repositories list to LTPDAPreferences
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Mon, 05 Dec 2011 16:20:06 +0100
parents f0afece42f48
children
line wrap: on
line source

% 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'))