-
Notifications
You must be signed in to change notification settings - Fork 8
/
getDraw.m
87 lines (81 loc) · 3.29 KB
/
getDraw.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
function draw = getDraw(oldState, settings)
%Return proposal based on current state and proposal distributions from
%settings
draw = getEmptyDrawStruct();
draw.ps = settings.proposalsARMA.proposalP(oldState.ps);
draw.qs = settings.proposalsARMA.proposalQ(oldState.qs);
%Draw new PACs and compute Parameters
%AR Proposals
if draw.ps ~= oldState.ps
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Between Model Move in p %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if draw.ps > 0
if draw.ps > oldState.ps
%Up move
if oldState.ps > 0
draw.arPacs = settings.proposalsARMA.proposalARBetween([oldState.arPacs; zeros(draw.ps - oldState.ps,1)]);
else
draw.arPacs = settings.proposalsARMA.proposalARBetween(zeros(draw.ps - oldState.ps,1));
end;
draw.arParameters = getParametersFromPACs(draw.arPacs,draw.ps);
else
%Down move
draw.arPacs = [draw.arPacs settings.proposalsARMA.proposalARBetween(oldState.arPacs(1:draw.ps))];
draw.arParameters = getParametersFromPACs(draw.arPacs,draw.ps);
end;
else
%"eradication move"
draw.arPacs = [];
draw.arParameters = [];
end;
else
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Within Model Move in p %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if draw.ps > 0
draw.arPacs = settings.proposalsARMA.proposalAR(oldState.arPacs(1:draw.ps));
draw.arParameters = getParametersFromPACs(draw.arPacs,draw.ps);
else
draw.arPacs = [];
draw.arParameters = [];
end;
end;
%MA Proposals
if draw.qs ~= oldState.qs
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Between Model Move in q %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if draw.qs > 0
if draw.qs > oldState.qs
%Up move
if oldState.qs > 0
draw.maPacs = settings.proposalsARMA.proposalMABetween([oldState.maPacs; zeros(draw.qs - oldState.qs,1)]);
else
draw.maPacs = settings.proposalsARMA.proposalMABetween(zeros(draw.qs - oldState.qs,1));
end;
draw.maParameters = -getParametersFromPACs(draw.maPacs,draw.qs);
else
%Down move
draw.maPacs = settings.proposalsARMA.proposalMABetween(oldState.maPacs(1:draw.qs));
draw.maParameters = -getParametersFromPACs(draw.maPacs,draw.qs);
end;
else
%"eradication move"
draw.maPacs = [];
draw.maParameters = [];
end;
else
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Within Model Move in p %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if draw.qs > 0
draw.maPacs = settings.proposalsARMA.proposalMA(oldState.maPacs(1:draw.qs));
draw.maParameters = -getParametersFromPACs(draw.maPacs,draw.qs);
else
draw.maPacs = [];
draw.maParameters = [];
end;
end;
draw.sigmaEs = settings.proposalsARMA.proposalSigmaE(oldState.sigmaEs);
end