From cb96f0abd16dd936ac1db4bda7c5877e0a871cee Mon Sep 17 00:00:00 2001 From: Norbert Marwan Date: Fri, 20 Sep 2024 20:08:40 +0200 Subject: [PATCH] improve entropy calculation --- rqa.m | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/rqa.m b/rqa.m index 90f4eb1..12e26ae 100644 --- a/rqa.m +++ b/rqa.m @@ -162,7 +162,7 @@ % 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)); @@ -170,7 +170,6 @@ 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 @@ -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));