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

https://github.com/nwbarendregt/AdaptNormThresh
04 November 2025, 10:21:20 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    No releases to show
  • bbb89f8
  • /
  • Figure 4 -- Known Reward Performance
  • /
  • RC_UGM_Opt.m
Raw File Download
Take a new snapshot of a software origin

If the archived software origin currently browsed is not synchronized with its upstream version (for instance when new commits have been issued), you can explicitly request Software Heritage to take a new snapshot of it.

Use the form below to proceed. Once a request has been submitted and accepted, it will be processed as soon as possible. You can then check its processing state by visiting this dedicated page.
swh spinner

Processing "take a new snapshot" request ...

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
  • directory
  • revision
  • snapshot
origin badgecontent badge Iframe embedding
swh:1:cnt:587aa1b8cce4463db878962c071fae61d0bcd416
origin badgedirectory badge Iframe embedding
swh:1:dir:354557c2a9886c2869b33de3e4b79306e8421abd
origin badgerevision badge
swh:1:rev:2878a3d9f5a3b9b89a0084a897bef3414e9de4a2
origin badgesnapshot badge
swh:1:snp:a568cc5cff39965992895669038ed8c43a59eedd

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
  • directory
  • revision
  • snapshot
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Tip revision: 2878a3d9f5a3b9b89a0084a897bef3414e9de4a2 authored by nwbarendregt on 03 May 2022, 15:08:29 UTC
Add files via upload
Tip revision: 2878a3d
RC_UGM_Opt.m
% RC_UGM_Opt.m
% Calculates optimal parameterization of the UGM 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;
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:
UGM_thresh = linspace(0.1,5,10);
UGM_a = linspace(0.1,10,10);
UGM_sigma = linspace(0,5,10);
UGM_tau = logspace(-5,0,10);

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

for i = 1:length(R_1)

    % Pre-allocate reward rate storage for model parameterizations:
    RR_i = NaN(length(UGM_thresh),length(UGM_a),length(UGM_sigma),length(UGM_tau));
    for j1 = 1:length(UGM_thresh)
        for j2 = 1:length(UGM_a)
            for j3 = 1:length(UGM_sigma)
                for j4 = 1:length(UGM_tau)

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

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

                        % Perform trial block using given UGM model parameterization:
                        [RT(n),C] = RDMD_sim_UGM(y(n,:),T/5,dt,UGM_thresh(j1),UGM_a(j2),UGM_tau(j4),0);
                        reward(n) = C*(R_1(i)*(RT(n) < 0.5)+R_2(i)*(RT(n) >= 0.5));
                        cost(n) = c*RT(n);
                    end
                    RR_i(j1,j2,j3,j4) = (mean(reward)-mean(cost))/(mean(RT)+t_i);
                end
            end
        end
    end

    % Calculate maximal reward rate for given reward timeseries and store
    % optimal parameterization:
    [UGM_RR_Opt(i),I] = max(RR_i,[],'all','linear');
    [th_I,a_I,s_I,t_I] = ind2sub(size(RR_i),I);
    UGM_Opt_theta(:,i) = [UGM_thresh(th_I);UGM_a(a_I);UGM_sigma(s_I);UGM_tau(t_I)];
end
save('RC_UGM_Opt_Data.mat','UGM_RR_Opt','UGM_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