0

I have two signals X : [250x1] double and Y : [250x1] double,

I want to calculate the co-variance matrix, by the deffinition.

The answer should be C : [250x250] double. However by C = cov(X,Y),

the answer is C : [2x2] double.

What is the problem?

I want to calculate (X-mean(X))T * C^-1 * (Y-mean(Y)),

which faces problem with a C : [2x2] double.

8
  • 1
    well according to your link (last line of the intro): "a 2×2 matrix would be necessary to fully characterize the two-dimensional variation." so everything looks fine no? Commented Oct 20, 2014 at 12:32
  • 1
    cov(x), if x is a vector, returns the variance of x. Commented Oct 20, 2014 at 12:33
  • 1
    What does X mean? Is X a multidimensional process or are the rows of X realizations of the same process? (same for Y) Commented Oct 20, 2014 at 12:33
  • @Benoit_11, I want to calculate (X-mean(X))T*C^-1*(Y-mean(Y)), so C should be [250*250] for it to work. Commented Oct 20, 2014 at 12:37
  • @NKN, cov(x,y) returns the conariance matrix of x and y according to MATLAB help. Commented Oct 20, 2014 at 12:38

1 Answer 1

2

In many applications, the concept of covariance is like the variance, but applied to a comparison of two vectors: in place of the sum of squares, we have a sum of cross-products.

According to your comment:

I want to calculate (X-mean(X))TC^-1(Y-mean(Y)),

I guess you are looking for something like the following:

X=randn(250,1); Y=randn(250,1); C = (1/249)*(X-mean(X))'*(Y-mean(Y)) 

It has been divided by N-1 to get an unbiased estimator of the sample covariance.

Also, if you want to comapre two matrices using cov function, you may do this:

X = randn(250,1); Y = randn(250,1); C = cov([X(:) Y(:)]) % the result is a 2x2 matrix 
Sign up to request clarification or add additional context in comments.

2 Comments

could you please check this to see that if your formula would work in that pdf eq.(2.4), thanks
finally I used your formula and it worked, but I'm not sure if it's true!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.