Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
content badge
swh:1:cnt:6c9fd5b47dae9f5e52e38119544ecd2149f6c77c

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
% RC_Const_Opt.m
% Calculates optimal parameterization of the noise-free Const model, and 
% associated reward rate, for the reward change task from 
% Barendregt et al., 2022.

clear

% Define simulation parameters for the reward change task:
T = 5; dt = 0.005;  t_i = 1;
dg = 0.001;
m = 5; c = 1;
R_1 = linspace(1,10); R_2 = 11-R_1;

% Define simulation parameters to empirically calculate model performance:
N_trial = 1e4;

% Define model parameterization mesh to search over:
Const_thresh = linspace(0.1,5,10);

% Pre-allocate reward rate and model parameterization storage:
Const_RR_Opt = NaN(1,length(R_1));
Const_Opt_theta = NaN(1,length(R_1));

for i = 1:length(R_1)

    % Pre-allocate RT, reward, and time cost storage for model
    % parameterizations:
    RT = NaN(length(Const_thresh),N_trial);
    reward = NaN(length(Const_thresh),N_trial);
    cost = NaN(length(Const_thresh),N_trial);
    for j = 1:length(Const_thresh)

        % Construct Const model given parameterization:
        thresh = Const_thresh(j)*ones(1,T/5/dt+1);

        % Generate block data:
        y = RDMD_trial_generate(m,T/5,dt,0,N_trial);
        for n = 1:N_trial

            % Perform trial block using given Const model parameterization:
            [RT(j,n),C] = RDMD_sim_norm(y(n,:),T/5,dt,thresh,0);
            reward(j,n) = C*(R_1(i)*(RT(j,n) < 0.5)+R_2(i)*(RT(j,n) >= 0.5));
            cost(j,n) = c*RT(j,n);
        end
    end

    % Calculate maximal reward rate for given reward timeseries and store
    % optimal parameterization:
    [Const_RR_Opt(i),I] = max((mean(reward,2)-mean(cost,2))./(mean(RT,2)+t_i));
    Const_Opt_theta(i) = Const_thresh(I);
end
save('RC_Const_Opt_Data.mat','Const_RR_Opt','Const_Opt_theta','R_1','R_2');

back to top

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API