-
Notifications
You must be signed in to change notification settings - Fork 0
/
Table2.m
73 lines (60 loc) · 1.94 KB
/
Table2.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
clear all
close all
clc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This routine reproduces the results of Table 2
%
% Stanley Chan
% Harvard University
% Dec 28, 2013
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
addpath(genpath('./deconvtv_v1/'));
n = 200; % Toggle with n = 1000;
max_trial = 50; % Our experiment sets max_trial = 50
mse_sas = zeros(10,max_trial);
mse_usvt = zeros(10,max_trial);
mse_sba = zeros(10,max_trial);
t_sas = zeros(10,max_trial);
t_usvt = zeros(10,max_trial);
t_sba = zeros(10,max_trial);
% Main Loop
for cidx = 1:10
caseid = cidx;
fprintf('cidx = %3g, \n', cidx);
for trial=1:max_trial
fprintf('trial = %3g, \n', trial);
% Generate a graphon
wtrue = gen_graphon(n,caseid);
% Sample a random graph from the graphon
G = construct_a_graph_from_P(wtrue,n,1);
pidx = randperm(n);
G = G(pidx,pidx);
% Apply Sort and Smooth
t0 = tic;
wsas = sort_and_smooth(G);
t_sas(cidx,trial) = toc(t0);
% Apply USVT
t1 = tic;
wusvt = usvt(G);
t_usvt(cidx,trial) = toc(t1);
% Apply Stochastic Blockmodel Approximation
t2 = tic;
if trial==1
h = oracle_h(G,wtrue);
end
wsba = stochastic_block(G,h);
t_sba(cidx,trial) = toc(t2);
% Record MSE
mse_sas(cidx,trial) = 0;%mean((wsas(:) -wtrue(:)).^2);
mse_usvt(cidx,trial) = 0;%mean((wusvt(:)-wtrue(:)).^2);
mse_sba(cidx,trial) = mean((wsba(:) -wtrue(:)).^2);
end
end
% Display results
fprintf('ID \t SAS \t USVT \t SBA \n');
for cidx = 1:10
fprintf('%3g \t %2.2e +/- %2.2e \t %2.2e +/- %2.2e \t %2.2e +/- %2.2e \n', cidx, ...
mean(mse_sas(cidx,:)), std(mse_sas(cidx,:)), ...
mean(mse_usvt(cidx,:)), std(mse_usvt(cidx,:)), ...
mean(mse_sba(cidx,:)), std(mse_sba(cidx,:)));
end