forked from andrewssobral/OnlineLRR-ICML2016
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ev_samples_orpca.m
79 lines (50 loc) · 1.87 KB
/
ev_samples_orpca.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
clear;
config = ev_samples_config();
method = 'orpca';
all_d = config.d;
all_rho = config.rho;
all_rep = config.repetitions;
p = config.p;
n = config.n;
K = config.K;
lambda1 = 1/sqrt(p);
lambda2 = 1/sqrt(p);
%% add path
addpath('OR-PCA/');
%% compute EV for OR-PCA
for k=1:length(all_rep)
rep = all_rep(k);
for j=1:length(all_d)
d = all_d(j);
for rhoidx=1:length(all_rho)
rho = all_rho(rhoidx);
fprintf('OR-PCA: rep = %d, d = %d, rho = %.2f\n', rep, d, rho);
result_file = sprintf(config.result_file_format, method, method, d, rho, rep);
data_file = sprintf(config.data_file_format, d, rho, rep);
load(data_file);
U_all = cell2mat(U);
UUt = U_all * U_all';
traceUUt = trace(UUt);
L = randn(p, d);
A = zeros(d, d);
B = zeros(p, d);
EV = zeros(1, n);
T = 0;
for t=1:n
if mod(t, 1000) == 0
fprintf('OR-PCA: access sample %d, EV = %g\n', t, EV(t-1));
end
tic;
z = Z(:, t);
[r, e] = solve_proj2(z, L, lambda1, lambda2);
A = A + r * r';
B = B + (z-e) * r';
L = update_col_orpca(L, A, B, lambda1);
T = T + toc;
EV(t) = js_compute_EV(L, UUt, traceUUt);
end
save(result_file, 'EV', 'T');
fprintf('save to %s\n', result_file);
end
end
end