-
Notifications
You must be signed in to change notification settings - Fork 0
/
f_pavlov_feedback.m
46 lines (40 loc) · 1.04 KB
/
f_pavlov_feedback.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
function [ fx] = f_pavlov_feedback( x_t,theta,u_t,in )
% function [ fx,dfdx,dfdP ] = f_pavlov( x_t,P,u_t,in )
% IN:
% - x_t : Q-values (2*1)
% - P : learning rate (1*1)
% - u_t : previous action and feedback
% - in : []
alpha = 1./(1+exp(-theta(1)));
% gamma = 1./(1+exp(-theta(2)));
epsilon = 1./(1+exp(-theta(2)));
gamma = 0;
cs = u_t(3);
us = u_t(4);
congruent = u_t(6);
if in.noCS
fx(1) = x_t(1) + alpha*(us-x_t(1));
else
if (cs && congruent) || (~cs && ~congruent) % actual infusion on previous trial
fx(1) = x_t(1) + alpha*(us-x_t(1));
fx(2) = x_t(2)+ gamma*alpha*(us-x_t(1));
elseif (~cs && congruent) || (cs && ~congruent) % no actual infusion on previous trial
fx(2) = x_t(2) + alpha*(us-x_t(2)); % no infusion on previous trial
fx(1) = x_t(1)+ gamma*alpha*(us-x_t(2));
end
end
%
% if cs
% %dfdx = [df1dx1 , df1dx2;
% % df2dx1 , df2dx2]
% dfdx = [1-alpha];
% dfdP = [alpha*(1-alpha)*(us-x_t)];
%
%
% else
% dfdx = 0;
% dfdP = 0;
%
% end
% dfdx = dfdx';
% dfdP = dfdP';