-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo_successive_norm.m
106 lines (79 loc) · 2.72 KB
/
demo_successive_norm.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
function results = demo_successive_norm(X,varargin)
opts = struct();
opts.exportfig = true;
opts.exportfun = @(fname)(print('-dpng','-r150',fname));
% if(exist('process_options'))
% [exportfig exportfun opts] = process_options(varargin, ...
% 'exportfig', opts.exportfig, ...
% 'exportfun', opts.exportfun ...
% );
% else
% warning('KPMTools from matlab-library needed to process optional arguments');
% end
exportfig = opts.exportfig;
exportfun = opts.exportfun;
results = {};
results{1}.method = 'Column Standardize';
results{1}.output = standard_correlation(X)
results{2}.method = 'Row-Column Standardize';
results{2}.output = standard_correlation_sn(X)
results{3}.method = 'Row-Column Sym Standardize';
results{3}.output = standard_correlation_sym_sn(X)
disp(sprintf('Frob. MSE: Sigma_c - Sigma_sym = %.3f', ...
norm(abs(results{2}.output.corr-results{3}.output.corr),'fro')));
disp(sprintf('Frob. SSE: Sigma_c - Sigma_sym = %.3f', ...
sum(sum((results{2}.output.corr-results{3}.output.corr).^2)) ));
figure('Position',[50 100 900 650]);
subplot(2,3,1);
imagesc(results{1}.output.corr); axis equal image;
colormap('winter');
title(results{1}.method);
subplot(2,3,2);
imagesc(results{2}.output.corr); axis equal image;
colormap('winter')
title(results{2}.method);
subplot(2,3,3);
imagesc(results{3}.output.corr); axis equal image;
colormap('winter')
title(results{3}.method);
subplot(2,3,4);
histogram(results{1}.output.corr(:),'Normalization','pdf');
axis equal; ylim([-0.1,2]);
title(results{1}.method); xlabel('correlation'); ylabel('pdf')
subplot(2,3,5);
histogram(results{2}.output.corr(:),'Normalization','pdf');
axis equal; ylim([-0.1,2]);
title(results{2}.method);xlabel('correlation'); ylabel('pdf')
subplot(2,3,6);
histogram(results{3}.output.corr(:),'Normalization','pdf');
axis equal; ylim([-0.1,2]);
colormap('winter')
title(results{3}.method);xlabel('correlation'); ylabel('pdf')
fname = ['tmp' filesep datestr(now,'dd-mmm-yyyy-HHMMSS')];
if(~exist(fname,'dir'))
mkdir(fname)
end
exportfun(fullfile(fname,mfilename));
end
function output = standard_correlation(X)
output = struct()
X = standardize.standardize_cols(X);
ggmobj = GGM(X);
ggmobj.MLECovEstimate();
output.corr = ggmobj.Sigma;
end
function output = standard_correlation_sn(X)
output = struct();
X = standardize.successive_normalize(X);
ggmobj = GGM(X);
ggmobj.MLECovEstimate();
output.corr = ggmobj.Sigma;
end
function output = standard_correlation_sym_sn(X)
output = struct();
X = standardize.successive_normalize(X, ...
struct('method','sym'));
ggmobj = GGM(X);
ggmobj.MLECovEstimate();
output.corr = ggmobj.Sigma;
end