how to compare two time series of same length using sample entropy?

Hello! I am studying the behavior of two centroids (geometric centers) of two soccer teams during a small-sided game. I have already computed the centroids coordinates (x,y) across time and they are stored in my workspace as 'centroidA' (for team A) and 'centroidB' (for team B). Each of the aforementioned variables has several lines and two columns, the first being for the x- coordinates and the second column being for the y- coordinates. I want to verify how much coupled are the two centroids in the x- and y- directions using sample entropy!
I've found this code, but it can only take one time-series:
function [e,A,B]=Samplentropy(y,M,r)
%function [e,A,B]=sampenc(y,M,r);
%
%Input
%
%y input data
%M maximum template length
%r matching tolerance
%
%Output
%
%e sample entropy estimates for m=0,1,...,M-1
%A number of matches for m=1,...,M
%B number of matches for m=1,...,M excluding last point
n=length(y);
lastrun=zeros(1,n);
run=zeros(1,n);
A=zeros(M,1);
B=zeros(M,1);
p=zeros(M,1);
e=zeros(M,1);
for i=1:(n-1)
nj=n-i;
y1=y(i);
for jj=1:nj
j=jj+i;
if abs(y(j)-y1)<r
run(jj)=lastrun(jj)+1;
M1=min(M,run(jj));
for m=1:M1
A(m)=A(m)+1;
if j<n
B(m)=B(m)+1;
end
end
else
run(jj)=0;
end
end
for j=1:nj
lastrun(j)=run(j);
end
end
N=n*(n-1)/2;
p(1)=A(1)/N;
e(1)=-log(p(1));
for m=2:M
p(m)=A(m)/B(m-1);
e(m)=-log(p(m));
end
Hope you can help!
Best wishes,
Pedro

 Réponse acceptée

Wayne King
Wayne King le 20 Oct 2012
If you want to compare the dependence of two time series using an information theoretic approach, a common thing to do is use mutual information. If you search the file exchange or the web, you'll find a number of MATLAB files to compute the mutual information.

2 commentaires

@Wayne King those codes are for discrete variables right? what about continuous?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by