Thread Subject: Complex Number Covariance Matrix

Subject: Complex Number Covariance Matrix

From: David Doria

Date: 24 Mar, 2008 21:57:01

Message: 1 of 5

I have 2 phasors (just complex numbers represented as
vectors) x and y that are spinning and stretching (so
changing both the real and imag components). I take a
"snapshot" of each of these every time interval (T). (So I
now have x1, x2, x3...etc and y1, y2, y3, etc...) I would
like to see how similar x and y were at each time, so I
think this means I would like to find the sample covariance

(1/N) * SUM( (x_i-ux)*(y_i-uy) )
         i

of x and y where ux=mean(x) and uy=mean(y) where x and y are
complex vectors (a+bi).

Is there a way to do this that makes sense?

Thanks,

David

Subject: Complex Number Covariance Matrix

From: Roger Stafford

Date: 25 Mar, 2008 01:30:20

Message: 2 of 5

"David Doria" <daviddoria@gmail.com> wrote in message <fs983d$ofr
$1@fred.mathworks.com>...
> I have 2 phasors (just complex numbers represented as
> vectors) x and y that are spinning and stretching (so
> changing both the real and imag components). I take a
> "snapshot" of each of these every time interval (T). (So I
> now have x1, x2, x3...etc and y1, y2, y3, etc...) I would
> like to see how similar x and y were at each time, so I
> think this means I would like to find the sample covariance
>
> (1/N) * SUM( (x_i-ux)*(y_i-uy) )
> i
>
> of x and y where ux=mean(x) and uy=mean(y) where x and y are
> complex vectors (a+bi).
>
> Is there a way to do this that makes sense?
>
> Thanks,
>
> David
----------
  Assuming x and y are complex-valued column vectors of the same length, if
you compute

 c = cov(x,y,1);

this will give you a 2 x 2 matrix in which the two diagonals are the two
(biased) variances of x and y, and the two off-diagonal elements c(1,2) and c
(2,1) are the (biased) covariances

 1/n*sum((x-ux)'*(y-uy)) % (Note the conjugate transpose.)

and its complex conjugate, respectively.

  It is up to you to decide if that is what you want as a measure of similarity. I
believe that is what is usually meant by the covariance of complex quantities.

  However, I would have thought you would prefer to use correlation values in
which the above quantities are normalized using the variances.

Roger Stafford

Subject: Complex Number Covariance Matrix

From: David Doria

Date: 25 Mar, 2008 11:13:03

Message: 3 of 5

So if I do:
(1/(n*sigma_x * sigma_y) * sum((x-ux)'*(y-uy))

where sigma is the sample standard deviation, Will this give
numbers between 0 and 1? (0 is "uncorrelated" and near 1 is
"highly correlated") My problem before was I was getting
numbers like 8 or 10, and I didn't know if those were "good"
or "bad".

Thanks,

Dave

> this will give you a 2 x 2 matrix in which the two
diagonals are the two
> (biased) variances of x and y, and the two off-diagonal
elements c(1,2) and c
> (2,1) are the (biased) covariances
>
> 1/n*sum((x-ux)'*(y-uy)) % (Note the conjugate transpose.)
>
> and its complex conjugate, respectively.
>
> It is up to you to decide if that is what you want as a
measure of similarity. I
> believe that is what is usually meant by the covariance of
complex quantities.
>
> However, I would have thought you would prefer to use
correlation values in
> which the above quantities are normalized using the variances.
>
> Roger Stafford
>

Subject: Complex Number Covariance Matrix

From: David Doria

Date: 25 Mar, 2008 12:18:02

Message: 4 of 5

So I tried this:

a = 5*rand(10, 1) + i*5*rand(10, 1);
b = 5*rand(10, 1) + i*5*rand(10, 1);

u_a = mean(a);
u_b = mean(b);

a=a-ua;
b=b-ub;

c=corrcoef(a,b)

but the off diagonals are complex numbers - I want a
positive value between 0 and 1 - is the magnitude a good
enough value? or is there a better way?

Thanks,

David

Subject: Complex Number Covariance Matrix

From: Roger Stafford

Date: 26 Mar, 2008 01:40:05

Message: 5 of 5

"David Doria" <daviddoria@gmail.com> wrote in message <fsaqhp$p6m
$1@fred.mathworks.com>...
> So I tried this:
>
> a = 5*rand(10, 1) + i*5*rand(10, 1);
> b = 5*rand(10, 1) + i*5*rand(10, 1);
>
> u_a = mean(a);
> u_b = mean(b);
>
> a=a-ua;
> b=b-ub;
>
> c=corrcoef(a,b)
>
> but the off diagonals are complex numbers - I want a
> positive value between 0 and 1 - is the magnitude a good
> enough value? or is there a better way?
>
> Thanks,
>
> David
---------
  Yes, if you recall, I stated that the two off-diagonal elements of the
covariance matrix are complex conjugates of one another, and indeed they
will in general be complex-valued for complex-valued arguments, x and y. It
is only the variances along the diagonal that are assured of being real-valued.
In other words, the covariance matrix is always Hermitian.

  In the case of 'corrcoef', which also gives a Hermitian matrix, you are
guaranteed that the absolute value of the corresponding correlation
coefficients will lie between 0 and 1, so using that is a possibility for what you
are doing.

  However, you will note that in taking the absolute value, you will have
thereby eliminated negative correlation values which indicate opposite-sense
relationships. My intuition tells me that the real and imaginary parts of the
correlation coefficients, which must lie inside the unit circle in the complex
plane, actually tell you something significant about the nature of correlation
in the real and imaginary parts of your two variables x and y. Earlier you
referred to a "spinning and stretching", and in all likelihood the location of a
complex coefficient within that circle tells you something significant about
the relative amounts of correlation in these two characteristics.

 If you write x = rx*exp(i*tx) and y = ry*exp(i*ty) where the r's and t's are
real, in taking the covariance you are summing rx*ry*exp(i*(ty-tx)) over all
the sample. To get a correlation with an absolute value near 1 at a certain
angle would indicate that x and y typically occurred with an approximately
fixed amount of angle difference of that amount.

  It is up to you as to what role you wish your correlation coefficient to play in
your analysis.

Roger Stafford


Tags for this Thread

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com