-
Notifications
You must be signed in to change notification settings - Fork 0
/
LADY_network.m
157 lines (142 loc) · 3.93 KB
/
LADY_network.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
% clear;
close all;
N = 30;
R = 6;
EPr = zeros(N, N, R);
diagdex = sparse(1:N, 1:N, true);
%%
Rind = 1;
EPr_t = zeros(N);
EPr_t(:, :) = EPr_t(:, :) + 0.02 * rand(N);
a = 0.7; b = 1;
EPr_t(1:10, 1:10) = a + (b-a).*rand(10, 10);
EPr_t(11:20, 11:20) = a + (b-a).*rand(10, 10);
EPr_t(21:30, 21:30) = a + (b-a).*rand(10, 10);
EPr_t = triu(EPr_t, 1) + triu(EPr_t, 1)';
EPr_t(diagdex) = 0;
% figure;imagesc(1-EPr_t);colormap('gray');
EPr(:,:, Rind) = EPr_t;
%%
Rind = 2;
EPr_t = zeros(N);
EPr_t(:, :) = EPr_t(:, :) + 0.02 * rand(N);
a = 0.9; b = 1;
subind = 1:7;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 8:15;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 16:23;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 24:30;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
EPr_t = triu(EPr_t, 1) + triu(EPr_t, 1)';
EPr_t(diagdex) = 0;
% figure;imagesc(1-EPr_t);colormap('gray');
EPr(:,:, Rind) = EPr_t;
%%
Rind = 3;
EPr_t = zeros(N);
EPr_t(:, :) = EPr_t(:, :) + 0.02 * rand(N);
a = 0.2; b = 0.7;
subind = 1:20;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
a = 0.7; b = 1;
subind = 1:10;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 11:20;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 21:30;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
EPr_t = triu(EPr_t, 1) + triu(EPr_t, 1)';
EPr_t(diagdex) = 0;
% figure;imagesc(1-EPr_t);colormap('gray');
EPr(:,:, Rind) = EPr_t;
%%
Rind = 3;
EPr_t = zeros(N);
EPr_t(:, :) = EPr_t(:, :) + 0.02 * rand(N);
a = 0.2; b = 0.7;
subind = 1:20;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
a = 0.7; b = 1;
subind = 1:10;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 11:20;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 21:30;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
EPr_t = triu(EPr_t, 1) + triu(EPr_t, 1)';
EPr_t(diagdex) = 0;
% figure;imagesc(1-EPr_t);colormap('gray');
EPr(:,:, Rind) = EPr_t;
%%
Rind = 4;
EPr_t = zeros(N);
EPr_t(:, :) = EPr_t(:, :) + 0.02 * rand(N);
a = 0.7; b = 1;
subind = [2:3,5:9,11,13:15];
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = [17:19,21:25,27,29:30];
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
EPr_t = triu(EPr_t, 1) + triu(EPr_t, 1)';
EPr_t(diagdex) = 0;
% figure;imagesc(1-EPr_t);colormap('gray');
EPr(:,:, Rind) = EPr_t;
%%
Rind = 5;
EPr_t = zeros(N);
EPr_t(:, :) = EPr_t(:, :) + 0.02 * rand(N);
a = 0.7; b = 1;
subind = [2:3,5:9,11,13:15];
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = [17:30];
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
EPr_t = triu(EPr_t, 1) + triu(EPr_t, 1)';
EPr_t(diagdex) = 0;
% figure;imagesc(1-EPr_t);colormap('gray');
EPr(:,:, Rind) = EPr_t;
%%
Rind = 6;
EPr_t = zeros(N);
EPr_t(:, :) = EPr_t(:, :) + 0.02 * rand(N);
a = 0.7; b = 1;
subind = 1:13;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 14:22;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
subind = 23:30;
EPr_t(subind, subind) = a + (b-a).*rand(numel(subind));
EPr_t = triu(EPr_t, 1) + triu(EPr_t, 1)';
EPr_t(diagdex) = 0;
% figure;imagesc(1-EPr_t);colormap('gray');
EPr(:,:, Rind) = EPr_t;
figure(1);
for t = 1:R
subplot(1,R,t);
imagesc(1 - EPr(:,:,t));colormap('gray')
end
%%
T = 50;
regime_seq_indices = zeros(1,T);
regime_seq_indices(1:4) = 1;
regime_seq_indices(5:8) = 6;
regime_seq_indices(9:11) = 3;
regime_seq_indices(12:14) = 1;
regime_seq_indices(15:19) = 2;
regime_seq_indices(20:25) = 4;
regime_seq_indices(26:30) = 2;
regime_seq_indices(31:33) = 1;
regime_seq_indices(34:38) = 3;
regime_seq_indices(39:42) = 1;
regime_seq_indices(47:50) = 4;
regime_seq_indices(43:46) = 5;
% figure(2);plot(1:T, regime_seq_indices, 'bo');
% ylim([0 R+1])
% set(gca, 'YGrid', 'on', 'XGrid', 'off');
%%
Adj = zeros(N, N, T);
for t = 1:T
Adj_t = rand(N) < EPr(:,:, regime_seq_indices(t));
Adj_t = triu(Adj_t, 1) + triu(Adj_t, 1)';
Adj(:,:,t) = Adj_t;
end