%setup
n = 50; %number of trials
k = 2; %number of cues
N = 1000; %number of datasets to generate and fit
e = .1; %learning rate for data-generating model
E = .01:.01:.5; %range of learning rates to be evaluated in fitting models
s = zeros(n,k); %stimulus matrix (trial x cue)
R = zeros(n,1); %outcome sequence
p = zeros(n,1); %prediction on each trial
r = zeros(n,1); %response on each trial
diff = zeros(1,N); %for tracking results: difference in fit between models
for i=1:N
%create cue-outcome schedule (using 2-partial-cue paradigm)
s = randi([0 1],n,k); %independent random cues
R = rand(n,1) < s*[.5;.5]; %cues contribute additively
%simulate common-e model to create test data
w = zeros(k,n+1); %initialize weight vector
for t=1:n %loop through trials
p(t) = s(t,:)*w(:,t); %expected outcome
r(t) = rand