-
Notifications
You must be signed in to change notification settings - Fork 0
/
tapas_condhalluc_obs2_sim.m
39 lines (31 loc) · 1.12 KB
/
tapas_condhalluc_obs2_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
function y = tapas_condhalluc_obs2_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/>.
% Get parameters
be = p(1);
nu = p(2);
% Prediction trajectory
mu1hat = infStates(:,1,1);
% Get true-positive rate corresponding to stimuli
tp = r.u(:,2);
% Update belief using precision-weighted prediction error
% with nu the generalized precision
x = mu1hat + 1/(1 + nu)*(tp - mu1hat);
% 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;