[Numpy-discussion] Re: [SciPy-dev] Computing correlations with SciPy
oliphant.travis at ieee.org
Fri Mar 17 00:45:05 CST 2006
John Hunter wrote:
> The following message is a courtesy copy of an article
> that has been posted to comp.lang.python as well.
>>>>>> "tkpmep" == tkpmep <tkpmep at hotmail.com> writes:
> tkpmep> I want to compute the correlation between two sequences X
> tkpmep> and Y, and tried using SciPy to do so without success.l
> tkpmep> Here's what I have, how can I correct it?
> >>>> X = [1, 2, 3, 4, 5] Y = [5, 4, 3, 2, 1] import scipy
> >>>> scipy.corrcoef(X,Y)
> tkpmep> Traceback (most recent call last): File "<interactive
> tkpmep> input>", line 1, in ? File
> tkpmep> "C:\Python24\Lib\site-packages\numpy\lib\function_base.py",
> tkpmep> line 671, in corrcoef d = diag(c) File
> tkpmep> "C:\Python24\Lib\site-packages\numpy\lib\twodim_base.py",
> tkpmep> line 80, in diag raise ValueError, "Input must be 1- or
> tkpmep> 2-d." ValueError: Input must be 1- or 2-d.
> Hmm, this may be a bug in scipy. matplotlib also defines a corrcoef
> function, which you may want to use until this problem gets sorted out
The problem is now sorted out in SVN of numpy. The problem was
inherited from Numeric's MLab. I revamped the cov function (which
corrcoef depended on) so it should hopefully work better than it did.
Thanks for the heads up.
More information about the Numpy-discussion