-
Notifications
You must be signed in to change notification settings - Fork 1
/
plot_BQlearn.m
94 lines (70 loc) · 1.87 KB
/
plot_BQlearn.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
88
89
90
91
92
93
94
% plot result of BQlearn
% copy of plot_Qlearn
figure;
subplot(2,1,1);
hold on;
h = bar(rewards * 4);
h.FaceAlpha = 0.3;
plot(W(:,1), '-o', 'color', 'green');
if ~pavlovian
plot(W(:,2), '-o', 'color', 'red');
end
xlabel('state');
title('weights');
if pavlovian
legend({'rewards', 'w'})
else
legend({'rewards', 'w(:,run)', 'w(:,stop)'})
end
plot([10.5 10.5], [-1 20], '--', 'color', [0.2 0.2 0.2], 'HandleVisibility','off');
plot([20.5 20.5], [-1 20], '--', 'color', [0.2 0.2 0.2], 'HandleVisibility','off');
if isfield(env, 'track')
% plot([20.5 20.5], [-1 20], '--', 'color', [0.2 0.2 0.2], 'HandleVisibility','off');
end
yh = max([h.YData W(:)'])*1.1;
yh = 3.5;
yl = -1.5;
text(4, yh - 0.1, [names{1}, ' rewarded']);
text(14, yh - 0.1, [names{1}, ' omission']);
if isfield(env, 'track')
%text(14, yh - 0.1, names{2});
end
text(env.ITI-0.1, yh - 0.5, 'ITI');
ylim([yl yh]);
subplot(2,1,2);
hold on;
h = bar(posts);
h.FaceAlpha = 0.3;
plot(pres, '-o');
xlabel('state');
title('RPEs');
legend({'post-reward', 'pre-reward'})
plot([10.5 10.5], [-1 20], '--', 'color', [0.2 0.2 0.2], 'HandleVisibility','off');
plot([20.5 20.5], [-1 20], '--', 'color', [0.2 0.2 0.2], 'HandleVisibility','off');
if isfield(env, 'track')
% plot([20.5 20.5], [-1 20], '--', 'color', [0.2 0.2 0.2], 'HandleVisibility','off');
end
yh = max(posts(:))*1.1;
yl = min(pres(:))*1.1;
text(4, yh - 0.1, [names{1}, ' rewarded']);
text(14, yh - 0.1, [names{1}, ' omission']);
if isfield(env, 'track')
% text(14, yh - 0.05, names{2});
end
if length(post_RPEs) == env.nO
text(env.obs(env.ITI)-0.1, yh - 0.05, 'ITI');
else
text(env.ITI-0.1, yh - 0.05, 'ITI');
end
ylim([yl yh]);
figure;
subplot(1,2,1);
imagesc(B{1});
xlabel('time');
ylabel('state');
title('belief state dynamics, rewarded');
subplot(1,2,2);
imagesc(B{2});
xlabel('time');
ylabel('state');
title('belief state dynamics, omission');