How to obtain the 3 × 3 symmetric covariance matrix of a 3x1 matrix?

8 views (last 30 days)
YZ
YZ on 1 Oct 2021
Edited: John D'Errico on 1 Oct 2021
A 3x1 matrix A = [1; 2; 3]. Use function cov and the result is cov(A) = 1.
Can A have a 3 × 3 symmetric covariance matrix? Thank you

Answers (2)

Matt J
Matt J on 1 Oct 2021
cov(A) considers the rows of A to be different observations and the columns of A to be different variables. So, if A is 3x1, then you have 1 variable. Therefore, its covariance matrix will be a 1x1 matrix, i.e., a scalar consisting of the variance of the observations. This confirms that cov() gave you the right result:
var([1;2;3])
ans = 1

John D'Errico
John D'Errico on 1 Oct 2021
Edited: John D'Errico on 1 Oct 2021
If all you have are three numbers, then a covariance matrix is meaningless. There are two cases we might consider, since I have no idea what you think you have.
  1. If they are three independent values, so three samples form a single distributino, then at best, you can compute a variance. But just a single variance, of the three numbers.
  2. If they represent ONE sample from some distribution of points in some three dimensional space, then you have only ONE point. Again, a covariance matrix is impossible to determine.
If you think you need a 3x3 covariance matrix, then it must be case #2. But as I said, then you have only ONE data point. You cannot determine a covariance matrix from one piece of information. The covariance matrix you desire to compute is undefined. In fact, the only valid covariance matrix from that single piece of information will be effectively
NaN(3,3)
ans = 3×3
NaN NaN NaN NaN NaN NaN NaN NaN NaN
Why is that? Because the computation of said covariance matrix will involve the value
0/0
ans = NaN
for all 9 elements of that matrix.
So while the underlying process that generated the vector may have a well defined covariance matrix, you cannot compute it from one vector. You need more data.
You cannot squeeze blood from a rock. Well, you might get blood if you try, but if you look at your hands, the blood came from your own fingers. Sorry.

Tags

Products


Release

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!