mvnrndを使ったエラーについて

mvnrndを使用して多変量正規分布の乱数発生を行いたいです。しかし、「sigmaは対称反正定行列でなければなりません」とエラーが生じて実行ができないです。共分散を確認しても値は0を含む半正定となっており、issymmetricを使用し対称になっているのも確認しました。何度も確認しきちんと対称半正定行列になっているのにエラーが出ます。解決策を教えていただきたいです。

Réponses (1)

Mariko Yamamoto
Mariko Yamamoto le 15 Nov 2021

0 votes

D=2;
Ngen=10;
mu = [1 2];
sigma = [1 0.5; 0.5 2];
mvnrnd(mu,sigma,Ngen)
としたいところ
R = chol(sigma);
z = repmat(mu,Ngen,1) + randn(Ngen,D)*R
としてはどうでしょうか

Catégories

En savoir plus sur 乱数発生器 dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!