forked from lei-zhang/socialRL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rl_outcome_weight.m
71 lines (42 loc) · 1.34 KB
/
rl_outcome_weight.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
%% Figure 1B
% plotting the weight of recent feedback (8 trials back) for 4 learning rates
%% initial setup
alpha1 = 0.9;
alpha2 = 0.7;
alpha3 = 0.5;
alpha4 = 0.3;
nt = 8; % # of trials
w1 = zeros(nt,1);
w2 = zeros(nt,1);
w3 = zeros(nt,1);
w4 = zeros(nt,1);
for j = 1:nt
w1(j) = power(1-alpha1, nt-j) * alpha1;
w2(j) = power(1-alpha2, nt-j) * alpha2;
w3(j) = power(1-alpha3, nt-j) * alpha3;
w4(j) = power(1-alpha4, nt-j) * alpha4;
end
%% plotting
figure;
set(gcf,'color',[1 1 1],'position', [20 20 700 505])
ax = axes;
colors = cbrewer('seq', 'BuPu', 10);
hold on
p1=plot(w1,'color', colors(9,:), 'linewidth', 3);
p2=plot(w2,'color', colors(7,:), 'linewidth', 3);
p3=plot(w3,'color', colors(5,:), 'linewidth', 3);
p4=plot(w4,'color', colors(3,:), 'linewidth', 3);
hold off
l= legend([p1,p2,p3,p4], ...
'\alpha = .9','\alpha = .7','\alpha = .5','\alpha = .3');
offsetAxes();
afs = 20; % axis font size
lfs = 24; % labels font size
set(l, 'FontSize',afs, 'box', 'off', 'location', 'northwest')
set(gca,'FontSize', afs)
xlabel('Trial', 'FontSize', lfs)
ylabel('Outcome weight','FontSize', lfs)
set(gca,'box','off' ,'TickDir','out', ...
'XTick',1:1:nt,'YTick',[0 0.5 1], 'Xlim',[.8 8], 'Ylim',[-0.1 1.1], ...
'XTickLabel', {'t-8','t-7','t-6','t-5','t-4','t-3','t-2','t-1'}, ...
'linewidth', 3)