-
Notifications
You must be signed in to change notification settings - Fork 35
/
Figure5_confusionMatrix.m
91 lines (73 loc) · 2.11 KB
/
Figure5_confusionMatrix.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
%%%%% Bob Wilson & Anne Collins
%%%%% 2018
%%%%% Code to produce figure 5 in submitted paper "Ten simple rules for the
%%%%% computational modeling of behavioral data"
clear
addpath('./SimulationFunctions')
addpath('./AnalysisFunctions')
addpath('./HelperFunctions')
addpath('./FittingFunctions')
addpath('./LikelihoodFunctions')
%%
CM = zeros(5);
T = 1000;
mu = [0.2 0.8];
for count = 1:100
count
figure(1); clf;
FM = round(100*CM/sum(CM(1,:)))/100;
t = imageTextMatrix(FM);
set(t(FM'<0.3), 'color', 'w')
hold on;
[l1, l2] = addFacetLines(CM);
set(t, 'fontsize', 22)
title(['count = ' num2str(count)]);
set(gca, 'xtick', [1:5], 'ytick', [1:5], 'fontsize', 28, ...
'xaxislocation', 'top', 'tickdir', 'out')
xlabel('fit model')
ylabel('simulated model')
drawnow
% Model 1
b = rand;
[a, r] = simulate_M1random_v1(T, mu, b);
[BIC, iBEST, BEST] = fit_all_v1(a, r);
CM(1,:) = CM(1,:) + BEST;
% Model 2
epsilon = rand;
[a, r] = simulate_M2WSLS_v1(T, mu, epsilon);
[BIC, iBEST, BEST] = fit_all_v1(a, r);
CM(2,:) = CM(2,:) + BEST;
% Model 3
alpha = rand;
beta = 1+exprnd(1);
[a, r] = simulate_M3RescorlaWagner_v1(T, mu, alpha, beta);
[BIC, iBEST, BEST] = fit_all_v1(a, r);
CM(3,:) = CM(3,:) + BEST;
% Model 4
alpha_c = rand;
beta_c = 1+exprnd(1);
[a, r] = simulate_M4ChoiceKernel_v1(T, mu, alpha_c, beta_c);
[BIC, iBEST, BEST] = fit_all_v1(a, r);
CM(4,:) = CM(4,:) + BEST;
% Model 5
alpha = rand;
beta = 1+exprnd(1);
alpha_c = rand;
beta_c = 1+exprnd(1);
[a, r] = simulate_M5RWCK_v1(T, mu, alpha, beta, alpha_c, beta_c);
[BIC, iBEST, BEST] = fit_all_v1(a, r);
CM(5,:) = CM(5,:) + BEST;
end
%%
figure(1);
title('')
set(gcf, 'Position', [811 417 500 400])
set(gca, 'fontsize', 28);
saveFigurePdf(gcf, '~/Figures/Figure5b')
%
%
% [Xf, LL, BIC] = fit_M1random_v1(a, r);
% [Xf, LL, BIC] = fit_M2WSLS_v1(a, r);
% [Xf, LL, BIC] = fit_M3RescorlaWagner_v1(a, r);
% [Xf, LL, BIC] = fit_M4CK_v1(a, r);
% [Xf, LL, BIC] = fit_M5RWCK_v1(a, r);