-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis5_v2018.m
117 lines (108 loc) · 3.38 KB
/
analysis5_v2018.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
clear all
load('EC1','-mat')
%load('CA1','-mat')
count=ones(6,3);
percent=99;
total_cells=0;
for index=1:length(data)
if isempty(data{index})~=1
for j=1:length(data{index})
total_cells=total_cells+1;
for aspect=1:6
test=sort(data{index}{j}.TEST.I(aspect,:));
information(aspect,total_cells)=data{index}{j}.I(aspect);
information_delta(aspect,total_cells)=data{index}{j}.I_delta(aspect);
information_theta(aspect,total_cells)=data{index}{j}.I_theta(aspect);
I(aspect,total_cells)=0;
I_delta(aspect,total_cells)=0;
I_theta(aspect,total_cells)=0;
if data{index}{j}.I(aspect)>test(percent)
I(aspect,total_cells)=1;
end
test=sort(data{index}{j}.TEST.I_delta(aspect,:));
if data{index}{j}.I_delta(aspect)>test(99)
I_delta(aspect,total_cells)=1;
end
test=sort(data{index}{j}.TEST.I_theta(aspect,:));
if data{index}{j}.I_theta(aspect)>test(99)
I_theta(aspect,total_cells)=1;
end
end
end
end
end
matrix1=information.*I;
matrix2=information_delta.*I_delta;
matrix3=information_theta.*I_theta;
%comparacion de codigos usando la idea de probabilidad
vector=[1,1,1,0,0,0];
matrix=nchoosek(vector,3);
number=2;
element(1,:)=matrix(1,:);
for i=1:length(matrix)
index=0;
for j=1:size(element,1)
if ~isequal(matrix(i,:),element(j,:))
index=index+1;
end
end
if index==size(element,1)
element(number,:)=matrix(i,:);
number=number+1;
end
end
new_element(1,:)=element(1,:);
number2=2;
for k=1:size(element)
permutations=perms(element(k,:));
for i=1:length(permutations)
index=0;
for j=1:size(new_element,1)
if ~isequal(permutations(i,:),new_element(j,:))
index=index+1;
end
end
if index==size(new_element,1)
new_element(number2,:)=permutations(i,:);
number2=number2+1;
end
end
end
% generate a 3d random vector from a uniform distribution
random_vector=rand(3,total_cells);
random_vector(find(random_vector>0.5))=1;
random_vector(find(random_vector<=0.5))=0;
%compare with I
probability1=zeros(size(new_element,1),1);
for i=1:length(random_vector)
for j=1:size(new_element,1)
if isequal(random_vector(:,i),new_element(j,:)')
probability1(j)=probability1(j)+1;
end
end
end
probability1=probability1/length(random_vector);
h=-sum((probability1+eps).*log((probability1+eps)));
for aspect=1:6
matrix_a(1,:)=I(aspect,:);
matrix_a(2,:)=I_delta(aspect,:);
matrix_a(3,:)=I_theta(aspect,:);
%compare with I
probability=zeros(size(new_element,1),1);
for i=1:length(matrix_a)
for j=1:size(new_element,1)
if isequal(matrix_a(:,i),new_element(j,:)')
probability(j)=probability(j)+1;
end
end
end
probability=probability/length(I);
dkl(aspect)=KLDivergence_v2018(probability,probability1)/h;
subplot(2,3,aspect)
matrix_z=zeros(4,3);
matrix_z(1,1)=probability(1);
matrix_z(2,1:3)=probability(2:4);
matrix_z(3,1:3)=probability(5:7);
matrix_z(4,1)=probability(8);
bar3(matrix_z')
end