Week 6 Homework

1. Play with the diffusion model, using the demo code. Vary each of the model parameters: z, mu, sigma, a. For each, describe how the model predictions change, and try to give an intuitive explanation based on the parameter's psychological interpretation.

2. Simulate the Bayesian random walk model, using equal-variance Gaussians for pS and pN. Define the model parameters Means and variance for the two distributions (pS and pN) mSignal = 1; %mean of signal distribution
mNoise = 0; %mean of noise distribution
sigma = 1; %standard deviation of both distributions

Decision threshold—corresponds to log-odds of accuracy, so try to define it that way alpha = log(.9/.1); %decision threshold; corresponds to 90% accuracy
Starting point—corresponds to prior log-odds, so try to define it that way E0 = log(2/1); %starting point; corresponds to prior belief of 2/3 signal, 1/3 noise
Time constant for converting number of samples to RT tau = .1; %time constant; 100 ms

Setup for simulation Choose a number of trials to simulate (can be large because model is fast) N = 10000; %number of trials to simulate
Create a sequence of correct categories (i.e., signal or noise on each trial) H = 1 + (rand(N,1) > 2/3); %1 for signal, 2 for noise; setting 2/3 baserate to match prior (though they don't have to match)
Create arrays for tracking response and RT across trials r = zeros(N,1); %response for each trial
RT = zeros(N,1); %RT for each trial

Loop through trials and simulate each step of the model for i = 1:N %loop through trials Initialize things to be tracked this trial Evidence E = E0; %evidence begins at starting point
Number of observations n = 0; %tracks number of observations taken on this trial

Sample observations until reaching threshold (hint: use a while loop) while abs(E) < alpha Sample an observation (x) based on the correct category for this trial if H(i) == 1 %signal trial
x = mSignal + randn*sigma; %observation else %noise trial
x = mNoise + randn*sigma; %observation end

Calculate the loglikelihood ratio for this observation; try to work through the algebra using the expressions for Gaussian distributions, and then compare to Eq 17 from this week's chapter L = (mSignal-mNoise)/sigma^2 * (x-(mSignal+mNoise)/2); %loglikelihood ratio
Increment the evidence and the count of observations E = E + L; %increment evidence by loglikelihood of current observation
n = n + 1; %increment count of observations

Record response and RT for this trial r(i) = 1 + (E<0); %response: 1 if E positive (hit upper threshold), 2 if E negative (hit lower threshold)
RT(i) = n*tau; %RT for this trial

Show results