Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

xcorr functional equivalent for linear-cirlcular cross-correlation?

7 views
Skip to first unread message

Evan Ruzanski

unread,
Nov 24, 2009, 7:40:22 PM11/24/09
to
Hello,

I'm trying to generate an estimate of the cross-correlation function for 2 time series. One time series is linear (domain -Inf - Inf) and the other is azimuthal (domain 0 - 2pi). If both functions were linear, I would simply use xcorr and be done. But here I can't do that.

I've searched this site and found the (very useful) Circular Statistics Toolbox which has a function called "circ_corrcl" which computes the correlation coefficient between a vector of samples representing a linear random variable and a vector of samples representing a circular random variable. However, this function only gives one correlation coefficient value and one p-value as output.

How can I generate an estimate of the cross-correlation function (i.e., a vector of length 2N - 1 where N is the length of the input vectors) analogous to that of xcorr representing correlation between time series of linear and circular variables?

Evan Ruzanski

unread,
Nov 24, 2009, 8:59:05 PM11/24/09
to
Hello again,

I examined 'circ_corrcl.m' and found the following lines of code which do the computation of the correlation coefficient between a linear and an angular vector:

% compute correlation coefficent for sin and cos independently
rxs = corr(x,sin(alpha));
rxc = corr(x,cos(alpha));
rcs = corr(sin(alpha),cos(alpha));

% compute angular-linear correlation (equ. 27.47)
rho = sqrt((rxc^2 + rxs^2 - 2*rxc*rxs*rcs)/(1-rcs^2));

Shouldn't I just be able to rewrite this as:

% compute correlation coefficent for sin and cos independently
rxs = xcorr(x,sin(alpha),'coeff');
rxc = xcorr(x,cos(alpha),'coeff');
rcs = xcorr(sin(alpha),cos(alpha),'coeff');

% compute angular-linear correlation (equ. 27.47)
rho = sqrt((rxc.^2 + rxs.^2 - 2.*rxc.*rxs.*rcs)/(1-rcs.^2));

Does this make sense???

I generated some test data:

ws1 = [1 2 1]; % Linear values
ws2 = [350 355 5]*pi/180; % Angular values

Then I run the amended code to get:

>> rxs = xcorr(ws1,sin(ws2),'coeff')

rxs =

0.1671 0.1671 -0.5000 -0.8329 -0.3329

>> rxc = xcorr(ws1,cos(ws2),'coeff')

rxc =

0.2366 0.7098 0.9437 0.7044 0.2339

>> rcs = xcorr(sin(ws2),cos(ws2),'coeff')

rcs =

-0.4726 -0.7098 -0.4672 0.0027 0.2345

>> rho_series = sqrt((rxc.^2 + rxs.^2 - 2*rxc.*rxs.*rcs)./(1 - rcs.^2))

rho_series =

0.3951 1.1878 0.9461 1.0923 0.4624

But now some values exceed unity, which doesn't make sense...

So I changed the normalization constant:

rho_series = sqrt((rxc.^2 + rxs.^2 - 2*rxc.*rxs.*rcs)./sum((1 - rcs.^2)))

And get:

rho_series =

0.1741 0.4184 0.4183 0.5462 0.2248

Which looks reasonable...

Anyone have comments on this???

"Evan Ruzanski" <ruzan...@engr.colostate.edu> wrote in message <hehudl$mh8$1...@fred.mathworks.com>...

Evan Ruzanski

unread,
Nov 24, 2009, 9:21:03 PM11/24/09
to
I had another idea...why just unwrap the angular variable???

>> ws1 = [1 2 1];

>> ws2 = [350 355 5]*pi/180;

>> ws3 = unwrap(ws2)

ws3 =

6.1087 6.1959 6.3705

>> wsCorr = xcorr(ws1,ws3,'coeff')

wsCorr =

0.2412 0.7169 0.9416 0.6971 0.2313

Does anyone have a comment on this approach?

Thank again...
Evan

"Evan Ruzanski" <ruzan...@engr.colostate.edu> wrote in message <hehudl$mh8$1...@fred.mathworks.com>...

0 new messages