-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfig_solway4.m
194 lines (156 loc) · 4.16 KB
/
fig_solway4.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
function fig_solway4(filename, do_save)
if ~exist('filename', 'var') || isempty(filename)
%load('solway4_alpha=2_10000.mat'); % <--- preprint
%load old_mats/solway4_N=35_alpha=2.0000_nsamples=10000.mat % <-- sample_c
%load solway4_N=35_alpha=1.0000_nsamples=10000_last.mat % <-- sample_c
load solway4_N=35_alpha=1.0000_nsamples=10000_eps=0.6000_last.mat % <-- sample_c
else
load(filename);
end
if ~exist('do_save', 'var')
do_save = true;
end
figure('pos', [10 500 1000 600] * 3/4);
fontsize = 13;
axisfontsize = 10;
lettersize = 14;
% A: graph
%
subplot(2,3,1);
[h, xs, ys] = plot_solway4_graph(H, D);
d = 0.7;
text(h.XData(10) - d, h.YData(10) + d, 's', 'FontSize', 12, 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle');
text(h.XData(20) + d, h.YData(20) - d, 'g', 'FontSize', 12, 'HorizontalAlignment', 'center', 'VerticalAlignment', 'middle');
%labelnode(h, 10, ' start');
%labelnode(h, 20, ' goal');
title('Experimental Design', 'fontsize', fontsize);
hold on;
E = zeros(size(D.G.E));
E(10,5) = 1;
E(5,6) = 1;
E(6,8) = 1;
E(8,9) = 1;
E(9,19) = 1;
E(19,20) = 1;
G = digraph(E);
h = plot(G);
set(h, 'XData', xs);
set(h, 'YData', ys);
labelnode(h, 1:D.G.N, '');
for i = 1:D.G.N
highlight(h, i, 'marker', 'none');
for j = 1:D.G.N
if E(i,j)
highlight(h, i, j, 'edgecolor', [244 137 143]/255, 'linewidth', 2);
end
end
end
h.ArrowSize = 10;
h.EdgeAlpha = 1;
%h.ArrowPosition = 0.9
E = zeros(size(D.G.E));
E(10,12) = 1;
E(12,16) = 1;
E(16,18) = 1;
E(18,23) = 1;
E(23,22) = 1;
E(22,20) = 1;
G = digraph(E);
h = plot(G);
set(h, 'XData', xs);
set(h, 'YData', ys);
labelnode(h, 1:D.G.N, '');
for i = 1:D.G.N
highlight(h, i, 'marker', 'none');
for j = 1:D.G.N
if E(i,j)
highlight(h, i, j, 'edgecolor', [143 207 165]/255, 'linewidth', 2);
end
end
end
h.ArrowSize = 10;
h.EdgeAlpha = 1;
%h.ArrowPosition = 0.9
hold off;
% B: Data
%
subplot(2,3,2);
n = size(tasks,1) * N;
c1 = 0.72 * n;
c2 = n - c1;
p = 2 * binocdf(min(c1,c2), n, 0.5);
y = binoinv([0.025 0.975], n, 0.5) / n;
m = c1/n;
bar(m);
hold on;
line([0 2], [0.5 0.5], 'linestyle', '--', 'color', [0.6 0.6 0.6]);
%h = fill([0 2 2 0], [y(1) y(1) y(2) y(2)], [0.4 0.4 0.4]);
%set(h, 'facealpha', 0.5, 'edgecolor', 'none');
set(gca, 'xlim', [0 2]);
set(gca, 'ylim', [0 1]);
set(gca, 'ytick', [0 0.5 1]);
xticklabels({'P(fewer boundaries)'});
hold off;
title('Data', 'fontsize', fontsize);
% C: Model
subplot(2,3,3);
c1 = 0;
c2 = 0;
n = 0;
synth = [];
for t = 1:size(tasks,1)
c1 = c1 + sum(move(:,t) == nexts(t,1)); % count 1 -- we care about that one
c2 = c2 + sum(move(:,t) == nexts(t,2)); % count 2
synth = [synth ones(1,c1) zeros(1,c2)];
end
n = c1 + c2;
p = 2 * binocdf(min(c1,c2), n, 0.5);
y = binoinv([0.025 0.975], n, 0.5) / n;
m = c1/n;
se = sem(synth);
bar(m);
hold on;
errorbar(m, se, 'color', 'black');
line([0 2], [0.5 0.5], 'linestyle', '--', 'color', [0.6 0.6 0.6]);
%h = fill([0 2 2 0], [y(1) y(1) y(2) y(2)], [0.4 0.4 0.4]);
%set(h, 'facealpha', 0.5, 'edgecolor', 'none');
set(gca, 'xlim', [0 2]);
set(gca, 'ylim', [0 1]);
set(gca, 'ytick', [0 0.5 1]);
xticklabels({'P(fewer boundaries)'});
hold off;
title('Model', 'fontsize', fontsize);
% D: Hierarchies
%{
x = xs;
y = ys;
for s = 1:12
subplot(4,6, 12 + s);
h = plot_H(chosen_H{s}, D);
set(h, 'XData', x);
set(h, 'YData', y);
labelnode(h, 1:D.G.N, '');
set(gca, 'xtick', []);
set(gca, 'ytick', []);
h.MarkerSize = 6;
if s == 3
title([' ', 'Example hierarchies'], 'fontsize', fontsize);
end
end
%}
ax1 = axes('Position',[0 0 1 1],'Visible','off');
axes(ax1);
text(0.10, 0.96, 'A', 'FontSize', lettersize, 'FontWeight', 'bold');
text(0.36, 0.96, 'B', 'FontSize', lettersize, 'FontWeight', 'bold');
text(0.64, 0.96, 'C', 'FontSize', lettersize, 'FontWeight', 'bold');
%text(0.10, 0.52, 'D', 'FontSize', lettersize, 'FontWeight', 'bold');
% save figure
if do_save
h = gcf;
%set(h, 'PaperPositionMode', 'auto');
set(h, 'PaperOrientation', 'landscape');
print('figures/solway4.pdf', '-dpdf');
end
% stats
%
fprintf('%f; two-tailed binomial test (c1 = %d) n = %d, p = %e\n', m, c1, n, p);