Skip to content

Commit

Permalink
improve entropy calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
pucicu committed Sep 20, 2024
1 parent 4ce5258 commit cb96f0a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions rqa.m
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,14 @@

% line length entropy
l_classes = sum(l_hist~=0); % number of occupied bins (for normalization of entropy)
l_prob = l_hist/sum(l_hist); % get probability distribution from histogram
l_prob = l_hist(l_hist~=0)/sum(l_hist(l_hist~=0)); % get probability distribution from histogram
ent_Sum = (l_prob .* log(l_prob));
if l_classes > 1
y(5) = -nansum(ent_Sum)/log(N(1));
else
y(5) = -nansum(ent_Sum);
end


% histogram of vertical lines
v_hist = zeros(1,N(1)); % allocate vector
for i = 1:N(1) % walk along the columns
Expand Down Expand Up @@ -242,7 +241,7 @@

% recurrence time entropy
rt_classes = sum(rt_hist~=0); % number of occupied bins (for normalization of entropy)
rt_prob = rt_hist/sum(rt_hist); % get probability distribution from histogram
rt_prob = rt_hist(rt_hist~=0)/sum(rt_hist(rt_hist~=0)); % get probability distribution from histogram
ent_Sum = (rt_prob .* log(rt_prob));
if rt_classes > 1
y(11) = -nansum(ent_Sum)/log(N(1));
Expand Down

0 comments on commit cb96f0a

Please sign in to comment.