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

Pauli Virtanen pav@iki...
Thu Mar 3 03:44:20 CST 2011


Hi,

Wed, 02 Mar 2011 14:36:18 -0500, josef.pktd wrote:
[clip]
>> The Matlab convention
>>
>>        corrcoef(x, y) == corrcoef(c_[x.ravel(), y.ravel()])
> 
> I don't remember matlab exactly, but I don't think there is a ravel, and
> I think R also does
> 
> cov(x, y) = np.dot((x-x.mean()).T, y-y.mean())
> 
> and normalized for corrcoef.

There's a ravel, according to their docs:

	http://www.mathworks.com/help/techdoc/ref/cov.html

"""cov(X,Y), where X and Y are matrices with the same number of elements, 
is equivalent to cov([X(:) Y(:)])."""

X(:) is the matlab notation for raveling.

-- 
Pauli Virtanen



More information about the SciPy-User mailing list