实验中,matlab用cov()得到协方差矩阵,这个矩阵作为多维高斯分布的gamma参数,结果gamma参数要求该矩阵为正定矩阵,而该矩阵只能保证为对称矩阵。http://stackoverflow.com/questions/11269715/matlabs-sigma-must-be-symmetric-and-positive-definite-error-sometimes-not-mak
给出了解决方案
This happens if the diagonal values of the covariance matrix are (very close to) zero. A simple fix is add a very small constant number to c
.
err_cnt = 0;
for i = 1:1000
try
a = rand(3);
c = cov(a) + .0001 * eye(3);
m = mean(a);
mvnpdf(a, m, c);
catch me
err_cnt = err_cnt + 1;
end
end
Results in 0 errors.
May 08, 2018 12:26:32 AM