-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo_time_varying.m
130 lines (103 loc) · 4.17 KB
/
demo_time_varying.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
clear;clc; close all;
run_path;
%% N-order streaming tensors
n_exp = 2;
time_frame = 500; % number of temporal slices
tensor_dim = [10 10 10]; % dimension of temporal slices
tucker_rank = [3 3 3];
fac_noise = 1e-3;
outlier_den = 0.1;
outlier_fac = 0;
time_varying_vec = [0 1e-3 1e-2 1e-1];
PER_SEP = zeros(length(time_varying_vec),time_frame);
for jj = 1 : length(time_varying_vec)
time_varying = time_varying_vec(jj);
epsilon = time_varying*ones(time_frame,1);
epsilon(300) = 1;
PER = zeros(1,time_frame);
for ii = 1 : n_exp
fprintf('+ run (%d/%d) \n',jj,ii)
%% Generate streaming data
[X_cell,X_true,Factor_True,Core_True] = online_tensor_dictionary_generator(time_frame,...
tensor_dim,tucker_rank,fac_noise,outlier_fac,outlier_den,epsilon);
%% Main Program
OPTS.Factor_True = Factor_True;
OPTS.Slide_True = X_true;
OPTS.Core_True = Core_True;
[~,PER_ii] = ROTDL(X_cell,tucker_rank,OPTS);
PER = PER + PER_ii(1,:);
end
PER = PER / n_exp;
PER_SEP(jj,:) = PER;
end
%% Plot
makerSize = 14;
numbMarkers = 50;
LineWidth = 2;
set(0, 'defaultTextInterpreter', 'latex');
color = get(groot,'DefaultAxesColorOrder');
red_o = [1,0,0];
blue_o = [0, 0, 1];
gree_o = 'g'; %[0, 0.5, 0];
black_o = [0.25, 0.25, 0.25];
blue_n = color(1,:);
oran_n = color(2,:);
yell_n = color(3,:);
viol_n = color(4,:);
gree_n = color(5,:);
lblu_n = color(6,:);
brow_n = color(7,:);
lbrow_n = [0.5350 0.580 0.2840];
fig = figure;
k = 1;
hold on;
d1 = semilogy(1:k:time_frame,PER_SEP(1,1:k:end),...
'linestyle','-','color',blue_o,'LineWidth',LineWidth);
d11 = plot(1:50:time_frame,PER_SEP(1,1:50:end),...
'marker','o','markersize',makerSize,...
'linestyle','none','color',blue_o,'LineWidth',2);
d12 = semilogy(1:1,PER_SEP(1,1),...
'marker','o','markersize',makerSize,...
'linestyle','-','color',blue_o,'LineWidth',2);
d2 = semilogy(1:k:time_frame,PER_SEP(2,1:k:end),...
'linestyle','-','color',red_o,'LineWidth',LineWidth);
d21 = plot(1:50:time_frame,PER_SEP(2,1:50:end),...
'marker','d','markersize',makerSize,...
'linestyle','none','color',red_o,'LineWidth',2);
d22 = semilogy(1:1,PER_SEP(2,1),...
'marker','d','markersize',makerSize,...
'linestyle','-','color',red_o,'LineWidth',2);
d3 = semilogy(1:k:time_frame,PER_SEP(3,1:k:end),...
'linestyle','-','color',gree_o,'LineWidth',LineWidth);
d31 = plot(1:50:time_frame,PER_SEP(3,1:50:end),...
'marker','h','markersize',makerSize,...
'linestyle','none','color',gree_o,'LineWidth',2);
d32 = semilogy(1:1,PER_SEP(3,1),...
'marker','h','markersize',makerSize,...
'linestyle','-','color',gree_o,'LineWidth',2);
d4 = semilogy(1:k:time_frame,PER_SEP(4,1:k:end),...
'linestyle','-','color',black_o,'LineWidth',LineWidth);
d41 = plot(1:50:time_frame,PER_SEP(4,1:50:end),...
'marker','s','markersize',makerSize,...
'linestyle','none','color',black_o,'LineWidth',2);
d42 = semilogy(1:1,PER_SEP(4,1),...
'marker','s','markersize',makerSize,...
'linestyle','-','color',black_o,'LineWidth',2);
lgd = legend([d12 d22 d32 d42],'$\varepsilon = 0$','$\varepsilon = 10^{-3}$','$\varepsilon = 10^{-2}$','$\varepsilon = 10^{-1}$');
lgd.FontSize = 28;
set(lgd, 'Interpreter', 'latex', 'Color', [0.95, 0.95, 0.95]);
ylabel('SEP $(\mathcal{D}_{tr}, \mathcal{D}_{es})$','interpreter','latex','FontSize',13,'FontName','Times New Roman');
xlabel('Time Index','interpreter','latex','FontSize',13,'FontName','Times New Roman');
%
h=gca;
set(gca, 'YScale', 'log');
yticks([1e-8 1e-5 1e-2 1e1 ])
yticklabels({'10^{-8}','10^{-5}','10^{-2}','10^{1}'})
set(h,'FontSize',16,'XGrid','on','YGrid','on','GridLineStyle','-','MinorGridLineStyle','-','FontName','Times New Roman');
set(h,'Xtick',0:100:time_frame,'FontSize',16,'XGrid','on','YGrid','on','GridLineStyle',':','MinorGridLineStyle','none',...
'FontName','Times New Roman');
set(h,'FontSize', 30);
grid on;
box on;
axis([0 time_frame 1e-10 1e1])
set(fig, 'units', 'inches', 'position', [0.5 0.5 10 7]);