Appendix A Matlab Code

%Main

Initialize_FI Initialize_SET

for Session_clock = 1:10800, FI_procedure

Scalar_timing_theory end

Record_data

%Initialize_FI FI = 30; clear

Procedure = XFI'; %Assign procedural name for saving data file

Seconds = 1; Minutes = 60*Seconds; Hours = 60*Minutes; Prime_code = 50; Response_code = 1; Food_code = 19;

Data = 0; Data_pointer = 1; Cycle_count = 0; Food = 0;

randn(xstate',sum(10 0*clock)); %Initialize random number generators rand(xstate',sum(100*clock));

%Initialize_SET Model = x SET'; %Clock

Speed_mean = 5; Speed_s d = 0; Speed = (Speed_sd * randn) + Speed_mean;

%Initialize the fixed-interval procedure %Initialize Scalar expectancy theory %Continue until session ends %Should the procedure deliver food?

%Should the model make a response?

%Transfer the data to disk

Accumulator = 0;

%Decision

Threshold = (Threshold_sd * randn) + Threshold_mean;

Memory_storage_pointer = 0; Memory_retrieval_pointer = 1; Memory_sample = ceil(rand*119);

%FI_procedure

%Input: Response %Output: Food if Cycle_clock >= FI*Seconds,

Prime = 1; end %Set fixed- interval if (Prime == 1 & Response == 1) Food = 1;

Cycle_count = Cycle_count + 1; Data(Data_pointer,1) =

round(Session_clock); %Record time

Data(Data_pointer,2) =

Food_code; %Record food

Data_pointer = Data_pointer + 1; Prime = 0; %Reinitialize prime end if (Response) ,

Data(Data_pointer,1) =

round(Session_clock); %Record time

Data(Data_pointer,2) =

Response_code; %Record response

Data_pointer = Data_pointer + 1;

Response = 0; %Reinitialize response end

Cycle_clock = Cycle_clock + 1;

%Scalar_timing_theory.m if Food == 1;

%Memory storage constant to transform perception to memory

Memory_storage_pointer = Memory_storage_pointer + 1; k = (k_sd * randn) + k_mean;

Memory(Memory_storage_pointer) = k * Accumulator;

%Get new sample of clock speed

Speed = (Speed_sd * randn) + Speed_mean; Accumulator = Speed * Cycle_clock;

%Get new sample from memory

Memory_retrieval_pointer = ceil(rand * Memory_ storage_pointer); %Round up to nearest integer

Memory_sample = Memory(Memory_retrieval_pointer);

%Get new sample of threshold

Threshold = (Threshold_sd * randn) + Threshold_mean;

Accumulator = Speed * Cycle_clock;

Discrepancy = abs(Memory_sample - Accumulator) ./ Memory_ sample;

if Discrepancy < Threshold, Response = 1; end if(rand<.01), Response = 1; end%Mean operant rate of 1 response in 100 s

%Record_data.m

Output_file = [Procedure x_' Model x_' num2str(FI) x.sim']; %Name the file save(Output_file, 'Data', x-ascii', x-double'-tabs'); %Save it on disk

Procedure x is Done.'] %Report completion

0 0

Post a comment