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

Revision f0c5c7cb930dc7952c24021113edac8be7e4bf32 authored by Guy Avraham on 26 October 2022, 13:32:18 UTC, committed by GitHub on 26 October 2022, 13:32:18 UTC
Create LICENSE
1 parent ac59451
  • Files
  • Changes
  • d8367b5
  • /
  • Codes
  • /
  • Simulations
  • /
  • rw_sim_diff_csScheduleOfExp1.m
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.

  • revision
  • directory
  • content
revision badge
swh:1:rev:f0c5c7cb930dc7952c24021113edac8be7e4bf32
directory badge
swh:1:dir:9eb08aeac36daaddbadbfea25e18cbc815e2b1a5
content badge
swh:1:cnt:270299b1bb664ceaf7d46ce95fae27e798aca404

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
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 ...
rw_sim_diff_csScheduleOfExp1.m
%% simulate rescorla-wagner model
clear;close all;clc;

addpath('../DataAnalysis')
load('data_diffCond')

%% differential conditioning paradigm
nsims = size(diff_cond.ha,1); % number of simulations - for the number of subj
ntrials = size(diff_cond.ha,2); % total number of trials
nlearning = 600; % learning trials
nwash = ntrials-nlearning; % washout

% init associative values (and set first trial to 0)
V_plan = nan(nsims,ntrials+1,1);  V_plan(:,1) = 0;
V_tone = nan(nsims,ntrials+1,1);  V_tone(:,1) = 0;
V_light = nan(nsims,ntrials+1,1);  V_light(:,1) = 0;
V = nan(nsims,ntrials+1,1);  V(:,1) = 0;

% model parameters - good try for delta HA- 
% Now updated based on the values in sim_SS_RW_diff_comp_current
alpha_plan = 0.99; % plan salience
alpha_tone = .002; % tone salience
alpha_light = .002; % light salience
beta = .12; % learning rate
lambda = 15; % maximum associative strength over all stimuli

% experiment specifications of all subjs
us_m=diff_cond.cs_p;
us_m(:,(nlearning+1):ntrials)=0;

% sim loop
for s = 1:nsims
    
    % trial protocol
    us = us_m(s,:); % clamp trials (after shuffling, with 200 washouts)
    cs_plus = diff_cond.cs_p(s,:); % init tone cs
    
    % trial loop
    for t = 1:ntrials
        % clamp trial?
        if us(t)
            err = lambda;
        else
            err = 0;
        end
        
        % which cs?
        if cs_plus(t)
            V(s,t) = V_plan(s,t) + V_tone(s,t);
            % update tone only
            delta_tone = alpha_tone * beta * (err - V(s,t));
            V_tone(s,t+1) = V_tone(s,t) + delta_tone;
            V_light(s,t+1) = V_light(s,t);
            % update plan
            delta_plan = alpha_plan * beta * (err - V(s,t));
            V_plan(s,t+1) = V_plan(s,t) + delta_plan; 
        else
            V(s,t) = V_plan(s,t) + V_light(s,t);
            % update light only
            delta_light = alpha_light * beta * (err - V(s,t));
            V_light(s,t+1) = V_light(s,t) + delta_light;
            V_tone(s,t+1) = V_tone(s,t);
            % update plan
            delta_plan = alpha_plan * beta * (err - V(s,t));
            V_plan(s,t+1) = V_plan(s,t) + delta_plan;
        end
    end
    
end

save('RW_sim_ha','V')
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