Computing correlations with SciPy
tkpmep at hotmail.com
tkpmep at hotmail.com
Sun Mar 19 10:18:31 EST 2006
Tested it and it works like a charm! Thank you very much for fixing
this. Not knowing what an SVN is, I simply copied the code into the
appropriate library files and it works perfectly well.
May I suggest a simple enhancement: modify corrcoef so that if it is
fed two 1 dimensional arrays, it returns a scalar. cov does something
similar for covariances: if you feed it just one vector, it returns a
scalar, and if you feed it two, it returns the covariance matrix i.e:
>>> x = [1, 2, 3, 4, 5]
>>> z = [5, 4, 3, 2, 1]
>>> scipy.cov(x,z)
array([[ 2.5, -2.5],
[-2.5, 2.5]])
>>> scipy.cov(x)
2.5
I suspect that the majority of users use corrcoef to obtain point
estimates of the covariance of two vectors, and relatively few will
estimate a covariance matrix, as this method tends not to be robust to
the presence of noise and/or errors in the data.
Thomas Philips
More information about the Python-list
mailing list