[Numpy-discussion] corrcoef

Sven Schreiber svetosch@gmx....
Thu Sep 6 12:13:24 CDT 2007


John Hunter schrieb:
> Is it desirable that numpy.corrcoef for two arrays returns a 2x2 array
> rather than a scalar
> 
> In [10]: npy.corrcoef(npy.random.rand(10), npy.random.rand(10))
> Out[10]:
> array([[ 1.        , -0.16088728],
>        [-0.16088728,  1.        ]])
> 
> 
> I always end up extracting the 0,1 element anyway.  What is the
> advantage, aside from backwards compatibility, for returning a 2x2?
> JDH

Forgive me if my answer is trivial and misses your point, but I guess
because for more than two data series one also gets the entire
correlation matrix and that is desirable. However, I would agree that
the name "corrcoef" is unfortunate, suggesting a scalar value (at least
to me).

-sven


More information about the Numpy-discussion mailing list