-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtwoParameterTest.m
118 lines (74 loc) · 3.26 KB
/
twoParameterTest.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
%% Two parameter (k,T) variability
T = 0:0.05:0.9;
K = 10;
N = 1000;
clear f_rho_within
% Within
MaxNumberOfCorrValues_surrounding = max(cellfun(@(x) length(x),correlations_surrounding));
for ii = 1:length(T)
for k = 0:K-1
valid_within_prev = zeros(1,N);
values_that_pass_thres = [];
for jj = 1:N
rnd_idx = randi(length(correlations_surrounding),1);
values_that_pass_thres = correlations_surrounding{rnd_idx}(:)>T(ii);
% Take central value
L = length(correlations_surrounding{rnd_idx});
m = ceil(L/2); % central location
central_loc_value = values_that_pass_thres(m);
% Count of correlations samples above a threshold T
% valid_within(k,jj) = sum(values_that_pass_thres);
% Count of the correlations values that pass a threshold TOGETHER
% with its previous sample(s)
valid_within_prev(jj) = sum([values_that_pass_thres(k+1:end); zeros(k,1)] & ...
values_that_pass_thres);
end % end for N number of random picks at the different queries.
f_rho_within(ii,k+1) = sum(valid_within_prev)/(N*MaxNumberOfCorrValues_surrounding);
end % end for K
% sum1_within(ii) = sum(valid_within)/(N*size(cat(2,correlations_surrounding{:}),2));
% sum2_within(ii) = sum(valid_within_prev)/(N*size(cat(2,correlations_surrounding{:}),2));
end % end for T threshold
%% Between
MaxNumberOfCorrValues_beyond = max(cellfun(@(x) length(x),correlations_beyond));
for ii = 1:length(T)
valid_beyond_prev = zeros(K,N);
for k = 0:K-1
for jj = 1:N
rnd_idx = randi(length(correlations_beyond),1);
values_that_pass_thres = correlations_beyond{rnd_idx}(:)>T(ii);
% Take central value
L = length(correlations_beyond{rnd_idx});
m = ceil(L/2); % central location
central_loc_value = values_that_pass_thres(m);
% Count of correlations samples above a threshold T
% valid_within(k,jj) = sum(values_that_pass_thres);
% Count of the correlations values that pass a threshold TOGETHER
% with its previous sample(s)
valid_beyond_prev(k+1,jj) = sum([values_that_pass_thres(k+1:end); zeros(k,1)] & ...
values_that_pass_thres);
end % end for N number of random picks at the different queries.
f_rho_between(ii,k+1) = sum(valid_beyond_prev(k+1,:))/(N*MaxNumberOfCorrValues_beyond);
end % end for K
% sum1_within(ii) = sum(valid_within)/(N*size(cat(2,correlations_surrounding{:}),2));
% sum2_within(ii) = sum(valid_within_prev)/(N*size(cat(2,correlations_surrounding{:}),2));
end % end for T threshold
%% Plots
%% Separate
figure
[X,Y] = meshgrid(0:K-1,T);
surf(X,Y,f_rho_within)
title('within')
figure
surf(X,Y,f_rho_between)
title('between');
%% Overlaying both
figure
[X,Y] = meshgrid(0:K-1,T);
colormap summer
hSurface = surf(X,Y,f_rho_within);
set(hSurface,'FaceColor',[0 0 1],'FaceAlpha',0.5);
% title('within')
hold on
hSurface2 = surf(X,Y,f_rho_between);
set(hSurface2,'FaceColor',[1 0 0],'FaceAlpha',0.5);
% title('between');