FINDING DETERMINANT OF MATRIX AFTER TAKING COVARIANCE
조회 수: 4 (최근 30일)
이전 댓글 표시
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
답변 (3개)
Oleg Komarov
2011년 8월 28일
disp(Z)
try:
format long
disp(pi)
format short
disp(pi)
댓글 수: 3
Oleg Komarov
2011년 8월 28일
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
2011년 8월 29일
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
2011년 9월 7일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!