Create a matrix with a specific correlation within a specific distribution

1 回表示 (過去 30 日間)
Carlos Bosley
Carlos Bosley 2018 年 11 月 13 日
I am creating matrices of random variables within the normal, uniform, and chi square distributions. However, I need to be able to specify the correlation value of the matrices.
rowsize = 10;
columnsize = 3;
dg = 2;
correlation_value = 0.7;
matrix = zeros(rowsize, columnsize);
for row = 1:rowsize
for column = 1:columnsize
matrix(row, column) = chi2rnd(dg);
end
end
correlatedMatrix = SomeFunction(matrix, correlation_value);
result = corr(correlatedMatrix)
result =
1.0000 0.7000 0.7000
0.7000 1.0000 0.7000
0.7000 0.7000 1.0000
Is there a function or some code to replace
correlatedMatrix = SomeFunction(...)
or a function or code to replace the call to chi2rnd(dg) where result will still be within the chi square distribution?

回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by