-
Notifications
You must be signed in to change notification settings - Fork 0
/
tapas_condhalluc_obs_sim.m
40 lines (31 loc) · 1.19 KB
/
tapas_condhalluc_obs_sim.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
function y = tapas_condhalluc_obs_sim(r, infStates, p)
% Simulates responses according to the condhalluc_obs model
%
% --------------------------------------------------------------------------------------------------
% Copyright (C) 2016 Christoph Mathys, TNU, UZH & ETHZ
%
% This file is part of the HGF toolbox, which is released under the terms of the GNU General Public
% Licence (GPL), version 3. You can redistribute it and/or modify it under the terms of the GPL
% (either version 3 or, at your option, any later version). For further details, see the file
% COPYING or <http://www.gnu.org/licenses/>.
% Inverse decision temparature beta is the only parameter
be = p;
% Prediction trajectory
mu1hat = infStates(:,1,1);
% Get true-positive rate corresponding to stimuli
tp = r.u(:,2);
% Calculate belief x using Bayes' theorem
x = tp.*mu1hat./(tp.*mu1hat + (1-mu1hat).^2);
% Belief is mu1hat in trials where there is no tone
x(find(tp==0)) = mu1hat(find(tp==0));
% Apply the logistic sigmoid to the inferred beliefs
prob = tapas_sgm(be.*(2.*x-1),1);
% Initialize random number generator
if isnan(r.c_sim.seed)
rng('shuffle');
else
rng(r.c_sim.seed);
end
% Simulate
y = binornd(1, prob);
return;