Thread Subject: xcorr functional equivalent for linear-cirlcular cross-correlation?

Subject: xcorr functional equivalent for linear-cirlcular cross-correlation?

From: Evan Ruzanski

Date: 25 Nov, 2009 00:40:22

Message: 1 of 3

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?

Subject: xcorr functional equivalent for linear-cirlcular cross-correlation?

From: Evan Ruzanski

Date: 25 Nov, 2009 01:59:05

Message: 2 of 3

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" <ruzanski.02@engr.colostate.edu> wrote in message <hehudl$mh8$1@fred.mathworks.com>...
> 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?

Subject: xcorr functional equivalent for linear-cirlcular cross-correlation?

From: Evan Ruzanski

Date: 25 Nov, 2009 02:21:03

Message: 3 of 3

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" <ruzanski.02@engr.colostate.edu> wrote in message <hehudl$mh8$1@fred.mathworks.com>...
> 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?

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
time series ana... Evan Ruzanski 24 Nov, 2009 19:44:06
linearcircular ... Evan Ruzanski 24 Nov, 2009 19:44:06
crosscorrelation Evan Ruzanski 24 Nov, 2009 19:44:05
rssFeed for this Thread

Contact us at files@mathworks.com