-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFig2b.m
73 lines (63 loc) · 1.92 KB
/
Fig2b.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
clear all
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Fig2b.m
%
% This program reproduces Fig.2(b) of the paper, which shows MAE vs T
%
% The proposed algorithm is compared with
% (1) Large Gap Method (by A. Channarond, J. Daudin, and S. Robin, 2012)
% (2) Universal Single Value Thresholding (by S. Chatterjee, 2012)
% (3) Matrix Completion (by R.H. Keshavan, A.Montanari, and S. Oh, 2010)
%
%
% Reference
% E. M. Airoldi, T. B. Costa, S. H. Chan, "Stochastic blockmodel approximation of a graphon:
% Theory and consistent estimation", Advances in Neural Information
% Processing Systems, 2013
%
%
% copy-right 2013
% Harvard University
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Graphon
w = [0.8 0.9 0.4 0.5;
0.1 0.6 0.3 0.2;
0.3 0.2 0.8 0.3;
0.4 0.1 0.2 0.9];
% Random Graphs
T_set = 2:2:40;
T_length = length(T_set);
max_trial = 100;
MAE_SBA = zeros(max_trial,T_length);
for i=1:T_length
fprintf('i = %3g \n', i);
T = T_set(i);
n = 200;
Q = 3;
Delta = 0.2;
parfor trial=1:max_trial
[G2 P_GT2] = construct_a_graph(w,n,T);
clusters_SBA = estimate_blocks_directed(G2,Delta);
[H_SBA P_SBA] = histogram3D(G2,clusters_SBA);
MAE_SBA(trial,i) = norm(P_SBA(:)-P_GT2(:),1)/numel(P_GT2);
end
end
% save('result_fig2b');
% load('result_fig2b');
figure(1);
fontsize = 12;
set(0,'defaultaxesfontsize',fontsize);
set(0,'defaulttextfontsize',fontsize);
fontname = 'Times New Roman';
set(0,'defaultaxesfontname',fontname);
set(0,'defaulttextfontname',fontname);
fontweight = 'normal';
set(0,'defaultaxesfontweight',fontweight);
set(0,'defaulttextfontweight',fontweight);
plot(T_set, log10(mean(MAE_SBA)), 'k-o', 'LineWidth', 2);
legend('Proposed','Location','NE');
xlabel('$2T$','interpreter','latex');
ylabel('$\log_{10}$(MAE)','interpreter','latex');
grid on;