-
Notifications
You must be signed in to change notification settings - Fork 8
/
doRJMCMC.m
33 lines (24 loc) · 871 Bytes
/
doRJMCMC.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
function [states, accepted] = doRJMCMC(settings)
global PROPOSALS_GLOBAL
clear states;
%Initialize states
states(settings.draws) = getEmptyStateStruct();
states(1) = getInitialState(settings);
accepted = 0;
% progressbar;
%Iterate until settings.draws is reached
for cntrDraws = 2:settings.draws
[state, draw] = RJMCMCStep(states(cntrDraws-1), settings);
% progressbar(cntrDraws/settings.draws);
if settings.saveProposals
PROPOSALS_GLOBAL(cntrDraws) = draw;
end;
accepted = accepted + draw.accepted;
states(cntrDraws) = state;
% Report every 10000th draw
if mod(cntrDraws,10000) == 0
disp(['Iteration ' num2str(cntrDraws) '; Acceptance rate ' num2str(accepted/cntrDraws) ]);
end;
end;
% progressbar(1);
end