%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%  Code for replication of results in the paper:
%%%%  Denotative and Connotative Control of Uncertainty: A Computational Dual Process Model
%%%%  Authors: Jesse Hoey (University of Waterloo),  
%%%%           Neil MacKinnon (University of Guelph),
%%%%           Tobias Schroeder  (Potdsam University of Applied Sciences)
%%%%  Copyright: the authors, 2021
%%%%  For research purposes only.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% This file:  README and file list and usage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%--------------------------------------------------------------------------------------------------
%% File list:
%%--------------------------------------------------------------------------------------------------
%%%%%python 2 code 
actsimulator.py: for generating results for sections 5.1 (fairness) and 5.3 (PCS juror example)

%%%%% MATLAB/Octave scripts, includes data from USA 2015 study
cogdissonance.m : for generation of Figure 6 
figure2_3_4.m : for generation of Figures 2,3 and 4 
computePost.m : helper function to compute the posteriors

%%%%% data from the Indiana 2005 study
fbehaviours.dat
fidentities.dat
fmodifiers.dat

%%%% dynamics equations from the USA 1978 study
tdynamics-female.dat
temotions-female.dat
tdynamics-male.dat
temotions-male.dat

%%--------------------------------------------------------------------------------------------------
%% USAGE:
%%--------------------------------------------------------------------------------------------------
matlab scripts are self-explanatory (see code) - simply run the scripts in matlab and you will see all the figures
some adjustments can be made in the code (flags that can be set to get the different figures in the appendices and main text)

%%--------------------------------------------------------------------------------------------------
%% Python script to generate data from Section 5.1 (Fairness):

%% the salient condition:
python actsimulator.py -e anxious -a student -b compromise_with -c student -g male

%% for voicing condition is the "post-event" emotion e value (2.2)
%% for non-voicing condition is the agent emotion e value (-0.77)
    
%% the non-salient condition:
python actsimulator.py -a student -b compromise_with -c student -g male

%% for voicing condition is the "post-event" emotion e value (1.9)
%% for non-voicing condition is the agent emotion e value (1.5)


%% Sad e value is -1.88
%% disappointed e value is -1.71
%Then compute, using the e values above, e.g. in Matlab:
sad=-1.88
disappointed=-1.71
%salient-voice
e=2.2;
((((sad-e)+4.3)*6/8.6+1)+((disappointed-e)+4.3)*6/8.6+1)/2

%salient-novoice
e=-0.77;
((((sad-e)+4.3)*6/8.6+1)+((disappointed-e)+4.3)*6/8.6+1)/2

%nonsalient-voice
e=1.9;
((((sad-e)+4.3)*6/8.6+1)+((disappointed-e)+4.3)*6/8.6+1)/2

%nonsalient-novoice
e=1.5;
((((sad-e)+4.3)*6/8.6+1)+((disappointed-e)+4.3)*6/8.6+1)/2

%Thus we have

%     		  voice		no voice
% salient          1.2 		   3.3
% non-salient	   1.4		   1.7


% These values are plotted in Figure 5(a)


%%--------------------------------------------------------------------------------------------------
%% To generate the results from section 5.3 (juror example)
%% the following can be cut-and-pasted into a shell to generate the results in Table 1
%% first column
python actsimulator.py -a juror -b convict -c student -g male  | grep 'deflection'
python actsimulator.py -a juror -b forgive -c student -g male  | grep 'deflection'
python actsimulator.py -a juror -b convict -c delinquent -g male  | grep 'deflection'
python actsimulator.py -a juror -b forgive -c delinquent -g male  | grep 'deflection'
python actsimulator.py -a juror -b convict -c friend -g male  | grep 'deflection'
python actsimulator.py -a juror -b forgive -c friend -g male  | grep 'deflection'

%% second column
python actsimulator.py -e sympathetic -a juror -b convict -c student -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a juror -b forgive -c student -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a juror -b convict -c delinquent -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a juror -b forgive -c delinquent -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a juror -b convict -c friend -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a juror -b forgive -c friend -g male | grep 'deflection'

%% third column
python actsimulator.py -a friend -b convict -c student -g male  | grep 'deflection'
python actsimulator.py -a friend -b forgive -c student -g male  | grep 'deflection'
python actsimulator.py -a friend -b convict -c delinquent -g male  | grep 'deflection'
python actsimulator.py -a friend -b forgive -c delinquent -g male  | grep 'deflection'
python actsimulator.py -a friend -b convict -c friend -g male  | grep 'deflection'
python actsimulator.py -a friend -b forgive -c friend -g male  | grep 'deflection'

%% fourth column
python actsimulator.py -e sympathetic -a friend -b convict -c student -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a friend -b forgive -c student -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a friend -b convict -c delinquent -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a friend -b forgive -c delinquent -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a friend -b convict -c friend -g male | grep 'deflection'
python actsimulator.py -e sympathetic -a friend -b forgive -c friend -g male | grep 'deflection'

