<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166283</link>
    <title>MATLAB Central Newsreader - Complex Number Covariance Matrix</title>
    <description>Feed for thread: Complex Number Covariance Matrix</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 24 Mar 2008 21:57:01 -0400</pubDate>
      <title>Complex Number Covariance Matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166283#422586</link>
      <author>David Doria</author>
      <description>I have 2 phasors (just complex numbers represented as&lt;br&gt;
vectors) x and y that are spinning and stretching (so&lt;br&gt;
changing both the real and imag components).  I take a&lt;br&gt;
&quot;snapshot&quot; of each of these every time interval (T). (So I&lt;br&gt;
now have x1, x2, x3...etc and y1, y2, y3, etc...) I would&lt;br&gt;
like to see how similar x and y were at each time, so I&lt;br&gt;
think this means I would like to find the sample covariance&lt;br&gt;
&lt;br&gt;
(1/N) * SUM( (x_i-ux)*(y_i-uy) )&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;i&lt;br&gt;
&lt;br&gt;
of x and y where ux=mean(x) and uy=mean(y) where x and y are&lt;br&gt;
complex vectors (a+bi).&lt;br&gt;
&lt;br&gt;
Is there a way to do this that makes sense?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
David</description>
    </item>
    <item>
      <pubDate>Tue, 25 Mar 2008 01:30:20 -0400</pubDate>
      <title>Re: Complex Number Covariance Matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166283#422607</link>
      <author>Roger Stafford</author>
      <description>&quot;David Doria&quot; &amp;lt;daviddoria@gmail.com&amp;gt; wrote in message &amp;lt;fs983d$ofr&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; I have 2 phasors (just complex numbers represented as&lt;br&gt;
&amp;gt; vectors) x and y that are spinning and stretching (so&lt;br&gt;
&amp;gt; changing both the real and imag components).  I take a&lt;br&gt;
&amp;gt; &quot;snapshot&quot; of each of these every time interval (T). (So I&lt;br&gt;
&amp;gt; now have x1, x2, x3...etc and y1, y2, y3, etc...) I would&lt;br&gt;
&amp;gt; like to see how similar x and y were at each time, so I&lt;br&gt;
&amp;gt; think this means I would like to find the sample covariance&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; (1/N) * SUM( (x_i-ux)*(y_i-uy) )&lt;br&gt;
&amp;gt;          i&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; of x and y where ux=mean(x) and uy=mean(y) where x and y are&lt;br&gt;
&amp;gt; complex vectors (a+bi).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is there a way to do this that makes sense?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; David&lt;br&gt;
----------&lt;br&gt;
&amp;nbsp;&amp;nbsp;Assuming x and y are complex-valued column vectors of the same length, if &lt;br&gt;
you compute&lt;br&gt;
&lt;br&gt;
&amp;nbsp;c = cov(x,y,1);&lt;br&gt;
&lt;br&gt;
this will give you a 2 x 2 matrix in which the two diagonals are the two &lt;br&gt;
(biased) variances of x and y, and the two off-diagonal elements c(1,2) and c&lt;br&gt;
(2,1) are the (biased) covariances&lt;br&gt;
&lt;br&gt;
&amp;nbsp;1/n*sum((x-ux)'*(y-uy))  % (Note the conjugate transpose.)&lt;br&gt;
&lt;br&gt;
and its complex conjugate, respectively.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;It is up to you to decide if that is what you want as a measure of similarity.  I &lt;br&gt;
believe that is what is usually meant by the covariance of complex quantities.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;However, I would have thought you would prefer to use correlation values in &lt;br&gt;
which the above quantities are normalized using the variances.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Tue, 25 Mar 2008 11:13:03 -0400</pubDate>
      <title>Re: Complex Number Covariance Matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166283#422660</link>
      <author>David Doria</author>
      <description>So if I do:&lt;br&gt;
(1/(n*sigma_x * sigma_y) * sum((x-ux)'*(y-uy))&lt;br&gt;
&lt;br&gt;
where sigma is the sample standard deviation, Will this give&lt;br&gt;
numbers between 0 and 1? (0 is &quot;uncorrelated&quot; and near 1 is&lt;br&gt;
&quot;highly correlated&quot;)  My problem before was I was getting&lt;br&gt;
numbers like 8 or 10, and I didn't know if those were &quot;good&quot;&lt;br&gt;
or &quot;bad&quot;.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
Dave&lt;br&gt;
&lt;br&gt;
&amp;gt; this will give you a 2 x 2 matrix in which the two&lt;br&gt;
diagonals are the two &lt;br&gt;
&amp;gt; (biased) variances of x and y, and the two off-diagonal&lt;br&gt;
elements c(1,2) and c&lt;br&gt;
&amp;gt; (2,1) are the (biased) covariances&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  1/n*sum((x-ux)'*(y-uy))  % (Note the conjugate transpose.)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; and its complex conjugate, respectively.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   It is up to you to decide if that is what you want as a&lt;br&gt;
measure of similarity.  I &lt;br&gt;
&amp;gt; believe that is what is usually meant by the covariance of&lt;br&gt;
complex quantities.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   However, I would have thought you would prefer to use&lt;br&gt;
correlation values in &lt;br&gt;
&amp;gt; which the above quantities are normalized using the variances.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
&amp;gt; </description>
    </item>
    <item>
      <pubDate>Tue, 25 Mar 2008 12:18:02 -0400</pubDate>
      <title>Re: Complex Number Covariance Matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166283#422669</link>
      <author>David Doria</author>
      <description>So I tried this:&lt;br&gt;
&lt;br&gt;
a = 5*rand(10, 1) + i*5*rand(10, 1);&lt;br&gt;
b = 5*rand(10, 1) + i*5*rand(10, 1);&lt;br&gt;
&lt;br&gt;
u_a = mean(a);&lt;br&gt;
u_b = mean(b);&lt;br&gt;
&lt;br&gt;
a=a-ua;&lt;br&gt;
b=b-ub;&lt;br&gt;
&lt;br&gt;
c=corrcoef(a,b)&lt;br&gt;
&lt;br&gt;
but the off diagonals are complex numbers - I want a &lt;br&gt;
positive value between 0 and 1 - is the magnitude a good &lt;br&gt;
enough value? or is there a better way?&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
David</description>
    </item>
    <item>
      <pubDate>Wed, 26 Mar 2008 01:40:05 -0400</pubDate>
      <title>Re: Complex Number Covariance Matrix</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/166283#422827</link>
      <author>Roger Stafford</author>
      <description>&quot;David Doria&quot; &amp;lt;daviddoria@gmail.com&amp;gt; wrote in message &amp;lt;fsaqhp$p6m&lt;br&gt;
$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; So I tried this:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a = 5*rand(10, 1) + i*5*rand(10, 1);&lt;br&gt;
&amp;gt; b = 5*rand(10, 1) + i*5*rand(10, 1);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; u_a = mean(a);&lt;br&gt;
&amp;gt; u_b = mean(b);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; a=a-ua;&lt;br&gt;
&amp;gt; b=b-ub;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; c=corrcoef(a,b)&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; but the off diagonals are complex numbers - I want a &lt;br&gt;
&amp;gt; positive value between 0 and 1 - is the magnitude a good &lt;br&gt;
&amp;gt; enough value? or is there a better way?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; David&lt;br&gt;
---------&lt;br&gt;
&amp;nbsp;&amp;nbsp;Yes, if you recall, I stated that the two off-diagonal elements of the &lt;br&gt;
covariance matrix are complex conjugates of one another, and indeed they &lt;br&gt;
will in general be complex-valued for complex-valued arguments, x and y.  It &lt;br&gt;
is only the variances along the diagonal that are assured of being real-valued.  &lt;br&gt;
In other words, the covariance matrix is always Hermitian.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;In the case of 'corrcoef', which also gives a Hermitian matrix, you are &lt;br&gt;
guaranteed that the absolute value of the corresponding correlation &lt;br&gt;
coefficients will lie between 0 and 1, so using that is a possibility for what you &lt;br&gt;
are doing.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;However, you will note that in taking the absolute value, you will have &lt;br&gt;
thereby eliminated negative correlation values which indicate opposite-sense &lt;br&gt;
relationships.  My intuition tells me that the real and imaginary parts of the &lt;br&gt;
correlation coefficients, which must lie inside the unit circle in the complex &lt;br&gt;
plane, actually tell you something significant about the nature of correlation &lt;br&gt;
in the real and imaginary parts of your two variables x and y.  Earlier you &lt;br&gt;
referred to a &quot;spinning and stretching&quot;, and in all likelihood the location of a &lt;br&gt;
complex coefficient within that circle tells you something significant about &lt;br&gt;
the relative amounts of correlation in these two characteristics.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;If you write x = rx*exp(i*tx) and y = ry*exp(i*ty) where the r's and t's are &lt;br&gt;
real, in taking the covariance you are summing rx*ry*exp(i*(ty-tx)) over all &lt;br&gt;
the sample.  To get a correlation with an absolute value near 1 at a certain &lt;br&gt;
angle would indicate that x and y typically occurred with an approximately &lt;br&gt;
fixed amount of angle difference of that amount.&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;It is up to you as to what role you wish your correlation coefficient to play in &lt;br&gt;
your analysis.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
  </channel>
</rss>

