-
Notifications
You must be signed in to change notification settings - Fork 2
/
C_intra.m
executable file
·66 lines (61 loc) · 1.66 KB
/
C_intra.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
function [intra] = C_intra(C)
%% compute Intradistance for a constellation
% C: Constellation (cell with first column the distributions, secondo
% column the small phi value)
% option:
if isempty(C)
intra = 0;
return
end
opt_EMD = 0; %1: Use EMD to compute distance between distribution,
%0: Use the interdistance between distributions
opt_fi_count = 0; %1: the difference in phi counts for the intra-distance
if opt_fi_count == 1
Nc=size(C,1);
N=length(C{1,1});
tot = 0;
% Wc=0;
if opt_EMD==1
for i=1:Nc
% Wc=Wc+C{i,2};
for j =(i+1) : Nc
tot = tot + (emd_hat_gd_metric_mex(C{i,1},C{j,1},gen_dist_matrix(N))+abs(C{i,2}-C{j,2})) * sqrt(C{i,2}*C{j,2});
end
end
% tot = tot/Wc^2;
else
for i=1:Nc
Wc=Wc+C{i,2};
for j =(i+1) : Nc
tot = tot + k_inter(C{i,1},C{j,1})* C{i,2}*C{j,2};
end
end
% tot = tot/Wc^2;
end
intra = tot;
else
Nc=size(C,1);
N=length(C{1,1});
tot = 0;
if opt_EMD==1
for i=1:Nc
for j =(i+1) : Nc
tot = tot + emd_hat_gd_metric_mex(C{i,1},C{j,1},gen_dist_matrix(N)) * sqrt(C{i,2}*C{j,2});
end
end
if Nc>1
% tot = tot/sqrt(nchoosek(Nc,2));
end
else
for i=1:Nc
for j =(i+1) : Nc
tot = tot + k_inter(C{i,1},C{j,1})* sqrt(C{i,2}*C{j,2});
end
end
if Nc>1
% tot = tot/nchoosek(Nc,2);
end
end
intra = tot;
end
end