Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to find covariance matrix of 3 or more vectors in matlab?

  1. Aug 16, 2013 #1
    Hi all,
    I know how to find covariance of 2 vectors and variance too. If covariance matrix is to be found of 3 vectors x,y and z, then then the cov matrix is given by

    cov_matrix(x,y,z) =[var(x) cov(x,y) cov(x,z); cov(x,y) var(y) cov(y,z); cov(x,z) cov(y,z) var(z) ];

    Is this equation right? In matlab I believe we first have to define a 3 row matrix 'A' to consider 3 vectors at once finding covariance matrix. Then command cov(A) gives the cov matrix. But I doubt whether this result matches with the above equation.

    -Devanand T
     
  2. jcsd
  3. Aug 16, 2013 #2

    chiro

    User Avatar
    Science Advisor

    Hey dexterdev.

    In general, the covariance matrix element (i,j) has the value Cov(Xi,Xj) = E[Xi*Xj] - E[Xi]E[Xj] for all random variables Xi and Xj. If i = j you get the variance Var[Xi].

    This definition holds for any finite number of random variables.
     
  4. Aug 16, 2013 #3
    @chiro : I got it Sir, thanks....
     
    Last edited: Aug 17, 2013
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to find covariance matrix of 3 or more vectors in matlab?
  1. Covariance matrix (Replies: 4)

Loading...