Raw File
Tip revision: 2878a3d9f5a3b9b89a0084a897bef3414e9de4a2 authored by nwbarendregt on 03 May 2022, 15:08:29 UTC
Add files via upload
Tip revision: 2878a3d
% RDMD_trial_generate.m
% Function that generates populations of belief trajectories for 
% continuous 2AFC tasks with changing SNR given by Eq. (8) in 
% Barendregt et al., 2022.

function [y,p]= SC_RDMD_trial_generate(m,T,dt,sigma,N_trial)

% Pre-allocate belief storage for belief with (y) and without (y_p) belief
% noise (y_p used for UGM simulations, where noise is added to filter 
% rather than input):
y = zeros(N_trial,round(T/dt)+1); y_p = zeros(N_trial,round(T/dt)+1); 
for i = 1:N_trial
    for j = 2:(T/dt+1)

        % Calculate white noise:
        dW = sqrt(dt)*randn;

        % Update observer belief:
        y(i,j) = y(i,j-1)+m(j-1)*dt+sqrt(2*m(j-1))*dW+sigma*randn;
        y_p(i,j) = y(i,j-1)+m(j-1)*dt+sqrt(2*m(j-1))*dW;

% Convert LLR y_p to a likelihood to use as input to the UGM:
p = exp(y_p)./(1+exp(y_p));
back to top