[SciPy-User] Strange behaviour from corrcoef when calculating correlation-matrix in SciPy/NumPy.

Pauli Virtanen pav at iki.fi
Thu Mar 3 18:56:47 EST 2011


On Thu, 03 Mar 2011 22:18:31 +0200, eat wrote:

>> *corrcoef([X(:) Y(:)]) %(1*
> ans =
>    1.00000   0.26328
>    0.26328   1.00000
[clip]
>> *corrcoef(X, Y) %(3*
> ans =
>    0.69462   0.13884
>   -0.43644   0.31623

You made a mistake here. The two always return the same results (cut and 
paste):

>> X= [1 2 7 3; 2 1 1 2]'

X =

     1     2
     2     1
     7     1
     3     2

>> Y= [4 2 7 1; 9 1 7 3]'

Y =

     4     9
     2     1
     7     7
     1     3

>> corrcoef([X(:) Y(:)])

ans =

    1.0000    0.2633
    0.2633    1.0000

>> corrcoef(X, Y)  

ans =

    1.0000    0.2633
    0.2633    1.0000




More information about the SciPy-User mailing list