FINDING DETERMINANT OF MATRIX AFTER TAKING COVARIANCE
2 views (last 30 days)
Show older comments
Z=cov(x);
disp(Z);
ans:cov
0.3333 0.4167 0.2500
0.4167 0.5833 0.3750
0.2500 0.3750 0.2500
G=det(Z);
disp(G);
detr
2.2407e-018 determinant value obtained manually and in calci is -1.5625*(10^-6). using det after covariance producing wrong ans. help me how to take a matrix (3*3), then take covariance and for that want to take determinant.... help me in this
0 Comments
Answers (3)
Oleg Komarov
on 28 Aug 2011
disp(Z)
try:
format long
disp(pi)
format short
disp(pi)
3 Comments
Oleg Komarov
on 28 Aug 2011
Your cov matrix is stored with precision up to the 16 decimal places, after that floating point approximation "kicks in" (not MATLAB dependendant).
Unless you specify more clearly what constitutes problem for you, I would say yes, no problem. Use cov and then det.
Honglei Chen
on 29 Aug 2011
As Oleg mentioned, I think this is a precision thing. I'm curious what is the original number you put in as x. Based on the number you are given, I tried to put in the fraction as the input to det and it works fine
>> det([1/3 5/12 1/4;5/12 7/12 3/8;1/4 3/8 1/4])
ans =
1.1565e-18
Mike Hosea
on 7 Sep 2011
I can give you a quick manual calculation of det(cov(x)). It's just 0. The problem is that determinant is not well-behaved in finite precision arithmetic. If you matrix is badly scaled and the exact answer is zero, your calculated determinant will be entirely composed of numerical noise. All of these answers are noise:
>> x = cov(rand(3))
x =
0.147692200988288 0.095764562838736 0.073054502962085
0.095764562838736 0.063238321621117 0.049927796895473
0.073054502962085 0.049927796895473 0.041859114554002
>> det(x)
ans =
5.736287575505627e-21
>> det(100*x)
ans =
5.454390014652211e-15
>> det(1e6*x)
ans =
0.008592762115391
>> det(1e10*x)
ans =
6.898406910429394e+09
I'm not aware of any good reasons to calculate the determinant of a matrix numerically. For example, use the RANK function to determine whether a matrix is singular. -- Mike
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!