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
19 January 2026, 07:08:41 UTC
  • Code
  • Branches (1)
  • Releases (0)
  • Visits
Revision 9124ee20fcbc67db053ebb59cdebae3aad266593 authored by nwbarendregt on 02 May 2022, 17:06:36 UTC, committed by GitHub on 02 May 2022, 17:06:36 UTC
Add files via upload
1 parent f843c31
  • Files
  • Changes
    • Branches
    • Releases
    • HEAD
    • refs/heads/main
    • 9124ee20fcbc67db053ebb59cdebae3aad266593
    No releases to show
  • ac994f9
  • /
  • Figure 4 -- Known Reward Performance
  • /
  • RC_Fixed_Noise_Strength.m
Raw File Download Save again
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.

  • revision
  • directory
  • content
  • snapshot
origin badgerevision badge
swh:1:rev:9124ee20fcbc67db053ebb59cdebae3aad266593
origin badgedirectory badge
swh:1:dir:354557c2a9886c2869b33de3e4b79306e8421abd
origin badgecontent badge
swh:1:cnt:475257e9565407f8beda78ffced4c01a05938747
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.

  • revision
  • directory
  • content
  • 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: 9124ee20fcbc67db053ebb59cdebae3aad266593 authored by nwbarendregt on 02 May 2022, 17:06:36 UTC
Add files via upload
Tip revision: 9124ee2
RC_Fixed_Noise_Strength.m
% RC_Fixed_Noise_Strength.m

load('DR_RR_Const_Opt_data.mat','Const_Opt_theta')
load('DR_RR_UGM_Opt_data.mat','UGM_Opt_theta')

% Define simulation variables for reward change task simulations:
T = 5; dt = 0.005;  t_i = 1;
dg = 0.001;
m = 5; c = 1;
R_1 = 3; R_2 = 11-R_1; R_ind = 23;
R = NaN(1,T/dt+1); R(1:100) = R_1; R(101:end) = R_2;

% Define noise strength discretization and maximal levels of each 
% noise source:
noise_strength = 0:0.1:1;
sigma_max = 5; mn_max = 0.25;

% Define simulation parameters to construct synthetic subjects:
N_sub = 100; N_trial = 1e4;

% Pre-allocate model reward rate storage:
NB_RR = NaN(length(noise_strength),N_sub);
Const_RR = NaN(length(noise_strength),N_sub);
UGM_RR = NaN(length(noise_strength),N_sub);

% Construct optimal models given reward timeseries
[NB_thresh,~] = RC_Bellmans(T,dt,t_i,dg,m,@(t) c,R);
Const_thresh = Const_Opt_theta(R_ind)*ones(1,T/5/dt+1);
UGM_theta = UGM_Opt_theta(:,R_ind);

for i = 1:length(noise_strength)
    NB_RR_i = NaN(1,N_sub);
    Const_RR_i = NaN(1,N_sub);
    UGM_RR_i = NaN(1,N_sub);
    
    % Sample strength of each noise source given fixed total noise level:
    z = noise_strength(i)*(sigma_max+mn_max);
    sigma = (min([sigma_max,z])-max([z-mn_max,0]))*rand(1,N_sub)+max([z-mn_max,0]);
    mn = z-sigma;

    for j = 1:N_sub

        % Generate trial data for synthetic subject:
        [y,p] = RDMD_trial_generate(m,T/5,dt,sigma(j),N_trial);

        % Pre-allocate RT, reward, and time cost storage for synthetic
        % subject:
        RT = NaN(N_trial,3);
        reward = NaN(N_trial,3);
        cost = NaN(N_trial,3);
        for n = 1:N_trial

            % Perform trial block using NB model:
            [RT(n,1),C] = RDMD_sim_norm(y(n,:),T/5,dt,NB_thresh,mn(j));
            reward(n,1) = C*(R_1*(RT(n,1) < 0.5)+R_2*(RT(n,1) >= 0.5));
            cost(n,1) = c*RT(n,1);
            
            % Perform trial block using Const model:
            [RT(n,2),C] = RDMD_sim_norm(y(n,:),T/5,dt,Const_thresh,mn(j));
            reward(n,2) = C*(R_1*(RT(n,2) < 0.5)+R_2*(RT(n,2) >= 0.5));
            cost(n,2) = c*RT(n,2);
            
            % Perform trial block using UGM:
            [RT(n,3),C] = RDMD_sim_UGM(p(n,:),T/5,dt,UGM_theta(1),UGM_theta(2),UGM_theta(3)+sigma(j),UGM_theta(4),mn(j));
            reward(n,3) = C*(R_1*(RT(n,3) < 0.5)+R_2*(RT(n,3) >= 0.5));
            cost(n,3) = c*RT(n,3);
        end

        % Calculate synthetic reward rates for each model:
        RR = (mean(reward,1)-mean(cost,1))./(mean(RT,1)+t_i);
        NB_RR_i(j) = RR(1); Const_RR_i(j) = RR(2); UGM_RR_i(j) = RR(3);
    end
    NB_RR(i,:) = NB_RR_i; Const_RR(i,:) = Const_RR_i; UGM_RR(i,:) = UGM_RR_i;
end

filename = ['RC_Fixed_Noise_Strength_R1_' num2str(R_1) '.mat'];
save(filename)
The diff you're trying to view is too large. Only the first 1000 changed files have been loaded.
Showing with 0 additions and 0 deletions (0 / 0 diffs computed)
swh spinner

Computing file changes ...

back to top

Software Heritage — Copyright (C) 2015–2026, 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