-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresults_generate_plots.m
80 lines (68 loc) · 1.43 KB
/
results_generate_plots.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
function [] = results_generate_plots(X,true_f,range)
nbins = 10;
try
range;
catch
range = 1:size(X,1);
end
X = X(range,:);
try
fval = true_f;
str = 'g--';
catch
fval = zeros(size(X,1),1);
str = 'r--';
end
figure
plot(X');
title ('Variable trace')
figure
plot_mean_acf(X,50)
c = range(1);
for f = 1:floor(size(X,1)/12)
figure
for s = 1:12
subplot(3,4,s);
n = hist(X(c,:),nbins);
m = max(n) + round(0.5*max(n));
hist(X(c,:),nbins);
hold on;
plot(fval(c)*ones(m,1),1:m,str);
title (['var ',num2str(c)]);
c = c+1;
end
end
rem = mod(size(X,1),12);
if rem > 0
figure
for s = 1:rem
subplot(3,4,s);
n = hist(X(c,:),nbins);
m = max(n) + round(0.5*max(n));
hist(X(c,:),nbins);
hold on;
plot(fval(c)*ones(m,1),1:m,str);
title (['var ',num2str(c)]);
c = c + 1;
end
end
end
function [] = plot_mean_acf(X, max_lag)
n = size(X,1);
t = size(X,2);
mean_acf = zeros(1,t);
for i = 1:n
acf = xcorr(detrend(X(i,:),'constant'),'coeff');
mean_acf = mean_acf + acf(t:end);
if i == 1
subplot(2,1,1)
a = acf(t:end);
stem(a(1:max_lag));
title 'Variable 1';
end
end
mean_acf = mean_acf / n;
subplot(2,1,2)
stem(mean_acf(1:max_lag));
title 'Mean of all variables'
end