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

asymmetric correlation matrix?

1 view
Skip to first unread message

Benedikt F

unread,
Feb 13, 2012, 12:26:10 PM2/13/12
to
Hi everyone,
I tried the following code and was surprised by the result:

Ts = randn(200,1000); %random data
Rtest = corrcoef(Ts); %get correlation matrix of these
isequal(Rtest,Rtest.') %check correlation matrix for symmetry
-> ans = 0

The asymmetry is about the rounding error, but where does it come from? If each symmetric value is computed once and then assigned twice, this should't happen.
When I use my real data instead of random, the correlation matrix is completely symmetric.

I'm using R2011b 32-bit on Ubuntu.

Benedikt

dpb

unread,
Feb 13, 2012, 5:11:46 PM2/13/12
to
On 2/13/2012 11:26 AM, Benedikt F wrote:
> Hi everyone,
> I tried the following code and was surprised by the result:
>
> Ts = randn(200,1000); %random data
> Rtest = corrcoef(Ts); %get correlation matrix of these
> isequal(Rtest,Rtest.') %check correlation matrix for symmetry
> -> ans = 0
>
> The asymmetry is about the rounding error, but where does it come from?
> If each symmetric value is computed once and then assigned twice, this
> should't happen.
...

Well, that would seem to indicate that it wasn't just computed once,
doesn't it? Order can make a difference in floating point; a lsb error
isn't a flaw under IEEE afaik that you can expect such to not occur on
occasion.

--

Matt J

unread,
Feb 14, 2012, 10:04:43 AM2/14/12
to
"Benedikt F" wrote in message <jhbh3i$g8q$1...@newscl01ah.mathworks.com>...
> Hi everyone,
> I tried the following code and was surprised by the result:
>
> Ts = randn(200,1000); %random data
> Rtest = corrcoef(Ts); %get correlation matrix of these
> isequal(Rtest,Rtest.') %check correlation matrix for symmetry
> -> ans = 0
>
> The asymmetry is about the rounding error, but where does it come from? If each symmetric value is computed once and then assigned twice, this should't happen.
================

I don't have the statistics toolbox, but if corrcoeff is an mfile, you could look inside to verify whether in fact each symmetric value is computed only once. It sounds like it isn't implemented this way.
Doing

Rtest=.5*(Rtest+Rtest.')

will probably help.
0 new messages