[SciPy-user] Cov of 2 vectors

Scott Sinclair scott.sinclair.za@gmail....
Thu May 28 02:48:54 CDT 2009

>2009/5/28  <sandeep.prasad@tcs.com>:
> How do i compute the covar of 2 vectors. The cov module in scipy always
> returns a 2 by 2matrix even if the vectors are of len >2 , how is this
> possible??
> However for the covariance of x and y i need a single number, are there any
> built in functions for this??

You're getting the full covariance matrix from cov. Since you only
have two vectors this is always a 2x2 matrix. The off-diagonal terms
[at locations (0, 1) & (1, 0)] are the covariance of your two vectors
and the on-diagonal terms represent the variance of each vector.




More information about the SciPy-user mailing list