-
Notifications
You must be signed in to change notification settings - Fork 3
/
simulate.m
37 lines (33 loc) · 945 Bytes
/
simulate.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
clear
T = 100; %number of iterations per simulation
S = 10; %number of simulations to run
%initialize analysis variables
pol = zeros(S,T);
a = zeros(S,T);
pol_avg = zeros(1,S);
a_avg = zeros(1,S);
tic
for s = 1:S
initialize;
for t = 1:T
draw
%pause(.1);
think;
analyze;
% figure(2);
% subplot(2,1,1); plot(1:t,pol(s,1:t));
% title('polarization'); xlim([1 T]); ylim([0 90]);
% subplot(2,1,2); plot(1:t,a(s,1:t));
% title('expanse'); xlim([1 T]);
end
pol_avg(s) = mean(pol(s,:));
a_avg(s) = mean(a(s,:));
figure(3);
subplot(2,1,1); plot(1:s,pol_avg(1:s), 1:s,pol_avg(1:s),'o');
title('polarization'); xlim([1 S]); ylim([0 90]);
subplot(2,1,2); plot(1:s,a_avg(1:s), 1:s,a_avg(1:s),'o');
title('expanse'); xlim([1 S]);
toc
end
polarization = mean(pol_avg)
expanse = mean(a_avg)